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:41:03 GMT
Repository: flink
Updated Branches:
  refs/heads/release-1.3 0f4f2bd45 -> ef63f4adb


[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/ef63f4ad
Tree: http://git-wip-us.apache.org/repos/asf/flink/tree/ef63f4ad
Diff: http://git-wip-us.apache.org/repos/asf/flink/diff/ef63f4ad

Branch: refs/heads/release-1.3
Commit: ef63f4adb37b78d00b4f3c82bc75f57c8cca2570
Parents: 0f4f2bd
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:35:01 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/ef63f4ad/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 67a91aa..f31b20c 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
@@ -27,6 +27,7 @@ import org.apache.calcite.rex._
 import org.apache.calcite.sql.SqlOperator
 import org.apache.calcite.sql.`type`.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.io.GenericInputFormat
 import org.apache.flink.api.common.typeinfo._
@@ -1284,7 +1285,8 @@ 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/ef63f4ad/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 f0432cf..56cdf3c 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