Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 3F3F120049B for ; Mon, 14 Aug 2017 16:41:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 3C026165441; Mon, 14 Aug 2017 14:41:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 817FE16543F for ; Mon, 14 Aug 2017 16:41:06 +0200 (CEST) Received: (qmail 93332 invoked by uid 500); 14 Aug 2017 14:41:03 -0000 Mailing-List: contact commits-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list commits@flink.apache.org Received: (qmail 93323 invoked by uid 99); 14 Aug 2017 14:41:03 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 14 Aug 2017 14:41:03 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id A5756DFC28; Mon, 14 Aug 2017 14:41:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: twalthr@apache.org To: commits@flink.apache.org Message-Id: <2fa6917f39164802ad57209dc7a8292a@git.apache.org> X-Mailer: ASF-Git Admin Mailer 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 +0000 (UTC) archived-at: Mon, 14 Aug 2017 14:41:07 -0000 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 Authored: Mon Aug 14 16:44:16 2017 +0800 Committer: twalthr 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 = "\"\"" + testAllApis( + Func3(42, hello), + s"Func3(42, '$hello')", + s"Func3(42, '$hello')", + s"42 and $hello") + } + + @Test def testResults(): Unit = { testAllApis( Func4(),