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

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

                Author: ASF GitHub Bot
            Created on: 05/Oct/18 16:39
            Start Date: 05/Oct/18 16:39
    Worklog Time Spent: 10m 
      Work Description: akedin commented on a change in pull request #6580: 
[BEAM-5202] register UDF/UDAF with ServiceLoader
URL: https://github.com/apache/beam/pull/6580#discussion_r223068890
 
 

 ##########
 File path: 
sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/UdfUdafRegister.java
 ##########
 @@ -0,0 +1,38 @@
+/*
+ * 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;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.beam.sdk.transforms.Combine;
+import org.apache.beam.sdk.transforms.SerializableFunction;
+
+/** Register for UDF and UDAF. */
+public interface UdfUdafRegister {
+  default Map<String, Class<? extends BeamSqlUdf>> getEvalUdfs() {
 
 Review comment:
   By reading this it's unclear what are `eval` udfs vs `serialize` udfs, add 
comments. And I would probably just call these methods `getBeamSqlUdfs()` and 
`getSerializableFunctionUdfs()` to avoid inventing another name for these 
things.
   
   Another approach that I can think of (don't know if it's better or not) to 
make it a bit more extensible is to use `TypeDescriptor`-style type 
specification:
   
   ```
   udfs = ImmutableMap.builder()
      .put(BeamSqlUdf.class, new HashMap<String, BeamSqlUdf>())
      .put(SerializableFunction.class, new HashMap<String, 
SerializableFunction<?, ?>>)
      .build();
   
   public <T> Map<String, T> getUdf(TypeDescriptor<T> udfTypeDescriptor) {
      udfType = // get udf class from udfTypeDescriptor
      return udfs.get(udfType);
   }
   
   ```
   
   I imagine the usage will be like: `register.getUdfs(new 
TypeDescriptor<BeamSqlUdf>> {})`.
   
   And I wonder wether it will be useful to have methods like 
`register.getUdf(String name, TypeDescriptor udfType);`

----------------------------------------------------------------
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: 151679)
    Time Spent: 1.5h  (was: 1h 20m)

> register UDF/UDAF with ServiceLoader
> ------------------------------------
>
>                 Key: BEAM-5202
>                 URL: https://issues.apache.org/jira/browse/BEAM-5202
>             Project: Beam
>          Issue Type: Improvement
>          Components: dsl-sql
>            Reporter: Xu Mingmin
>            Assignee: Xu Mingmin
>            Priority: Major
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> create a ServiceLoader for UDF/UDAF register, if the autoLoad option is set 
> to TRUE.



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

Reply via email to