Skip to content

Conversation

@pauldheinrichs
Copy link
Contributor

@pauldheinrichs pauldheinrichs commented May 19, 2024

Check List

  • Tests has been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Issue Reference this PR resolves
Resolves: #8268

Description of Changes Made (if issue reference is not provided)

Resolves:

  • Pre aggregation rollup_join query invalidations for cross datasource utilizing different parameter symbols.
  • IE: Oracle, Postgres, Druid, MSSQL

Summary:

So this is a fun one, here's the situation. At first i thought this was entirely community druid problem but tracked it down to an underlying issue with rollup_joins.

If we rollup_join two datasources that contain a different paramAllocator symbol (IE: $1 and ?) the default paramAllocator would inject the wrong parameters into the pre-aggregation sql code invalidating the cache on the API node and causing weird behaviour. This would only present itself when actually querying the data and thus causing issues.


Smoke tested:

  • Refresh schedules refreshing pre-aggregations
  • Generated pre-aggregations

Thanks ❤️

@pauldheinrichs pauldheinrichs requested a review from a team as a code owner May 19, 2024 03:26
@vercel
Copy link

vercel bot commented May 19, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

8 Ignored Deployments
Name Status Preview Comments Updated (UTC)
examples-angular-dashboard ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-d3 ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-dashboard ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-data-table ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-highcharts ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-material-ui ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-react-pivot-table ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am
examples-vue-query-builder ⬜️ Ignored (Inspect) Visit Preview Jun 24, 2024 0:30am

@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label May 19, 2024
@pauldheinrichs pauldheinrichs requested a review from a team as a code owner May 21, 2024 14:33
// By default, we'll use BaseQuery, but it's important to note that different databases (Oracle, PostgreSQL, MySQL, Druid, etc.)
// have unique parameter allocator symbols. Using the wrong allocator can break the query, especially when rollup joins involve
// different cubes that require different allocators.
return this.options.queryFactory.createQuery(cube, this.compilers, { ...this.subQueryOptions(options), paramAllocator: undefined });
Copy link
Contributor Author

@pauldheinrichs pauldheinrichs May 21, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unset the paramAllocator set by this.subQueryOptions to allow QueryClasses to assume their default paramAllocator class

@pauldheinrichs pauldheinrichs changed the title Resolve rollup join pre-aggregation param allocator issue fix(schema-compiler) Resolve rollup join pre-aggregation param allocator issue May 21, 2024
@paveltiunov
Copy link
Member

@pauldheinrichs Thanks for contributing! Could you please set the allocator to undefined in the branch without queryFactory as well? It should be consistent.

@paveltiunov paveltiunov self-assigned this May 23, 2024
@pauldheinrichs
Copy link
Contributor Author

pauldheinrichs commented May 23, 2024

@pauldheinrichs Thanks for contributing! Could you please set the allocator to undefined in the branch without queryFactory as well? It should be consistent.

@paveltiunov For sure, i've updated the newSubQuery method to behave the same!

@pauldheinrichs
Copy link
Contributor Author

@paveltiunov sorry for the ping - curious if there's any other adjustments needed from my end here to push this forward!

newSubQuery(options) {
const QueryClass = this.constructor;
return new QueryClass(this.compilers, this.subQueryOptions(options));
return new QueryClass(this.compilers, { ...this.subQueryOptions(options), paramAllocator: undefined });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't unset param allocator here as it should reused in case of actual sub_query: true members.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What would you recommend here then, reverting the last commit and pushing forward with just the initial implementation?

@paveltiunov
Copy link
Member

Closing as it was fixed in #8619

@pauldheinrichs pauldheinrichs deleted the ph/8268 branch September 13, 2024 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:community Contribution from Cube.js community members.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rollup joins across different data sources with different param allocators causing invalidations

2 participants