Skip to content

Commit f08f19b

Browse files
authored
fix(schema-compiler): Fix pre-agg partitions creation for Ksql (#9750)
1 parent 3a96b22 commit f08f19b

File tree

3 files changed

+11
-0
lines changed

3 files changed

+11
-0
lines changed

packages/cubejs-ksql-driver/src/KsqlQuery.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ export class KsqlQuery extends BaseQuery {
8383
return dimensionColumns.length ? ` GROUP BY ${dimensionColumns.join(', ')}` : '';
8484
}
8585

86+
public partitionInvalidateKeyQueries(_cube: string, _preAggregation: any) {
87+
return [];
88+
}
89+
8690
public preAggregationStartEndQueries(cube: string, preAggregation: any) {
8791
if (preAggregation.partitionGranularity) {
8892
if (!preAggregation.refreshRangeStart) {

packages/cubejs-schema-compiler/src/adapter/BaseQuery.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4456,6 +4456,10 @@ export class BaseQuery {
44564456
return `SELECT ${sql} as refresh_key`;
44574457
}
44584458

4459+
partitionInvalidateKeyQueries(_cube, _preAggregation) {
4460+
// this is not used across all dialects, atm only in KsqlQuery.
4461+
}
4462+
44594463
preAggregationInvalidateKeyQueries(cube, preAggregation, preAggregationName) {
44604464
return this.cacheValue(
44614465
['preAggregationInvalidateKeyQueries', cube, JSON.stringify(preAggregation)],

packages/cubejs-schema-compiler/src/adapter/PreAggregations.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ export class PreAggregations {
237237
const tableName = this.preAggregationTableName(cube, preAggregationName, preAggregation);
238238
const invalidateKeyQueries = this.query.preAggregationInvalidateKeyQueries(cube, preAggregation, preAggregationName);
239239
const queryForSqlEvaluation = this.query.preAggregationQueryForSqlEvaluation(cube, preAggregation);
240+
// Atm this is only defined in KsqlQuery but without it partitions are recreated on every refresh
241+
const partitionInvalidateKeyQueries = queryForSqlEvaluation.partitionInvalidateKeyQueries?.(cube, preAggregation);
240242

241243
const allBackAliasMembers = this.query.allBackAliasMembers();
242244

@@ -298,6 +300,7 @@ export class PreAggregations {
298300
timestampPrecision: queryForSqlEvaluation.timestampPrecision(),
299301
tableName,
300302
invalidateKeyQueries,
303+
partitionInvalidateKeyQueries,
301304
type: preAggregation.type,
302305
external: preAggregation.external,
303306
previewSql: queryForSqlEvaluation.preAggregationPreviewSql(tableName),

0 commit comments

Comments
 (0)