flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] fhueske commented on a change in pull request #6535: [FLINK-9977] [table][doc] Refine the SQL/Table built-in function docs
Date Mon, 13 Aug 2018 14:42:31 GMT
fhueske commented on a change in pull request #6535: [FLINK-9977] [table][doc] Refine the SQL/Table
built-in function docs
URL: https://github.com/apache/flink/pull/6535#discussion_r209626394
 
 

 ##########
 File path: flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/SqlExpressionTest.scala
 ##########
 @@ -133,11 +136,78 @@ class SqlExpressionTest extends ExpressionTestBase {
     testSqlApi("TRIM(LEADING 'x' FROM 'xxxxSTRINGxxxx')", "STRINGxxxx")
     testSqlApi("TRIM(TRAILING 'x' FROM 'xxxxSTRINGxxxx')", "xxxxSTRING")
     testSqlApi(
-      "OVERLAY('This is a old string' PLACING 'new' FROM 11 FOR 3)",
+      "OVERLAY('This is an old string' PLACING ' new' FROM 10 FOR 5)",
       "This is a new string")
     testSqlApi("SUBSTRING('hello world', 2)", "ello world")
     testSqlApi("SUBSTRING('hello world', 2, 3)", "ell")
-    testSqlApi("INITCAP('hello world')", "Hello World")
+    testSqlApi("INITCAP('hello WORLD')", "Hello World")
+    testSqlApi("CONCAT('a', 'b')", "ab")
+    testSqlApi("CONCAT('a', NULLIF('a', 'a'), 'b')", "null")
+    testSqlApi("CONCAT_WS('~', 'a', NULLIF('a', 'a'), 'b')", "a~b")
+    testSqlApi("LPAD('hi',4,'??')", "??hi")
+    testSqlApi("RPAD('hi',4,'??')", "hi??")
+    testSqlApi("FROM_BASE64('aGVsbG8gd29ybGQ=')", "hello world")
+    testSqlApi("TO_BASE64('hello world')", "aGVsbG8gd29ybGQ=")
+  }
+
+  @Test
+  def testTemporalFunctions(): Unit = {
+    testSqlApi("DATE '1990-10-14'", "1990-10-14")
+    testSqlApi("TIME '12:12:12'", "12:12:12")
+    testSqlApi("TIMESTAMP '1990-10-14 12:12:12.123'", "1990-10-14 12:12:12.123")
+    testSqlApi("INTERVAL '10 00:00:00.004' DAY TO SECOND", "+10 00:00:00.004")
+    testSqlApi("INTERVAL '10 00:12' DAY TO MINUTE", "+10 00:12:00.000")
+    testSqlApi("INTERVAL '2-10' YEAR TO MONTH", "+2-10")
+    testSqlApi("EXTRACT(DAY FROM DATE '1990-12-01')", "1")
+    testSqlApi("EXTRACT(DAY FROM INTERVAL '19 12:10:10.123' DAY TO SECOND(3))", "19")
+    testSqlApi("YEAR(DATE '1994-09-27')", "1994")
+    testSqlApi("QUARTER(DATE '2016-04-12')", "2")
+    testSqlApi("MONTH(DATE '1994-09-27')", "9")
+    testSqlApi("WEEK(DATE '1994-09-27')", "39")
+    testSqlApi("DAYOFYEAR(DATE '1994-09-27')", "270")
+    testSqlApi("DAYOFMONTH(DATE '1994-09-27')", "27")
+    testSqlApi("DAYOFWEEK(DATE '1994-09-27')", "3")
+    testSqlApi("HOUR(TIMESTAMP '1994-09-27 13:14:15')", "13")
+    testSqlApi("MINUTE(TIMESTAMP '1994-09-27 13:14:15')", "14")
+    testSqlApi("SECOND(TIMESTAMP '1994-09-27 13:14:15')", "15")
+    testSqlApi("FLOOR(TIME '12:44:31' TO MINUTE)", "12:44:00")
+    testSqlApi("CEIL(TIME '12:44:31' TO MINUTE)", "12:45:00")
+    testSqlApi(
 
 Review comment:
   Add a test that evaluates to `false`?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message