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-7441] [table] Double quote string literals is not supported in Table API and SQL
Date Mon, 14 Aug 2017 14:34:06 GMT
Repository: flink
Updated Branches:
  refs/heads/master 3c84f8b9b -> 98c06addb


[FLINK-7441] [table] Double quote string literals is not supported in Table API and SQL

This closes #4538.


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

Branch: refs/heads/master
Commit: 98c06addbb3246eb475296c0fb64eee3ef3f442c
Parents: 3c84f8b
Author: Jark Wu <jark@apache.org>
Authored: Mon Aug 14 16:44:16 2017 +0800
Committer: twalthr <twalthr@apache.org>
Committed: Mon Aug 14 16:33:31 2017 +0200

----------------------------------------------------------------------
 .../org/apache/flink/table/codegen/CodeGenerator.scala    |  4 +++-
 .../table/expressions/UserDefinedScalarFunctionTest.scala | 10 ++++++++++
 2 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flink/blob/98c06add/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
index 63fd058..28fea59 100644
--- a/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
+++ b/flink-libraries/flink-table/src/main/scala/org/apache/flink/table/codegen/CodeGenerator.scala
@@ -26,6 +26,7 @@ import org.apache.calcite.sql.SqlOperator
 import org.apache.calcite.sql.`type`.SqlTypeName._
 import org.apache.calcite.sql.`type`.{ReturnTypes, SqlTypeName}
 import org.apache.calcite.sql.fun.SqlStdOperatorTable._
+import org.apache.commons.lang3.StringEscapeUtils
 import org.apache.flink.api.common.functions._
 import org.apache.flink.api.common.typeinfo._
 import org.apache.flink.api.common.typeutils.CompositeType
@@ -669,7 +670,8 @@ abstract class CodeGenerator(
         generateNonNullLiteral(resultType, decimalField)
 
       case VARCHAR | CHAR =>
-        generateNonNullLiteral(resultType, "\"" + value.toString + "\"")
+        val escapedValue = StringEscapeUtils.ESCAPE_JAVA.translate(value.toString)
+        generateNonNullLiteral(resultType, "\"" + escapedValue + "\"")
 
       case SYMBOL =>
         generateSymbol(value.asInstanceOf[Enum[_]])

http://git-wip-us.apache.org/repos/asf/flink/blob/98c06add/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
----------------------------------------------------------------------
diff --git a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
index 9b3407e..71ff70d 100644
--- a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
+++ b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/UserDefinedScalarFunctionTest.scala
@@ -119,6 +119,16 @@ class UserDefinedScalarFunctionTest extends ExpressionTestBase {
   }
 
   @Test
+  def testDoubleQuoteParameters(): Unit = {
+    val hello = "\"<hello>\""
+    testAllApis(
+      Func3(42, hello),
+      s"Func3(42, '$hello')",
+      s"Func3(42, '$hello')",
+      s"42 and $hello")
+  }
+
+  @Test
   def testResults(): Unit = {
     testAllApis(
       Func4(),


Mime
View raw message