From bbafbe6aeaaa83fa846ea88cab03ecca6f0ec3fe Mon Sep 17 00:00:00 2001 From: Alexandr Romanenko Date: Thu, 22 May 2025 16:59:13 +0200 Subject: [PATCH] fix(tesseract): Using FULL JOIN for outer aggregate joins in BigQuery --- .../src/adapter/BigqueryQuery.ts | 1 - .../src/physical_plan_builder/builder.rs | 21 ++++++++----------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.ts b/packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.ts index 7dab6e0983afe..f5b9743d3c39c 100644 --- a/packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.ts +++ b/packages/cubejs-schema-compiler/src/adapter/BigqueryQuery.ts @@ -273,7 +273,6 @@ export class BigqueryQuery extends BaseQuery { templates.types.decimal = 'BIGDECIMAL({{ precision }},{{ scale }})'; templates.types.binary = 'BYTES'; templates.expressions.cast_to_string = 'CAST({{ expr }} AS STRING)'; - templates.operators.is_not_distinct_from = 'IS NOT DISTINCT FROM'; templates.join_types.full = 'FULL'; templates.statements.time_series_select = 'SELECT DATETIME(TIMESTAMP(f)) date_from, DATETIME(TIMESTAMP(t)) date_to \n' + 'FROM (\n' + diff --git a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs index 8e368689f19b3..92bfa14d403b4 100644 --- a/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs +++ b/rust/cubesqlplanner/cubesqlplanner/src/physical_plan_builder/builder.rs @@ -53,7 +53,7 @@ impl PhysicalPlanBuilderContext { pub struct PhysicalPlanBuilder { query_tools: Rc, - _plan_sql_templates: PlanSqlTemplates, + plan_sql_templates: PlanSqlTemplates, } impl PhysicalPlanBuilder { @@ -61,7 +61,7 @@ impl PhysicalPlanBuilder { let plan_sql_templates = query_tools.plan_sql_templates(); Self { query_tools, - _plan_sql_templates: plan_sql_templates, + plan_sql_templates, } } @@ -464,17 +464,14 @@ impl PhysicalPlanBuilder { let on = JoinCondition::new_dimension_join(conditions, true); let next_alias = format!("q_{}", i); - join_builder.inner_join_source(join.clone(), next_alias, on); - - /* TODO: Full join fails even in BigQuery, where it’s theoretically supported. Disabled for now — needs investigation. if full_key_aggregate.use_full_join_and_coalesce - && self.plan_sql_templates.supports_full_join() - { - join_builder.full_join_source(join.clone(), next_alias, on); - } else { - // TODO in case of full join is not supported there should be correct blending query that keeps NULL values - join_builder.inner_join_source(join.clone(), next_alias, on); - } */ + && self.plan_sql_templates.supports_full_join() + { + join_builder.full_join_source(join.clone(), next_alias, on); + } else { + // TODO in case of full join is not supported there should be correct blending query that keeps NULL values + join_builder.inner_join_source(join.clone(), next_alias, on); + } } let result = From::new_from_join(join_builder.build());