feat: Support pre-aggregation-specific data source credentials (CORE-…#10587
feat: Support pre-aggregation-specific data source credentials (CORE-…#10587
Conversation
9ab1520 to
141cdad
Compare
141cdad to
05bc016
Compare
5d296f4 to
ecee6f0
Compare
|
Claude finished @ovr's task in 6m 12s —— View job Code Review: Pre-aggregation-specific data source credentials
SummaryThis PR adds support for separate database credentials for pre-aggregation workloads, allowing users to configure a different user/password (or other connection parameters) for pre-aggregation building vs. regular queries. The implementation:
The overall architecture is sound — the approach of reusing the existing driver factory with a boolean flag is clean and backward-compatible. However, I found several bugs and one design concern that should be addressed before merge. Bugs Found1. 2. Stale 3. SSL cert env vars not updated for pre-aggregations (could not attach inline - Design ConcernNo fallback to base env vars (inline comment) When This forces users to duplicate all connection env vars for pre-aggregations, not just the ones they want to override. For a "separate credentials" feature, a fallback pattern would be much more ergonomic: CUBEJS_DB_HOST=shared-host # used by both
CUBEJS_DB_USER=regular-user
CUBEJS_PRE_AGGREGATIONS_DB_USER=preagg-user # only override what differsIf this no-fallback behavior is intentional, it should be clearly documented. Positive Observations
Minor Items
|
packages/cubejs-backend-shared/test/db_env_pre_aggregations.test.ts
Outdated
Show resolved
Hide resolved
| if (preAggregations) { | ||
| const dsMatch = key.match(/^(CUBEJS_DS_[A-Z0-9_]+?_)(DB_|JDBC_|AWS_|DATABASE|FIREBOLT_)(.*)/); | ||
| if (dsMatch) { | ||
| return `${dsMatch[1]}PRE_AGGREGATIONS_${dsMatch[2]}${dsMatch[3]}`; | ||
| } | ||
|
|
||
| if (key.startsWith('CUBEJS_')) { | ||
| return key.replace(/^CUBEJS_/, 'CUBEJS_PRE_AGGREGATIONS_'); | ||
| } | ||
| } |
There was a problem hiding this comment.
Suggestion: Consider adding a unit test for edge cases in the regex. The regex ^(CUBEJS_DS_[A-Z0-9_]+?_)(DB_|JDBC_|AWS_|DATABASE|FIREBOLT_)(.*) uses a non-greedy match for the DS name which could behave unexpectedly with certain datasource names.
For example, a datasource named db would produce the key CUBEJS_DS_DB_DB_HOST. The non-greedy [A-Z0-9_]+?_ would match CUBEJS_DS_D first, then try B_DB_HOST against the alternation — B_ doesn't match DB_, so it extends to CUBEJS_DS_DB_ and then matches DB_HOST. This works, but edge cases like datasource names containing DB, AWS, JDBC, etc. as substrings should be tested.
Also, DATABASE in the alternation doesn't have a trailing underscore. For CUBEJS_DS_FOO_DATABASE_SECRET_ARN, group 2 captures DATABASE and group 3 captures _SECRET_ARN (including the leading underscore). This produces CUBEJS_DS_FOO_PRE_AGGREGATIONS_DATABASE_SECRET_ARN which is correct, but the asymmetry with other alternatives (which have trailing _) is subtle.
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #10587 +/- ##
==========================================
+ Coverage 57.84% 57.93% +0.09%
==========================================
Files 225 215 -10
Lines 17637 16635 -1002
Branches 3634 3343 -291
==========================================
- Hits 10202 9638 -564
+ Misses 6890 6508 -382
+ Partials 545 489 -56
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
No description provided.