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

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

                Author: ASF GitHub Bot
            Created on: 20/Nov/18 22:46
            Start Date: 20/Nov/18 22:46
    Worklog Time Spent: 10m 
      Work Description: akedin closed pull request #7096: [BEAM-5852][SQL] 
Disallow checked exceptions in UDF
URL: https://github.com/apache/beam/pull/7096
 
 
   

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/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java
 
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java
index 10375c444cfa..015349521c9e 100644
--- 
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java
+++ 
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/UdfImpl.java
@@ -96,6 +96,9 @@ public static ScalarFunction create(Method method) {
         throw RESOURCE.requireDefaultConstructor(clazz.getName()).ex();
       }
     }
+    if (method.getExceptionTypes().length != 0) {
+      throw new RuntimeException(method.getName() + " must not throw checked 
exception");
+    }
     CallImplementor implementor = createImplementor(method);
     return new UdfImpl(method, implementor);
   }
diff --git 
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/udf/BuiltinStringFunctions.java
 
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/udf/BuiltinStringFunctions.java
index ce27a02bc53c..898af51caa91 100644
--- 
a/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/udf/BuiltinStringFunctions.java
+++ 
b/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/impl/udf/BuiltinStringFunctions.java
@@ -110,12 +110,16 @@ public String reverse(String str) {
     parameterArray = {TypeName.STRING},
     returnType = TypeName.BYTES
   )
-  public byte[] fromHex(String str) throws DecoderException {
+  public byte[] fromHex(String str) {
     if (str == null) {
       return null;
     }
 
-    return Hex.decodeHex(str.toCharArray());
+    try {
+      return Hex.decodeHex(str.toCharArray());
+    } catch (DecoderException e) {
+      throw new RuntimeException(e);
+    }
   }
 
   @UDF(
@@ -123,7 +127,7 @@ public String reverse(String str) {
     parameterArray = {TypeName.BYTES},
     returnType = TypeName.STRING
   )
-  public String toHex(byte[] bytes) throws DecoderException {
+  public String toHex(byte[] bytes) {
     if (bytes == null) {
       return null;
     }


 

----------------------------------------------------------------
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: 168015)
    Time Spent: 6h 20m  (was: 6h 10m)

> 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 20m
>  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