You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "ChengJie1053 (via GitHub)" <gi...@apache.org> on 2024/01/11 10:27:58 UTC
[PR] Flink supports udf function [linkis]
ChengJie1053 opened a new pull request, #5067:
URL: https://github.com/apache/linkis/pull/5067
Flink supports udf function
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] Flink supports udf function [linkis]
Posted by "peacewong (via GitHub)" <gi...@apache.org>.
peacewong commented on code in PR #5067:
URL: https://github.com/apache/linkis/pull/5067#discussion_r1449709325
##########
linkis-engineconn-plugins/flink/flink-core/src/main/java/org/apache/linkis/engineconnplugin/flink/client/utils/FlinkUdfUtils.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.linkis.engineconnplugin.flink.client.utils;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.PipelineOptions;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.functions.UserDefinedFunction;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlinkUdfUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(FlinkUdfUtils.class);
+
+ private static final String CREATE_TEMP_FUNCTION_PATTERN =
+ "create\\s+temporary\\s+function\\s+(\\w+)\\s+as\\s+\"(.*?)\"";
+
+ private static final String CREATE_TEMP_FUNCTION_SQL =
+ "CREATE TEMPORARY FUNCTION IF NOT EXISTS %s AS '%s' ";
+
+ public static void addFlinkPipelineClasspaths(StreamExecutionEnvironment env, String path) {
+ logger.info("Flink udf start add pipeline classpaths, jar path: {}", path);
+
+ try {
+ Field configuration = StreamExecutionEnvironment.class.getDeclaredField("configuration");
+ configuration.setAccessible(true);
+ Configuration conf = (Configuration) configuration.get(env);
+
+ Field confData = Configuration.class.getDeclaredField("confData");
+ confData.setAccessible(true);
+ Map<String, Object> map = (Map<String, Object>) confData.get(conf);
+ List<String> jarList = new ArrayList<>();
+ jarList.add(path);
+ map.put(PipelineOptions.CLASSPATHS.key(), jarList);
Review Comment:
Is it necessary to consider the situation where the value was originally changed to append list?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] Flink supports udf function [linkis]
Posted by "ChengJie1053 (via GitHub)" <gi...@apache.org>.
ChengJie1053 commented on code in PR #5067:
URL: https://github.com/apache/linkis/pull/5067#discussion_r1450054014
##########
linkis-engineconn-plugins/flink/flink-core/src/main/java/org/apache/linkis/engineconnplugin/flink/client/utils/FlinkUdfUtils.java:
##########
@@ -0,0 +1,116 @@
+/*
+ * 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.linkis.engineconnplugin.flink.client.utils;
+
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.PipelineOptions;
+import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
+import org.apache.flink.table.functions.UserDefinedFunction;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class FlinkUdfUtils {
+
+ private static final Logger logger = LoggerFactory.getLogger(FlinkUdfUtils.class);
+
+ private static final String CREATE_TEMP_FUNCTION_PATTERN =
+ "create\\s+temporary\\s+function\\s+(\\w+)\\s+as\\s+\"(.*?)\"";
+
+ private static final String CREATE_TEMP_FUNCTION_SQL =
+ "CREATE TEMPORARY FUNCTION IF NOT EXISTS %s AS '%s' ";
+
+ public static void addFlinkPipelineClasspaths(StreamExecutionEnvironment env, String path) {
+ logger.info("Flink udf start add pipeline classpaths, jar path: {}", path);
+
+ try {
+ Field configuration = StreamExecutionEnvironment.class.getDeclaredField("configuration");
+ configuration.setAccessible(true);
+ Configuration conf = (Configuration) configuration.get(env);
+
+ Field confData = Configuration.class.getDeclaredField("confData");
+ confData.setAccessible(true);
+ Map<String, Object> map = (Map<String, Object>) confData.get(conf);
+ List<String> jarList = new ArrayList<>();
+ jarList.add(path);
+ map.put(PipelineOptions.CLASSPATHS.key(), jarList);
Review Comment:
Ok, thanks for reviewing the code
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org
Re: [PR] Flink supports udf function [linkis]
Posted by "peacewong (via GitHub)" <gi...@apache.org>.
peacewong merged PR #5067:
URL: https://github.com/apache/linkis/pull/5067
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@linkis.apache.org
For additional commands, e-mail: notifications-help@linkis.apache.org