From 5cf1e2c1ca1f70ef84e8f0a8d96d4563b18230ff Mon Sep 17 00:00:00 2001 From: Zoltan Haindrich Date: Wed, 4 Oct 2023 10:01:41 +0000 Subject: [PATCH] check for latest rewrite place --- .../builtin/EarliestLatestAnySqlAggregator.java | 9 +++++++++ .../builtin/EarliestLatestBySqlAggregator.java | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java index 5f1b3c3228d..e730f036404 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestAnySqlAggregator.java @@ -340,5 +340,14 @@ public class EarliestLatestAnySqlAggregator implements SqlAggregator Optionality.FORBIDDEN ); } + + public org.apache.calcite.sql.SqlNode rewriteCall(org.apache.calcite.sql.validate.SqlValidator validator, org.apache.calcite.sql.SqlCall call) + { + // I think the best chance would be to to try to rewrite it here + // biggest question is kinda like which is the time column + // look inside SqlCoalesceFunction for a sample how a rewrite is done around here + return call; + } } + } diff --git a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestBySqlAggregator.java b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestBySqlAggregator.java index 95b70e1f1e5..45f4251d6c7 100644 --- a/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestBySqlAggregator.java +++ b/sql/src/main/java/org/apache/druid/sql/calcite/aggregation/builtin/EarliestLatestBySqlAggregator.java @@ -25,12 +25,15 @@ import org.apache.calcite.rex.RexBuilder; import org.apache.calcite.rex.RexLiteral; import org.apache.calcite.rex.RexNode; import org.apache.calcite.sql.SqlAggFunction; +import org.apache.calcite.sql.SqlCall; import org.apache.calcite.sql.SqlFunctionCategory; import org.apache.calcite.sql.SqlKind; +import org.apache.calcite.sql.SqlNode; import org.apache.calcite.sql.type.InferTypes; import org.apache.calcite.sql.type.OperandTypes; import org.apache.calcite.sql.type.SqlReturnTypeInference; import org.apache.calcite.sql.type.SqlTypeFamily; +import org.apache.calcite.sql.validate.SqlValidator; import org.apache.calcite.util.Optionality; import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.ISE; @@ -204,5 +207,10 @@ public class EarliestLatestBySqlAggregator implements SqlAggregator Optionality.FORBIDDEN ); } + @Override + public SqlNode rewriteCall(SqlValidator validator, SqlCall call) + { + return super.rewriteCall(validator, call); + } } }