You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by GitBox <gi...@apache.org> on 2022/04/28 08:03:03 UTC
[GitHub] [incubator-seatunnel] wuzhenhua01 opened a new pull request, #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
wuzhenhua01 opened a new pull request, #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770
Add Uuid transform for spark and fix some error at replace doc https://github.com/apache/incubator-seatunnel/issues/1762
<!--
Thank you for contributing to SeaTunnel! Please make sure that your code changes
are covered with tests. And in case of new features or big changes
remember to adjust the documentation.
Feel free to ping committers for the review!
## Contribution Checklist
- Make sure that the pull request corresponds to a [GITHUB issue](https://github.com/apache/incubator-seatunnel/issues).
- Name the pull request in the form "[Feature] [component] Title of the pull request", where *Feature* can be replaced by `Hotfix`, `Bug`, etc.
- Minor fixes should be named following this pattern: `[hotfix] [docs] Fix typo in README.md doc`.
-->
## Purpose of this pull request
<!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
## Check list
* [x] Code changed are covered with tests, or it does not need tests for reason:
* [x] If any new Jar binary package adding in your PR, please add License Notice according
[New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/contribution/new-license.md)
* [x] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] wuzhenhua01 commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
wuzhenhua01 commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r860834268
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
I'm afraid I don't quite follow your gist. Your meaning we need a list to accept fields ?
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun merged pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun merged PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] wuzhenhua01 commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
wuzhenhua01 commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r860860443
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
Got it, I will refactor later.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r860842038
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
Sorry, I don't make myself clear. It's better to split the magic string from this method. We can add a Object e.g. Config or Constant to store these config key "fields", "prefix".
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r861422726
##########
seatunnel-common/src/main/java/org/apache/seatunnel/common/constants/TransformConfigConstants.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.seatunnel.common.constants;
+
+public final class TransformConfigConstants {
+ /* common transform constant */
+ public static final String FIELDS = "fields";
+ public static final String SOURCE_FILED = "source_field";
+ public static final String DEFAULT_SOURCE_FILED = "raw_message";
+ public static final String TARGET_FILED = "target_field";
+
+ /* json transform constant */
+ public static final String SCHEMA_DIR = "schema_dir";
+ public static final String SCHEMA_FILE = "schema_file";
+ public static final String DEFAULT_SCHEMA_FILE = "";
+
+ /* replace transform constant */
+ public static final String PATTERN = "pattern";
+ public static final String REPLACEMENT = "replacement";
+ public static final String REPLACE_REGEX = "is_regex";
+ public static final boolean DEFAULT_REPLACE_REGEX = false;
+ public static final String REPLACE_FIRST = "replace_first";
+ public static final boolean DEFAULT_REPLACE_FIRST = false;
+
+ /* split transform constant */
+ public static final String SPLIT_SEPARATOR = "separator";
+ public static final String DEFAULT_SPLIT_SEPARATOR = " ";
+
+ /* UUID transform constant */
+ public static final String UUID_PREFIX = "prefix";
+ public static final String DEFAULT_UUID_PREFIX = "";
+ public static final String UUID_SECURE = "secure";
+ public static final boolean DEFAULT_UUID_SECURE = false;
Review Comment:
The constants file need to put into plugin module, you need to create constant file for each plugin. If we put all constant into one file, the file will be very big.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r861422726
##########
seatunnel-common/src/main/java/org/apache/seatunnel/common/constants/TransformConfigConstants.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * 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.seatunnel.common.constants;
+
+public final class TransformConfigConstants {
+ /* common transform constant */
+ public static final String FIELDS = "fields";
+ public static final String SOURCE_FILED = "source_field";
+ public static final String DEFAULT_SOURCE_FILED = "raw_message";
+ public static final String TARGET_FILED = "target_field";
+
+ /* json transform constant */
+ public static final String SCHEMA_DIR = "schema_dir";
+ public static final String SCHEMA_FILE = "schema_file";
+ public static final String DEFAULT_SCHEMA_FILE = "";
+
+ /* replace transform constant */
+ public static final String PATTERN = "pattern";
+ public static final String REPLACEMENT = "replacement";
+ public static final String REPLACE_REGEX = "is_regex";
+ public static final boolean DEFAULT_REPLACE_REGEX = false;
+ public static final String REPLACE_FIRST = "replace_first";
+ public static final boolean DEFAULT_REPLACE_FIRST = false;
+
+ /* split transform constant */
+ public static final String SPLIT_SEPARATOR = "separator";
+ public static final String DEFAULT_SPLIT_SEPARATOR = " ";
+
+ /* UUID transform constant */
+ public static final String UUID_PREFIX = "prefix";
+ public static final String DEFAULT_UUID_PREFIX = "";
+ public static final String UUID_SECURE = "secure";
+ public static final boolean DEFAULT_UUID_SECURE = false;
Review Comment:
The constants file need to put into plugin module, you need to create constant file for each plugin.
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r860706820
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
Please split this constant string, we don't want to receive another PR to solve this. And split the constant string in `Replace`.
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
+
+ val func: UserDefinedFunction = udf(() => {
+ generate(config.getString("prefix"))
+ })
+ var filterDf = df.withColumn(Constants.ROW_TMP, func())
+ filterDf = filterDf.withColumn(key, col(Constants.ROW_TMP))
+ val ds = filterDf.drop(Constants.ROW_TMP)
+ if (func != null) {
+ env.getSparkSession.udf.register("Uuid", func)
+ }
+ ds
+ }
+
+ override def checkConfig(): CheckResult = {
+ checkAllExists(config, "fields")
+ }
+
+ override def prepare(env: SparkEnvironment): Unit = {
+ val defaultConfig = ConfigFactory.parseMap(Map("prefix" -> "", "secure" -> false))
+ config = config.withFallback(defaultConfig)
+
+ /**
+ * The secure algorithm can be comparatively slow.
+ * The new nonSecure algorithm never blocks and is much faster.
+ * The nonSecure algorithm uses a secure random seed but is otherwise deterministic,
+ * though it is one of the strongest uniform pseudo-random number generators known so far.
+ * thanks for whoschek@cloudera.com
+ */
+ if (config.getBoolean("secure")) {
+ val rand = new SecureRandom
+ val seed = for (_ <- 0 until 728) yield rand.nextInt
+ prng = new Well19937c(seed.toArray)
+ }
+ }
+
+ @VisibleForTesting
+ def generate(prefix: String): String = {
+ val uuid = if (prng == null) UUID.randomUUID else new UUID(prng.nextLong, prng.nextLong)
+ prefix + uuid
+ }
+
+ @VisibleForTesting
+ def setPrng(prng: RandomGenerator): Unit = {
+ this.prng = prng
+ }
+}
Review Comment:
Please implement the `getPluginName()` method. And please solve this in `Replace` together.
##########
docs/en/transform/uuid.md:
##########
@@ -0,0 +1,62 @@
+# Uuid
+
+## Description
+
+Generate a universally unique identifier on a specified field.
+
+:::tip
+
+This transform **ONLY** supported by Spark.
+
+:::
+
+## Options
+
+| name | type | required | default value |
+| -------------- | ------ | -------- | ------------- |
+| fields | string | yes | - |
+| prefix | string | no | - |
+| secure | boolean| no | false |
+
+### field [string]
+
+The name of the field to generate.
+
+### prefix [string]
+
+The prefix string constant to prepend to each generated UUID.
+
+### secure [boolean]
+
+the cryptographically secure algorithm can be comparatively slow
+The nonSecure algorithm uses a secure random seed but is otherwise deterministic
+
+### common options [string]
+
+Transform plugin common parameters, please refer to [Transform Plugin](common-options.mdx) for details
+
+## Examples
+
+```bash
+ uuid {
Review Comment:
Maybe use `UUID` is better? Anyway there is a typo.
```suggestion
UUID {
```
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [incubator-seatunnel] ruanwenjun commented on a diff in pull request #1770: [Feature][seatunnel-transforms] Add Uuid transform for spark
Posted by GitBox <gi...@apache.org>.
ruanwenjun commented on code in PR #1770:
URL: https://github.com/apache/incubator-seatunnel/pull/1770#discussion_r860842038
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
@wuzhenhua01 Sorry, I don't make myself clear. It's better to split the magic string from this method. We can add a Object e.g. Config or Constant to store these config key "fields", "prefix".
##########
seatunnel-transforms/seatunnel-transforms-spark/seatunnel-transform-spark-uuid/src/main/scala/org/apache/seatunnel/spark/transform/Uuid.scala:
##########
@@ -0,0 +1,85 @@
+/*
+ * 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.seatunnel.spark.transform
+
+import java.security.SecureRandom
+import java.util.UUID
+
+import scala.collection.JavaConversions._
+
+import com.google.common.annotations.VisibleForTesting
+import org.apache.commons.math3.random.{RandomGenerator, Well19937c}
+import org.apache.seatunnel.common.Constants
+import org.apache.seatunnel.common.config.CheckConfigUtil.checkAllExists
+import org.apache.seatunnel.common.config.CheckResult
+import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.apache.spark.sql.expressions.UserDefinedFunction
+import org.apache.spark.sql.functions.{col, udf}
+
+class Uuid extends BaseSparkTransform {
+ private var prng: RandomGenerator = _
+
+ override def process(df: Dataset[Row], env: SparkEnvironment): Dataset[Row] = {
+ val key = config.getString("fields")
Review Comment:
@wuzhenhua01 Sorry, I don't make myself clear. It's better to split the magic string from this method. We can add an Object e.g. Config or Constant to store these configs key "fields", "prefix".
--
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: commits-unsubscribe@seatunnel.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org