[ 
https://issues.apache.org/jira/browse/FLINK-10222?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16616907#comment-16616907
 ] 

ASF GitHub Bot commented on FLINK-10222:
----------------------------------------

asfgit closed pull request #6622: [FLINK-10222] [table] Table scalar function 
expression parses error when function name equals the exists keyword suffix
URL: https://github.com/apache/flink/pull/6622
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

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 4909d2c79da..a8f73a21bdf 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
@@ -42,7 +42,8 @@ object ExpressionParser extends JavaTokenParsers with 
PackratParsers {
 
   // Convert the keyword into an case insensitive Parser
   implicit def keyword2Parser(kw: Keyword): Parser[String] = {
-    ("""(?i)\Q""" + kw.key + """\E""").r
+    ("""(?i)\Q""" + kw.key +
+      
"""\E(?![_$a-zA-Z0-9\u005f\u0024\u0061-\u007a\u0041-\u005a\u0030-\u0039])""").r
   }
 
   // Keyword
diff --git 
a/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/KeywordParseTest.scala
 
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/KeywordParseTest.scala
new file mode 100644
index 00000000000..05c464a37ea
--- /dev/null
+++ 
b/flink-libraries/flink-table/src/test/scala/org/apache/flink/table/expressions/KeywordParseTest.scala
@@ -0,0 +1,75 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.table.expressions
+
+import org.apache.flink.api.common.typeinfo.TypeInformation
+import org.apache.flink.api.java.typeutils.RowTypeInfo
+import org.apache.flink.table.expressions.utils.ExpressionTestBase
+import org.apache.flink.types.Row
+import org.junit.{Assert, Test}
+
+/**
+  * Tests keyword as suffix.
+  */
+class KeywordParseTest extends ExpressionTestBase {
+
+  @Test
+  def testFunctionNameContainsSuffixKeyword(): Unit = {
+    // ASC / DESC (no parameter)
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.ascii()")).asInstanceOf[Call]).functionName,
+      "ASCII")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.iiascii()")).asInstanceOf[Call]).functionName,
+      "IIASCII")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.iiasc()")).asInstanceOf[Call]).functionName,
+      "IIASC")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.descabc()")).asInstanceOf[Call]).functionName,
+      "DESCABC")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.abcdescabc()")).asInstanceOf[Call]).functionName,
+      "ABCDESCABC")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.abcdesc()")).asInstanceOf[Call]).functionName,
+      "ABCDESC")
+    // LOG has parameter
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.logabc()")).asInstanceOf[Call]).functionName,
+      "LOGABC")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.abclogabc()")).asInstanceOf[Call]).functionName,
+      "ABCLOGABC")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.abclog()")).asInstanceOf[Call]).functionName,
+      "ABCLOG")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.log2()")).asInstanceOf[Call]).functionName,
+      "LOG2")
+    Assert.assertEquals(
+      
((ExpressionParser.parseExpression("f0.log10()")).asInstanceOf[Call]).functionName,
+      "LOG10")
+  }
+
+  override def testData: Any = new Row(0)
+
+  override def typeInfo: TypeInformation[Any] =
+    new RowTypeInfo().asInstanceOf[TypeInformation[Any]]
+}


 

----------------------------------------------------------------
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:
us...@infra.apache.org


> Table scalar function expression parses error when function name equals the 
> exists keyword suffix
> -------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-10222
>                 URL: https://issues.apache.org/jira/browse/FLINK-10222
>             Project: Flink
>          Issue Type: Bug
>          Components: Table API & SQL
>            Reporter: vinoyang
>            Priority: Major
>              Labels: pull-request-available
>
> Suffix extraction in ExpressionParser.scala does not actually support 
> extraction of keywords with the same prefix. For example: Adding suffix 
> parsing rules for {{a.fun}} and {{a.function}} simultaneously will causes 
> exceptions. 
> some discussion : 
> [https://github.com/apache/flink/pull/6432#issuecomment-416127815]
> https://github.com/apache/flink/pull/6585#discussion_r212797015



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to