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/03/02 00:55:41 UTC

[GitHub] [incubator-seatunnel] yx91490 opened a new pull request #1367: [SeaTunnel#1343] add plugin: seatunnel-transform-spark-sleep

yx91490 opened a new pull request #1367:
URL: https://github.com/apache/incubator-seatunnel/pull/1367


   <!--
   
   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
   
   close #1343 
   
   <!-- Describe the purpose of this pull request. For example: This pull request adds checkstyle plugin.-->
   
   ## Check list
   
   * [ ] Code changed are covered with tests, or it does not need tests for reason:
   * [ ] If any new Jar binary package adding in you PR, please add License Notice according
     [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/developement/NewLicenseGuide.md)
   * [ ] 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] ZhangchengHu0923 commented on pull request #1367: [Feature#1343][Connectors] add plugin: seatunnel-transform-spark-sleep

Posted by GitBox <gi...@apache.org>.
ZhangchengHu0923 commented on pull request #1367:
URL: https://github.com/apache/incubator-seatunnel/pull/1367#issuecomment-1062520769


   > There might be an error need to change here.
   > 
   > And I am not sure in which case the newly added transformer will be useful, since it doesn't output any information that would be helpful for debug.
   
   @yx91490 I'm interested in this feature too, could u please describe how you debug with this sleep 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] yx91490 commented on a change in pull request #1367: [Feature#1343][Connectors] add plugin: seatunnel-transform-spark-sleep

Posted by GitBox <gi...@apache.org>.
yx91490 commented on a change in pull request #1367:
URL: https://github.com/apache/incubator-seatunnel/pull/1367#discussion_r826047262



##########
File path: seatunnel-transforms/seatunnel-transform-spark-sleep/src/main/scala/org/apache/seatunnel/spark/transform/Sleep.scala
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.util.concurrent.TimeUnit
+
+import org.apache.seatunnel.common.config.{CheckConfigUtil, CheckResult}
+import org.apache.seatunnel.spark.{BaseSparkTransform, SparkEnvironment}
+import org.apache.spark.sql.{Dataset, Row}
+import org.slf4j.{Logger, LoggerFactory}
+
+class Sleep extends BaseSparkTransform {
+
+  private val logger: Logger = LoggerFactory.getLogger(classOf[Sleep])
+
+  private[transform] val KEY_TIMEUNIT = "timeunit"
+
+  private[transform] val KEY_TIMEOUT = "timeout"
+
+  private[transform] val VALID_TIMEUNITS: Set[String] = TimeUnit.values().map(it => it.name()).toSet
+
+  override def checkConfig(): CheckResult = {
+    val result = CheckConfigUtil.checkAllExists(config, KEY_TIMEOUT)
+    if (!result.isSuccess) {
+      return result
+    }
+    if (config.hasPath(KEY_TIMEUNIT)) {
+      val timeunit = config.getString(KEY_TIMEUNIT)
+      if (!VALID_TIMEUNITS.contains(timeunit)) {
+        CheckResult.error(s"TimeUnit '$timeunit' is invalid!")
+      }
+    }
+    CheckResult.success()

Review comment:
       sorry, very thanks!




-- 
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] yx91490 commented on pull request #1367: [Feature#1343][Connectors] add plugin: seatunnel-transform-spark-sleep

Posted by GitBox <gi...@apache.org>.
yx91490 commented on pull request #1367:
URL: https://github.com/apache/incubator-seatunnel/pull/1367#issuecomment-1066917076


   > > There might be an error need to change here.
   > > And I am not sure in which case the newly added transformer will be useful, since it doesn't output any information that would be helpful for debug.
   > 
   > @yx91490 I'm interested in this feature too, could u please describe how you debug with this sleep plugin ?
   
   you can use your imagination :)


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