Skip to content

Add CUBEJS_CUBESTORE_ROLLING_WINDOW_JOIN flag #9351

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/cubejs-backend-shared/src/env.ts
Original file line number Diff line number Diff line change
@@ -1848,6 +1848,9 @@ const variables: Record<string, (...args: any) => any> = {
cubeStoreNoHeartBeatTimeout: () => get('CUBEJS_CUBESTORE_NO_HEART_BEAT_TIMEOUT')
.default('30')
.asInt(),
cubeStoreRollingWindowJoin: () => get('CUBEJS_CUBESTORE_ROLLING_WINDOW_JOIN')
.default('false')
.asBoolStrict(),

allowUngroupedWithoutPrimaryKey: () => get('CUBEJS_ALLOW_UNGROUPED_WITHOUT_PRIMARY_KEY')
.default(get('CUBESQL_SQL_PUSH_DOWN').default('true').asString())
17 changes: 15 additions & 2 deletions packages/cubejs-schema-compiler/src/adapter/CubeStoreQuery.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import moment from 'moment-timezone';
import { parseSqlInterval } from '@cubejs-backend/shared';
import { parseSqlInterval, getEnv } from '@cubejs-backend/shared';
import { BaseQuery } from './BaseQuery';
import { BaseFilter } from './BaseFilter';
import { BaseMeasure } from './BaseMeasure';
@@ -30,6 +30,13 @@ type RollingWindow = {
};

export class CubeStoreQuery extends BaseQuery {
private readonly cubeStoreRollingWindowJoin: boolean;

public constructor(compilers, options) {
super(compilers, options);
this.cubeStoreRollingWindowJoin = getEnv('cubeStoreRollingWindowJoin');
}

public newFilter(filter) {
return new CubeStoreFilter(this, filter);
}
@@ -55,10 +62,16 @@ export class CubeStoreQuery extends BaseQuery {
}

public subtractInterval(date: string, interval: string) {
if (this.cubeStoreRollingWindowJoin) {
return super.subtractInterval(date, interval);
}
return `DATE_SUB(${date}, INTERVAL ${this.formatInterval(interval)})`;
}

public addInterval(date: string, interval: string) {
if (this.cubeStoreRollingWindowJoin) {
return super.addInterval(date, interval);
}
return `DATE_ADD(${date}, INTERVAL ${this.formatInterval(interval)})`;
}

@@ -179,7 +192,7 @@ export class CubeStoreQuery extends BaseQuery {
cumulativeMeasures: Array<[boolean, BaseMeasure]>,
preAggregationForQuery: any
) {
if (!cumulativeMeasures.length) {
if (this.cubeStoreRollingWindowJoin || !cumulativeMeasures.length) {
return super.regularAndTimeSeriesRollupQuery(regularMeasures, multipliedMeasures, cumulativeMeasures, preAggregationForQuery);
}
const cumulativeMeasuresWithoutMultiplied = cumulativeMeasures.map(([_, measure]) => measure);

Unchanged files with check annotations Beta

use crate::cube_bridge::dimension_definition::DimensionDefinition;

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, bigquery, x86_64-unknown-linux-gnu)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, athena, x86_64-unknown-linux-gnu)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, snowflake, x86_64-unknown-linux-gnu)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cubestore (20.x)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, false)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, true)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, true)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, false)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build & Test :dev for Debian without pushing

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, crate)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, elasticsearch)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mssql)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, firebolt)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql-aurora-serverless)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mongobi)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, vertica)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, druid)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, prestodb)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, postgres)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, clickhouse)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, dremio)

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`

Check warning on line 1 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build native Linux 20 x86_64-unknown-linux-gnu Python fallback

unused import: `crate::cube_bridge::dimension_definition::DimensionDefinition`
use crate::planner::query_tools::QueryTools;
use crate::planner::sql_evaluator::{MemberExpressionSymbol, MemberSymbol, SqlCall};
use crate::planner::sql_templates::PlanSqlTemplates;
use crate::planner::{evaluate_with_context, BaseMember, BaseMemberHelper, VisitorContext};

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, bigquery, x86_64-unknown-linux-gnu)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, bigquery, x86_64-unknown-linux-gnu)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, athena, x86_64-unknown-linux-gnu)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, athena, x86_64-unknown-linux-gnu)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, snowflake, x86_64-unknown-linux-gnu)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cloud (20.x, snowflake, x86_64-unknown-linux-gnu)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cubestore (20.x)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration-cubestore (20.x)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, false)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, false)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, true)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (22.x, 3.11, true)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, true)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, true)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, false)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / unit (20.x, 3.11, false)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build & Test :dev for Debian without pushing

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build & Test :dev for Debian without pushing

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, crate)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, crate)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, elasticsearch)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, elasticsearch)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mssql)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mssql)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, firebolt)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, firebolt)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql-aurora-serverless)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql-aurora-serverless)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mongobi)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mongobi)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, vertica)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, vertica)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, druid)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, druid)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, prestodb)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, prestodb)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, postgres)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, postgres)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, clickhouse)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, clickhouse)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, mysql)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, dremio)

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / integration (20.x, dremio)

unused import: `BaseMember`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build native Linux 20 x86_64-unknown-linux-gnu Python fallback

unused import: `BaseMemberHelper`

Check warning on line 5 in rust/cubesqlplanner/cubesqlplanner/src/planner/filter/base_segment.rs

GitHub Actions / Build native Linux 20 x86_64-unknown-linux-gnu Python fallback

unused import: `BaseMember`
use cubenativeutils::CubeError;
use std::rc::Rc;