This is an automated email from the ASF dual-hosted git repository. xiong pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/calcite.git
The following commit(s) were added to refs/heads/master by this push: new 6a3eea2 Following [CALCITE-1794], update DruidDateTimeUtils and plans in Druid adapter 6a3eea2 is described below commit 6a3eea213732028e424f01b01f6f93d064348d41 Author: NobiGo <nobigo...@gmail.com> AuthorDate: Thu Mar 3 14:02:16 2022 +0800 Following [CALCITE-1794], update DruidDateTimeUtils and plans in Druid adapter --- .../org/apache/calcite/adapter/druid/DruidDateTimeUtils.java | 4 ++++ .../src/test/java/org/apache/calcite/test/DruidAdapter2IT.java | 8 ++++---- .../src/test/java/org/apache/calcite/test/DruidAdapterIT.java | 10 +++++----- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidDateTimeUtils.java b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidDateTimeUtils.java index 90b48a5..2586491 100644 --- a/druid/src/main/java/org/apache/calcite/adapter/druid/DruidDateTimeUtils.java +++ b/druid/src/main/java/org/apache/calcite/adapter/druid/DruidDateTimeUtils.java @@ -260,6 +260,10 @@ public class DruidDateTimeUtils { TimestampString timestampString = (TimestampString) comparable; return timestampString.getMillisSinceEpoch(); } + if (comparable instanceof DateString) { + DateString dataString = (DateString) comparable; + return dataString.getMillisSinceEpoch(); + } throw new AssertionError("unsupported type: " + comparable.getClass()); } diff --git a/druid/src/test/java/org/apache/calcite/test/DruidAdapter2IT.java b/druid/src/test/java/org/apache/calcite/test/DruidAdapter2IT.java index 0187662..0f5eec2 100644 --- a/druid/src/test/java/org/apache/calcite/test/DruidAdapter2IT.java +++ b/druid/src/test/java/org/apache/calcite/test/DruidAdapter2IT.java @@ -1338,7 +1338,7 @@ public class DruidAdapter2IT { + "1998-01-01T00:00:00.000Z'],'context':{'skipEmptyBuckets':false}}"; sql(sql) .explainContains("PLAN=EnumerableInterpreter\n" - + " DruidQuery(table=[[foodmart, foodmart]], intervals=[[1997-01-01T00:00:00.000Z/1998-01-01T00:00:00.000Z]], filter=[AND(>=(CAST($11):INTEGER, 8), <=(CAST($11):INTEGER, 10), <(CAST($10):INTEGER, 15))], projects=[[$90]], groups=[{}], aggs=[[SUM($0)]])") + + " DruidQuery(table=[[foodmart, foodmart]], intervals=[[1997-01-01T00:00:00.000Z/1998-01-01T00:00:00.000Z]], filter=[AND(SEARCH(CAST($11):INTEGER, Sarg[[8..10]]), <(CAST($10):INTEGER, 15))], projects=[[$90]], groups=[{}], aggs=[[SUM($0)]])") .returnsUnordered("EXPR$0=75364.1") .queryContains(new DruidChecker(druidQuery)); } @@ -3026,9 +3026,9 @@ public class DruidAdapter2IT { + "CAST(FLOOR(CAST(\"timestamp\" AS DATE) to MONTH) AS DATE) = " + " CAST('1997-01-01' as DATE) GROUP BY floor(\"timestamp\" to DAY) order by d limit 3"; final String plan = "PLAN=EnumerableInterpreter\n" - + " DruidQuery(table=[[foodmart, foodmart]], intervals=[[1900-01-09T00:00:00.000Z/" - + "2992-01-10T00:00:00.000Z]], filter=[=(FLOOR(CAST($0):DATE NOT NULL, FLAG(MONTH)), " - + "1997-01-01)], projects=[[FLOOR($0, FLAG(DAY))]], groups=[{0}], aggs=[[]], sort0=[0], " + + " DruidQuery(table=[[foodmart, foodmart]], " + + "intervals=[[1997-01-01T00:00:00.000Z/1997-02-01T00:00:00.000Z]], " + + "projects=[[FLOOR($0, FLAG(DAY))]], groups=[{0}], aggs=[[]], sort0=[0], " + "dir0=[ASC], fetch=[3])"; sql(sql) .explainContains(plan) diff --git a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java index 4c0bb9b..6aab15f 100644 --- a/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java +++ b/druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java @@ -1633,8 +1633,8 @@ public class DruidAdapterIT { .explainContains("PLAN=EnumerableInterpreter\n" + " DruidQuery(table=[[foodmart, foodmart]], " + "intervals=[[1997-01-01T00:00:00.000Z/1998-01-01T00:00:00.000Z]], " - + "filter=[AND(>=(CAST($11):INTEGER, 8), <=(CAST($11):INTEGER, 10), " - + "<(CAST($10):INTEGER, 15))], projects=[[$90]], groups=[{}], aggs=[[SUM($0)]])\n") + + "filter=[AND(SEARCH(CAST($11):INTEGER, Sarg[[8..10]]), <(CAST($10):INTEGER, 15))], " + + "projects=[[$90]], groups=[{}], aggs=[[SUM($0)]])\n") .returnsUnordered("EXPR$0=75364.1") .queryContains(new DruidChecker(druidQuery)); } @@ -3673,9 +3673,9 @@ public class DruidAdapterIT { + "CAST(FLOOR(CAST(\"timestamp\" AS DATE) to MONTH) AS DATE) = " + " CAST('1997-01-01' as DATE) GROUP BY floor(\"timestamp\" to DAY) order by d limit 3"; final String plan = "PLAN=EnumerableInterpreter\n" - + " DruidQuery(table=[[foodmart, foodmart]], intervals=[[1900-01-09T00:00:00.000Z/" - + "2992-01-10T00:00:00.000Z]], filter=[=(FLOOR(CAST($0):DATE NOT NULL, FLAG(MONTH)), " - + "1997-01-01)], projects=[[FLOOR($0, FLAG(DAY))]], groups=[{0}], aggs=[[]], " + + " DruidQuery(table=[[foodmart, foodmart]], " + + "intervals=[[1997-01-01T00:00:00.000Z/1997-02-01T00:00:00.000Z]], " + + "projects=[[FLOOR($0, FLAG(DAY))]], groups=[{0}], aggs=[[]], " + "post_projects=[[CAST($0):TIMESTAMP(0) NOT NULL]], sort0=[0], dir0=[ASC], fetch=[3])"; sql(sql, FOODMART) .explainContains(plan)