xuzifu666 commented on code in PR #4261:
URL: https://github.com/apache/calcite/pull/4261#discussion_r2011435918
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -1364,6 +1364,47 @@ private static String toSql(RelNode root, SqlDialect
dialect,
sql(query).ok(expected);
}
+ /**
+ * Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6909">[CALCITE-6909]
+ * Support ClickHouse Dailect with Decimal type</a>.
+ */
+ @Test void testClickHouseCastDecimalPrecision() {
+ final String query = "select cast(\"product_id\" as decimal(8,2)) "
+ + "from \"product\" ";
+ final String query1 = "select cast(\"product_id\" as decimal(12,2)) "
+ + "from \"product\" ";
+ final String query2 = "select cast(\"product_id\" as decimal(22,2)) "
+ + "from \"product\" ";
+ final String query3 = "select cast(\"product_id\" as decimal(42,2)) "
+ + "from \"product\" ";
+
+ final String expectedClickHouse = "SELECT CAST(`product_id` AS
`Decimal32(2)`)\n"
Review Comment:
@NobiGo In my test this syntax is OK:
select cast(1.32, 'DECIMAL256(2)') from system.numbers limit 1;
1.32
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -1364,6 +1364,47 @@ private static String toSql(RelNode root, SqlDialect
dialect,
sql(query).ok(expected);
}
+ /**
+ * Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6909">[CALCITE-6909]
+ * Support ClickHouse Dailect with Decimal type</a>.
+ */
+ @Test void testClickHouseCastDecimalPrecision() {
+ final String query = "select cast(\"product_id\" as decimal(8,2)) "
+ + "from \"product\" ";
+ final String query1 = "select cast(\"product_id\" as decimal(12,2)) "
+ + "from \"product\" ";
+ final String query2 = "select cast(\"product_id\" as decimal(22,2)) "
+ + "from \"product\" ";
+ final String query3 = "select cast(\"product_id\" as decimal(42,2)) "
+ + "from \"product\" ";
+
+ final String expectedClickHouse = "SELECT CAST(`product_id` AS
`Decimal32(2)`)\n"
Review Comment:
Thanks for the case, from the case the ClickHouse Dialect cast system
contains a bugļ¼cast(a as type) should change to cast(a, type), WDYT? @NobiGo
--
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]