Skip to content

Commit

Permalink
Following [CALCITE-1794], update DruidDateTimeUtils and plans in Drui…
Browse files Browse the repository at this point in the history
…d adapter
  • Loading branch information
NobiGo committed Mar 3, 2022
1 parent 6febf78 commit 6a3eea2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,10 @@ private static Long toLong(Comparable comparable) {
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());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1338,7 +1338,7 @@ private void checkGroupBySingleSortLimit(boolean approx) {
+ "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));
}
Expand Down Expand Up @@ -3026,9 +3026,9 @@ private void testCountWithApproxDistinct(boolean approx, String sql,
+ "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)
Expand Down
10 changes: 5 additions & 5 deletions druid/src/test/java/org/apache/calcite/test/DruidAdapterIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -1633,8 +1633,8 @@ private void checkGroupBySingleSortLimit(boolean approx) {
.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));
}
Expand Down Expand Up @@ -3673,9 +3673,9 @@ private void testCountWithApproxDistinct(boolean approx, String sql, String expe
+ "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)
Expand Down

0 comments on commit 6a3eea2

Please sign in to comment.