xuzifu666 commented on code in PR #4287:
URL: https://github.com/apache/calcite/pull/4287#discussion_r2032858600
##########
core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java:
##########
@@ -9474,6 +9474,55 @@ private void checkLiteral2(String expression, String
expected) {
sql(sql).ok(expected);
}
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealTypesCast() {
+ String query = "SELECT CAST(\"department_id\" AS float), "
+ + "CAST(\"department_id\" AS double), "
+ + "CAST(\"department_id\" AS real) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(\"department_id\" AS FLOAT), "
+ + "CAST(\"department_id\" AS DOUBLE), "
+ + "CAST(\"department_id\" AS FLOAT)\nFROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(`department_id` AS FLOAT), "
+ + "CAST(`department_id` AS DOUBLE), "
+ + "CAST(`department_id` AS FLOAT)\nFROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealArrayTypesCast() {
+ String query = "SELECT CAST(array[1,2,3] AS real array) FROM \"employee\"";
+ String expectedPhoenix = "SELECT CAST(ARRAY[1, 2, 3] AS FLOAT ARRAY)\n"
+ + "FROM \"foodmart\".\"employee\"";
+ String expectedHive = "SELECT CAST(ARRAY (1, 2, 3) AS FLOAT ARRAY)\n"
+ + "FROM `foodmart`.`employee`";
+
+ sql(query)
+ .withPhoenix().ok(expectedPhoenix)
+ .withHive().ok(expectedHive);
+ }
+
+ /** Test case for
+ * <a
href="https://issues.apache.org/jira/browse/CALCITE-6940">[CALCITE-6940]
+ * Hive/Phoenix Dialect should not cast to REAL type directly</a>. */
+ @Test void testRealMapTypesCast() {
+ String query = "SELECT CAST(MAP[1.0,2.0,3.0,4.0] AS MAP<FLOAT, REAL>) FROM
\"employee\"";
+ String expectedHive = "SELECT CAST(MAP (1.0, 2.0, 3.0, 4.0) AS MAP< FLOAT,
FLOAT >)\n"
Review Comment:
This spark is ok, but hive and phoenix not support.
--
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]