flink-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twal...@apache.org
Subject flink git commit: [FLINK-6632] [table] Improved the method BoolLiteral of ExpressionParser for case insensitive.
Date Mon, 22 May 2017 17:00:46 GMT
Repository: flink
Updated Branches:
  refs/heads/master a7bc5de9b -> 9a9e193a1


[FLINK-6632] [table] Improved the method BoolLiteral of ExpressionParser for case insensitive.

This closes #3944.


Project: http://git-wip-us.apache.org/repos/asf/flink/repo
Commit: http://git-wip-us.apache.org/repos/asf/flink/commit/9a9e193a
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/9a9e193a
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/9a9e193a

Branch: refs/heads/master
Commit: 9a9e193a1edf335c89804dc3643fc02681570821
Parents: a7bc5de
Author: sunjincheng121 <sunjincheng121@gmail.com>
Authored: Fri May 19 18:24:09 2017 +0800
Committer: twalthr <twalthr@apache.org>
Committed: Mon May 22 19:00:19 2017 +0200

----------------------------------------------------------------------
 .../table/expressions/ExpressionParser.scala    | 52 +++++++++++++-------
 .../stringexpr/CalcStringExpressionTest.scala   |  4 +-
 .../table/expressions/ScalarOperatorsTest.scala | 19 +++++++
 3 files changed, 56 insertions(+), 19 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/9a9e193a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
index f995a96..e1ffb33 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/expressions/ExpressionParser.scala
@@ -82,6 +82,24 @@ object ExpressionParser extends JavaTokenParsers with PackratParsers {
   lazy val UNBOUNDED_RANGE: Keyword = Keyword("unbounded_range")
   lazy val ROWTIME: Keyword = Keyword("rowtime")
   lazy val PROCTIME: Keyword = Keyword("proctime")
+  lazy val TRUE: Keyword = Keyword("true")
+  lazy val FALSE: Keyword = Keyword("false")
+  lazy val PRIMITIVE_ARRAY: Keyword = Keyword("PRIMITIVE_ARRAY")
+  lazy val OBJECT_ARRAY: Keyword = Keyword("OBJECT_ARRAY")
+  lazy val BYTE: Keyword = Keyword("BYTE")
+  lazy val SHORT: Keyword = Keyword("SHORT")
+  lazy val INTERVAL_MONTHS: Keyword = Keyword("INTERVAL_MONTHS")
+  lazy val INTERVAL_MILLIS: Keyword = Keyword("INTERVAL_MILLIS")
+  lazy val INT: Keyword = Keyword("INT")
+  lazy val LONG: Keyword = Keyword("LONG")
+  lazy val FLOAT: Keyword = Keyword("FLOAT")
+  lazy val DOUBLE: Keyword = Keyword("DOUBLE")
+  lazy val BOOLEAN: Keyword = Keyword("BOOLEAN")
+  lazy val STRING: Keyword = Keyword("STRING")
+  lazy val SQL_DATE: Keyword = Keyword("SQL_DATE")
+  lazy val SQL_TIMESTAMP: Keyword = Keyword("SQL_TIMESTAMP")
+  lazy val SQL_TIME: Keyword = Keyword("SQL_TIME")
+  lazy val DECIMAL: Keyword = Keyword("DECIMAL")
 
   def functionIdent: ExpressionParser.Parser[String] = super.ident
 
@@ -121,22 +139,22 @@ object ExpressionParser extends JavaTokenParsers with PackratParsers
{
   // data types
 
   lazy val dataType: PackratParser[TypeInformation[_]] =
-    "PRIMITIVE_ARRAY" ~ "(" ~> dataType <~ ")" ^^ { ct => Types.PRIMITIVE_ARRAY(ct)
} |
-    "OBJECT_ARRAY" ~ "(" ~> dataType <~ ")" ^^ { ct => Types.OBJECT_ARRAY(ct) }
|
-    "BYTE" ^^ { e => Types.BYTE } |
-    "SHORT" ^^ { e => Types.SHORT } |
-    "INTERVAL_MONTHS" ^^ { e => Types.INTERVAL_MONTHS } |
-    "INTERVAL_MILLIS" ^^ { e => Types.INTERVAL_MILLIS } |
-    "INT" ^^ { e => Types.INT } |
-    "LONG" ^^ { e => Types.LONG } |
-    "FLOAT" ^^ { e => Types.FLOAT } |
-    "DOUBLE" ^^ { e => Types.DOUBLE } |
-    "BOOLEAN" ^^ { { e => Types.BOOLEAN } } |
-    "STRING" ^^ { e => Types.STRING } |
-    "SQL_DATE" ^^ { e => Types.SQL_DATE } |
-    "SQL_TIMESTAMP" ^^ { e => Types.SQL_TIMESTAMP } |
-    "SQL_TIME" ^^ { e => Types.SQL_TIME } |
-    "DECIMAL" ^^ { e => Types.DECIMAL }
+    PRIMITIVE_ARRAY ~ "(" ~> dataType <~ ")" ^^ { ct => Types.PRIMITIVE_ARRAY(ct)
} |
+    OBJECT_ARRAY ~ "(" ~> dataType <~ ")" ^^ { ct => Types.OBJECT_ARRAY(ct) } |
+    BYTE ^^ { e => Types.BYTE } |
+    SHORT ^^ { e => Types.SHORT } |
+    INTERVAL_MONTHS ^^ { e => Types.INTERVAL_MONTHS } |
+    INTERVAL_MILLIS ^^ { e => Types.INTERVAL_MILLIS } |
+    INT ^^ { e => Types.INT } |
+    LONG ^^ { e => Types.LONG } |
+    FLOAT ^^ { e => Types.FLOAT } |
+    DOUBLE ^^ { e => Types.DOUBLE } |
+    BOOLEAN ^^ { { e => Types.BOOLEAN } } |
+    STRING ^^ { e => Types.STRING } |
+    SQL_DATE ^^ { e => Types.SQL_DATE } |
+    SQL_TIMESTAMP ^^ { e => Types.SQL_TIMESTAMP } |
+    SQL_TIME ^^ { e => Types.SQL_TIME } |
+    DECIMAL ^^ { e => Types.DECIMAL }
 
   // literals
 
@@ -167,7 +185,7 @@ object ExpressionParser extends JavaTokenParsers with PackratParsers {
     str => Literal(str.substring(1, str.length - 1))
   }
 
-  lazy val boolLiteral: PackratParser[Expression] = ("true" | "false") ^^ {
+  lazy val boolLiteral: PackratParser[Expression] = (TRUE | FALSE) ^^ {
     str => Literal(str.toBoolean)
   }
 

http://git-wip-us.apache.org/repos/asf/flink/blob/9a9e193a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/table/stringexpr/CalcStringExpressionTest.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/table/stringexpr/CalcStringExpressionTest.scala
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/table/stringexpr/CalcStringExpressionTest.scala
index 819d6d4..381b8c8 100644
--- a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/table/stringexpr/CalcStringExpressionTest.scala
+++ b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/api/scala/batch/table/stringexpr/CalcStringExpressionTest.scala
@@ -112,7 +112,7 @@ class CalcStringExpressionTest {
     val ds = CollectionDataSets.get3TupleDataSet(env).toTable(tEnv, 'a, 'b, 'c)
 
     val t1 = ds.filter( Literal(false) )
-    val t2 = ds.filter("false")
+    val t2 = ds.filter("faLsE")
 
     val lPlan1 = t1.logicalPlan
     val lPlan2 = t2.logicalPlan
@@ -128,7 +128,7 @@ class CalcStringExpressionTest {
     val ds = CollectionDataSets.get3TupleDataSet(env).toTable(tEnv, 'a, 'b, 'c)
 
     val t1 = ds.filter( Literal(true) )
-    val t2 = ds.filter("true")
+    val t2 = ds.filter("trUe")
 
     val lPlan1 = t1.logicalPlan
     val lPlan2 = t2.logicalPlan

http://git-wip-us.apache.org/repos/asf/flink/blob/9a9e193a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala
index 1a65806..0639835 100644
--- a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala
+++ b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/ScalarOperatorsTest.scala
@@ -138,6 +138,25 @@ class ScalarOperatorsTest extends ExpressionTestBase {
 
   @Test
   def testOtherExpressions(): Unit = {
+    // boolean literals
+    testAllApis(
+      true,
+      "true",
+      "true",
+      "true")
+
+    testAllApis(
+      false,
+      "False",
+      "fAlse",
+      "false")
+
+    testAllApis(
+      true,
+      "TrUe",
+      "tRuE",
+      "true")
+
     // null
     testAllApis(Null(Types.INT), "Null(INT)", "CAST(NULL AS INT)", "null")
     testAllApis(


Mime
View raw message