Repository navigation
chore: Add failing tests reproducing old bugs (#5652, #6158, #8561, #10181, #10962, #11240) - #12557
paveltiunov wants to merge 1 commit into
Conversation
…10181, #10962, #11240) These tests only reproduce the bugs and don't fix them: - #8561 schema-compiler: subquery dimension join aliases ignore sql_alias, so long cube names collide after Postgres truncates identifiers - #10181 schema-compiler: ungrouped query on a cube without a primary key fails in PreAggregations even with allowUngroupedWithoutPrimaryKey - #6158 schema-compiler: case dimension with an empty when list renders invalid SQL - #11240 schema-compiler: time_shift measure with a joined cube dimension splits each day into two rows - #5652 api-gateway: time measures always resolve to null in GraphQL - #10962 cubesql: Bind after a failed Parse still sends BindComplete Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TgekqD53E1skuvTgq3W1Ks
|
Claude finished @paveltiunov's task in 1m 35s —— View job Changes requested: 1 high, 1 medium, 2 low. All six new tests fail on Review details
Findings
Notes
|
| })(req, res); | ||
| }); | ||
|
|
||
| test('should return the value of a time measure', async () => { |
There was a problem hiding this comment.
High: merging this turns CI red. Every new test fails on master, and CI runs all of them:
- this one: the api-gateway
unitstep (push.yml:139,lerna run unit) issue-{6158,8561,10181,11240}.test.ts: theintegrationjob,postgresmatrix entry (.github/actions/integration/postgres.sh→integration:postgres), on bothuse_tesseract_sql_plannervaluestest_bind_after_failed_parse_is_skipped:cargo insta test --workspaceinrust-cubesql.yml:113
The repo already has a pattern for this: packages/cubejs-testing/test/smoke-view-join.test.ts:75 uses test.failing(...). Jest 29 supports it here. It also signals when a fix lands, because the test then "unexpectedly passes" and has to be flipped back to test. In Rust, see the comment on test_extended_query_errors.rs:109.
| test('should return the value of a time measure', async () => { | |
| test.failing('should return the value of a time measure', async () => { |
The same change applies to the it(...) in issue-6158, issue-8561 and issue-10181, and to testIfNative in issue-11240 (getEnv('nativeSqlPlanner') ? it.failing : it.skip). One caveat: test.failing passes on any throw, so a broken DB connection or a typo in the fixture also counts as "still failing". Pinning the expected error, as smoke-view-join.test.ts:119 does, keeps the test honest.
| socket | ||
| } | ||
|
|
||
| #[tokio::test] |
There was a problem hiding this comment.
This test fails on master (2EZ vs EZ), and rust-cubesql.yml:113 runs cargo insta test --workspace, so the cubesql job goes red once this merges. Mark it ignored until #10962 is fixed. #[should_panic] is a worse fit: it would also pass on the 10s read timeout or on any expect in the handshake.
| #[tokio::test] | |
| #[tokio::test] | |
| #[ignore = "https://github.com/cube-js/cube/issues/10962"] |
| // Reproduces https://github.com/cube-js/cube/issues/11240: a `time_shift` measure | ||
| // queried with a dimension of a joined cube. The shifted CTE joins that cube on the | ||
| // unshifted fact date, so its `day_name` belongs to the previous day, and the final | ||
| // join uses `day_name` to align the shifted and current rows. Each day comes back as | ||
| // two rows, one with `total` and one with `total_prior_day`. |
There was a problem hiding this comment.
Low: this 5-line header re-narrates the issue. The same goes for the headers in issue-8561.test.ts:1-5, issue-10181.test.ts:1-5, test_extended_query_errors.rs:1-5 and the 3–4 line blocks in issue-6158.test.ts and graphql.test.ts:422. The issue link and the test name already carry the symptom. Keep the load-bearing sentence, i.e. what a later reader would get wrong without it. Here that is:
| // Reproduces https://github.com/cube-js/cube/issues/11240: a `time_shift` measure | |
| // queried with a dimension of a joined cube. The shifted CTE joins that cube on the | |
| // unshifted fact date, so its `day_name` belongs to the previous day, and the final | |
| // join uses `day_name` to align the shifted and current rows. Each day comes back as | |
| // two rows, one with `total` and one with `total_prior_day`. | |
| // https://github.com/cube-js/cube/issues/11240: the shifted CTE joins dim_date on the | |
| // unshifted date, so aligning on day_name splits each day into two rows. |
| allowUngroupedWithoutPrimaryKey: true, | ||
| order: [{ id: 'no_pk.a' }], | ||
| timezone: 'UTC', | ||
| } as any); |
There was a problem hiding this comment.
Low: the as any isn't needed. allowUngroupedWithoutPrimaryKey is declared in BaseQueryOptions (src/adapter/BaseQuery.ts:128), and order is any[]. The cast only hides type errors if the option is renamed.
| } as any); | |
| }); |
Check List
Issue Reference this PR resolves
Refs #5652, #6158, #8561, #10181, #10962, #11240. These tests only reproduce the bugs and don't fix them. Each one fails on current
master. I also reproduced every bug end to end on the v1.8.16 release, running Cube and Cube Store against Postgres 16.packages/cubejs-schema-compiler/test/integration/postgres/issue-8561.test.ts: the join alias of a subquery dimension is built from the cube name and ignoressql_alias. With two subquery dimensions on a cube whose name is longer than 63 characters, Postgres truncates both aliases to the same name and fails withtable name "..." specified more than once. Fails on both planners.allowUngroupedWithoutPrimaryKeyset to true #10181packages/cubejs-schema-compiler/test/integration/postgres/issue-10181.test.ts: an ungrouped query on a cube without a primary key, withallowUngroupedWithoutPrimaryKey: true. The SQL builds, butPreAggregations.transformQueryToCanUseFormcallsprimaryKeyNames()and throwsOne or more Primary key is required for 'no_pk' cube. The server runs that path on every/v1/loadrequest. Fails on both planners.packages/cubejs-schema-compiler/test/integration/postgres/issue-6158.test.ts: acasedimension withwhen: []compiles but rendersCASE ELSE 'Unknown' END, which Postgres rejects. Fails on both planners.packages/cubejs-schema-compiler/test/integration/postgres/issue-11240.test.ts: atime_shiftmeasure queried with a dimension from a joined cube. The shifted CTE joinsdim_dateon the unshifted date, and the final join aligns rows onday_nametoo, so each day comes back as two rows: one withtotaland one withtotal_prior_day. Tesseract only; skipped on the legacy planner, which doesn't support multi-stage measures.packages/cubejs-api-gateway/test/graphql.test.ts(time measures): atimemeasure is typed asTimeDimensionin the GraphQL schema. The result mapping only adds thevaluepath for time dimensions, so a time measure always resolves to null. Because of this, the workaround for the original report (atype: timemeasure withMIN(...)instead oftype: minon a date) doesn't work over GraphQL either.rust/cubesql/cubesql/src/compile/test/test_extended_query_errors.rs: sends Parse (a failing query), Bind, Describe, Execute and Sync over the wire. Cube answersBindComplete,ErrorResponse,ReadyForQuery; Postgres answers onlyErrorResponse,ReadyForQuery. The Bind handler inshim.rsstill callsself.bind()whentracked_erroris set.Test runs:
TEST_LOCAL=1 jest dist/test/integration/postgres/issue-*withCUBEJS_TESSERACT_SQL_PLANNER=trueandfalse: all fail as described above.jest dist/test/graphql.test.js: only the newtime measurestest fails.cargo test -p cubesql --lib test_bind_after_failed_parse_is_skipped: fails with2EZinstead ofEZ.Generated by Claude Code