You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2022/08/15 09:31:09 UTC

[GitHub] [flink] wuchong commented on a diff in pull request #20571: [FLINK-27015][hive] Fix exception for casting timestamp to decimal in Hive dialect

wuchong commented on code in PR #20571:
URL: https://github.com/apache/flink/pull/20571#discussion_r945548796


##########
flink-connectors/flink-connector-hive/src/test/java/org/apache/flink/connectors/hive/HiveDialectQueryITCase.java:
##########
@@ -743,6 +743,31 @@ public void testBoolComparison() {
         }
     }
 
+    @Test
+    public void testCastTimeStampToDecimal() throws Exception {
+        try {
+            // test cast timestamp to decimal explicitly
+            List<Row> results =
+                    CollectionUtil.iteratorToList(
+                            tableEnv.executeSql(
+                                            "select cast(cast('2012-12-19 11:12:19.1234567' as timestamp) as decimal(30,8))")
+                                    .collect());
+            assertThat(results.toString()).isEqualTo("[+I[1355886739.12345670]]");
+
+            // test insert timestamp type to decimal type directly
+            tableEnv.executeSql("create table t1 (c1 DECIMAL(38,6))");
+            tableEnv.executeSql("create table t2 (c2 TIMESTAMP)");
+            tableEnv.executeSql("insert into t2 values('2029-06-05 14:28:29.23445')").await();

Review Comment:
   Shouldn't it be inserting values into `t1` for testing `insert timestamp type to decimal type directly`?



-- 
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: issues-unsubscribe@flink.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org