Skip to content

Commit c81810d

Browse files
committed
fix
1 parent 177b6ef commit c81810d

File tree

7 files changed

+23
-9
lines changed

7 files changed

+23
-9
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,6 +1117,10 @@ export class BaseQuery {
11171117
return `${date} + interval ${intervalStr}`;
11181118
}
11191119

1120+
supportGeneratedSeriesForCustomTd() {
1121+
return false;
1122+
}
1123+
11201124
/**
11211125
* @param {string} interval
11221126
* @returns {string}

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ export class PostgresQuery extends BaseQuery {
5757
return `round(hll_cardinality(hll_add_agg(hll_hash_any(${sql}))))`;
5858
}
5959

60+
public supportGeneratedSeriesForCustomTd() {
61+
return true;
62+
}
63+
6064
public sqlTemplates() {
6165
const templates = super.sqlTemplates();
6266
// eslint-disable-next-line no-template-curly-in-string
@@ -81,11 +85,9 @@ export class PostgresQuery extends BaseQuery {
8185
templates.types.float = 'REAL';
8286
templates.types.double = 'DOUBLE PRECISION';
8387
templates.types.binary = 'BYTEA';
84-
templates.tesseract.support_generated_series_for_custom_td = 'YES';
8588
templates.operators.is_not_distinct_from = 'IS NOT DISTINCT FROM';
8689
templates.statements.generated_time_series_select = 'SELECT {{ date_from }} AS "date_from",\n' +
8790
'{{ date_to }} AS "date_to" \n' +
88-
// 'd + interval {{ granularity }} - interval \'1 millisecond\' AS "date_to" \n' +
8991
'FROM generate_series({{ start }}::timestamp, {{ end }}:: timestamp, {{ granularity }}::interval) d ';
9092
templates.statements.generated_time_series_with_cte_range_source = 'SELECT d AS "date_from",\n' +
9193
'd + interval {{ granularity }} - interval \'1 millisecond\' AS "date_to" \n' +

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ export class PrestodbQuery extends BaseQuery {
122122
return `approx_distinct(${sql})`;
123123
}
124124

125+
public supportGeneratedSeriesForCustomTd() {
126+
return true;
127+
}
128+
125129
protected limitOffsetClause(limit, offset) {
126130
const limitClause = limit != null ? ` LIMIT ${limit}` : '';
127131
const offsetClause = offset != null ? ` OFFSET ${offset}` : '';
@@ -155,7 +159,6 @@ export class PrestodbQuery extends BaseQuery {
155159
// Presto intervals have a YearMonth or DayTime type variants, but no universal type
156160
delete templates.types.interval;
157161
templates.types.binary = 'VARBINARY';
158-
templates.tesseract.support_generated_series_for_custom_td = 'YES';
159162
templates.tesseract.ilike = 'LOWER({{ expr }}) {% if negated %}NOT {% endif %} LIKE {{ pattern }}';
160163
templates.filters.like_pattern = 'CONCAT({% if start_wild %}\'%\'{% else %}\'\'{% endif %}, LOWER({{ value }}), {% if end_wild %}\'%\'{% else %}\'\'{% endif %}) ESCAPE \'\\\'';
161164
templates.statements.time_series_select = 'SELECT from_iso8601_timestamp(dates.f) date_from, from_iso8601_timestamp(dates.t) date_to \n' +

rust/cubesqlplanner/cubesqlplanner/src/cube_bridge/driver_tools.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ pub trait DriverTools {
3131
fn hll_merge(&self, sql: String) -> Result<String, CubeError>;
3232
fn hll_cardinality_merge(&self, sql: String) -> Result<String, CubeError>;
3333
fn count_distinct_approx(&self, sql: String) -> Result<String, CubeError>;
34+
fn support_generated_series_for_custom_td(&self) -> Result<bool, CubeError>;
3435
fn date_bin(
3536
&self,
3637
interval: String,

rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -967,7 +967,7 @@ impl PhysicalPlanBuilder {
967967

968968
let ts_date_range = if self
969969
.plan_sql_templates
970-
.supports_generated_time_series(granularity_obj.is_predefined_granularity())
970+
.supports_generated_time_series(granularity_obj.is_predefined_granularity())?
971971
{
972972
if let Some(date_range) = time_dimension_symbol
973973
.get_range_for_time_series(date_range, self.query_tools.timezone())?

rust/cubesqlplanner/cubesqlplanner/src/plan/time_series.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl TimeSeries {
4040
}
4141

4242
pub fn to_sql(&self, templates: &PlanSqlTemplates) -> Result<String, CubeError> {
43-
if templates.supports_generated_time_series(self.granularity.is_predefined_granularity()) {
43+
if templates.supports_generated_time_series(self.granularity.is_predefined_granularity())? {
4444
let interval_description = templates
4545
.interval_and_minimal_time_unit(self.granularity.granularity_interval().to_sql())?;
4646
if interval_description.len() != 2 {

rust/cubesqlplanner/cubesqlplanner/src/planner/sql_templates/plan.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -426,13 +426,17 @@ impl PlanSqlTemplates {
426426
.contains_template("operators/is_not_distinct_from")
427427
}
428428

429-
pub fn supports_generated_time_series(&self, predifined_granularity: bool) -> bool {
430-
self.render
429+
pub fn supports_generated_time_series(
430+
&self,
431+
predifined_granularity: bool,
432+
) -> Result<bool, CubeError> {
433+
Ok(self
434+
.render
431435
.contains_template("statements/generated_time_series_select")
432436
&& (predifined_granularity
433437
|| self
434-
.render
435-
.contains_template("tesseract/support_generated_series_for_custom_td"))
438+
.driver_tools()
439+
.support_generated_series_for_custom_td()?))
436440
}
437441

438442
pub fn generated_time_series_select(

0 commit comments

Comments
 (0)