mihaibudiu commented on code in PR #4302:
URL: https://github.com/apache/calcite/pull/4302#discussion_r2041173493
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -5355,6 +5355,61 @@ private void checkLiteral2(String expression, String
expected) {
.withMysql().ok(expectedMysql);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6949">[CALCITE-6949]
+ * ClickHouse not support floor date to
SECOND/MILLISECOND/MICROSECOND/NANOSECOND</a>. */
+ @Test void testFloorClickHouse() {
+ String query = "SELECT floor(\"hire_date\" TO YEAR) FROM \"employee\"";
+ String expectedClickHouse = "SELECT toStartOfYear(`hire_date`)\n"
+ + "FROM `foodmart`.`employee`";
+ sql(query).withClickHouse().ok(expectedClickHouse);
+
+ String query1 = "SELECT floor(\"hire_date\" TO MONTH) FROM \"employee\"";
+ String expectedClickHouse1 = "SELECT toStartOfMonth(`hire_date`)\n"
+ + "FROM `foodmart`.`employee`";
+ sql(query1).withClickHouse().ok(expectedClickHouse1);
+
+ String query2 = "SELECT floor(\"hire_date\" TO WEEK) FROM \"employee\"";
+ String expectedClickHouse2 = "SELECT toMonday(`hire_date`)\n"
Review Comment:
In some places weeks are considered to start on Sunday, so the meaning of
the `FLOOR(... WEEK)` function may vary depending on the source dialect or even
the locale. But I don't know how this can be fixed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]