Meta attribute macro for Crosstab pivots#133
Conversation
When a sqlQuery has an attributeMetaQueryRef, automatically populate a macro with the ordered column definitions (name + type) from the meta query results. This enables use of crosstab pivots where the AS clause needs to reference the dynamically defined columns. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Move META_ATTRIBUTE_COLUMNS_FOR_CROSSTAB macro population to occur before super.resolveReferences() call. The macro validation happens during super.resolveReferences(), so the macro must be populated in _sqlMacroMap before that point to avoid "macro not defined" errors. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
….jbrestel/project_home/WDK into meta-attribute-macro
Add getPostgresType() method to ColumnType to map WDK types to PostgreSQL type names (e.g., "string" -> "text", "number" -> "integer"). Update SqlQuery to use getPostgresType() when generating the crosstab macro so the AS clause uses valid PostgreSQL types. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
|
Tested on my ToxoDB dev site for phenotype and RNASeq (see related PRs) |
|
Hmm.. Actually something may not be write with the colTypes. The query being run looks like this:
The column being returned "av.number_value" is numeric but the WDK is casting them all to "text" when populating the macro. NOTE: Somehow it seems to be getting this right on the front end because i can see histograms and the sorting by numeric seems to be working. Not sure what is going on there. |
|
Ok. the text vs. numeric issue has been resolved. It is behaving correctly now |
When attributeMetaQueryRef returns zero rows, still define the macro with a placeholder value (_no_columns_defined text) to prevent "macro not defined" validation errors. This ensures the model loads even when a meta query has no results. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Add macro whichis populated by running of an attribute meta query. This allows us to specify columns returned by a "pivot" (crosstab function in postgres).
NOTE: The crosstab function is postgres specific. No attempt was made to name things generically.
Related to :
VEuPathDB/EbrcModelCommon#78
VEuPathDB/ApiCommonModel#139