[ 
https://issues.apache.org/jira/browse/BEAM-5852?focusedWorklogId=168024&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-168024
 ]

ASF GitHub Bot logged work on BEAM-5852:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 20/Nov/18 23:01
            Start Date: 20/Nov/18 23:01
    Worklog Time Spent: 10m 
      Work Description: amaliujia commented on a change in pull request #6928: 
[BEAM-5852] BeamSQL functions
URL: https://github.com/apache/beam/pull/6928#discussion_r235201178
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/udf/BuiltinStringFunctions.java
 ##########
 @@ -0,0 +1,302 @@
+/*
+ * 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.beam.sdk.extensions.sql.impl.udf;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import com.google.auto.service.AutoService;
+import java.util.Arrays;
+import org.apache.beam.sdk.schemas.Schema.TypeName;
+import org.apache.commons.codec.DecoderException;
+import org.apache.commons.codec.binary.Hex;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+
+/** BuiltinStringFunctions. */
+@AutoService(BeamBuiltinFunctionProvider.class)
+public class BuiltinStringFunctions extends BeamBuiltinFunctionProvider {
+
+  // return a explicitly null for Boolean has NP_BOOLEAN_RETURN_NULL warning.
+  // return null for boolean is not allowed.
+  // TODO: handle null input.
+  @UDF(
+    funcName = "ENDS_WITH",
+    parameterArray = {TypeName.STRING},
+    returnType = TypeName.STRING
+  )
+  public Boolean endsWith(String str1, String str2) {
+    return str1.endsWith(str2);
+  }
+
+  // return a explicitly null for Boolean has NP_BOOLEAN_RETURN_NULL warning.
+  // return null for boolean is not allowed.
+  // TODO: handle null input.
+  @UDF(
+    funcName = "STARTS_WITH",
+    parameterArray = {TypeName.STRING},
+    returnType = TypeName.STRING
+  )
+  public Boolean startsWith(String str1, String str2) {
+    return str1.startsWith(str2);
+  }
+
+  @UDF(
+    funcName = "LENGTH",
 
 Review comment:
   You can go ahead to use code generation. For any function that we might want 
them behave differently, we can implement those and let planner decides which 
set of functions to use.

----------------------------------------------------------------
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:
[email protected]


Issue Time Tracking
-------------------

    Worklog Id:     (was: 168024)
    Time Spent: 6h 50m  (was: 6h 40m)

> Function extension in BeamSQL
> -----------------------------
>
>                 Key: BEAM-5852
>                 URL: https://issues.apache.org/jira/browse/BEAM-5852
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>          Time Spent: 6h 50m
>  Remaining Estimate: 0h
>
> We could add more functions to BeamSQL (as UDFs) to provide rich 
> functionalities than standard/Calcite functions.



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

Reply via email to