fix(schema-compiler): handle sqlTable in originalSql pre-aggregation#10824
fix(schema-compiler): handle sqlTable in originalSql pre-aggregation#10824paveltiunov wants to merge 2 commits intomasterfrom
Conversation
When a cube uses `sqlTable` instead of `sql`, the `preAggregationSql` method for `originalSql` type pre-aggregations would crash with: TypeError: Cannot read properties of undefined (reading 'apply') This happened because `cubeFromPath(cube).sql` is undefined for cubes that use `sqlTable`, and the undefined value was passed to `evaluateSql()` which called `resolveSymbolsCall(undefined, ...)`. The fix checks for `sqlTable` first (matching the logic in `cubeSql()`) before falling back to `sql`. Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
|
Claude finished @paveltiunov's task in 1m 49s —— View job Code Review: PR #10824
Verdict: This PR looks good. The fix is correct, minimal, and well-tested. A few observations below. Fix Analysis (
|
d1a515c to
e4a57c6
Compare
|
Claude finished @paveltiunov's task in 1m 57s —— View job Code Review: PR #10824
Verdict: This PR looks good. The fix is correct, minimal, and well-tested. Detailed analysis below. Fix Analysis (
|
When a cube uses sqlTable instead of sql, the preAggregationSql method for originalSql type pre-aggregations crashed with: TypeError: Cannot read properties of undefined (reading 'apply') Root cause: cubeFromPath(cube).sql is undefined for cubes that use sqlTable, and the undefined value was passed to evaluateSql() which called resolveSymbolsCall(undefined, ...). The fix handles the sqlTable case separately, wrapping the resolved table name in SELECT * FROM to produce valid SQL (matching the semantics of cubeSql()). Also adds an integration test that runs the pre-aggregation query against Postgres via evaluateQueryWithPreAggregations(). Co-authored-by: Pavel Tiunov <pavel.tiunov@gmail.com>
e4a57c6 to
cfcd8f5
Compare
Check List
Description of Changes Made
When a cube uses
sqlTableinstead ofsql, thepreAggregationSqlmethod fororiginalSqltype pre-aggregations crashes with:This happens during
/cubejs-system/v1/pre-aggregations/partitionscalls when the cube definition usessqlTableinstead ofsql.Root cause: In
BaseQuery.preAggregationSql(), theoriginalSqlbranch calledevaluateSql(cube, cubeFromPath.sql)directly, butcubeFromPath.sqlisundefinedfor cubes that usesqlTable.Fix: Reuse the existing
cubeSql()method which already handles bothsqlTableandsqlcubes correctly, instead of accessingcubeFromPath.sqldirectly:Tests added:
originalSqlpre-aggregations on cubes that usesqlTable, verifyingpreAggregationSql()produces validSELECT * FROMSQL.dbRunner.evaluateQueryWithPreAggregations(), verifying correct data retrieval through theoriginalSqlpre-aggregation withsqlTable.