You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Apache Spark (Jira)" <ji...@apache.org> on 2021/02/07 12:30:00 UTC
[jira] [Assigned] (SPARK-34396) Add a new build-in function
delegate
[ https://issues.apache.org/jira/browse/SPARK-34396?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Apache Spark reassigned SPARK-34396:
------------------------------------
Assignee: (was: Apache Spark)
> Add a new build-in function delegate
> ------------------------------------
>
> Key: SPARK-34396
> URL: https://issues.apache.org/jira/browse/SPARK-34396
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 3.2.0
> Reporter: ulysses you
> Priority: Minor
>
> Delegate is just like a big box that can include some other expressions. It will execute all of children and return the last child result as its result.
>
> The origin idea is from debug. Debug SQL is hard since SQL is always quite long and complex. This new function can help debug with inject some help functions, e.g., `println, sleep, raise_error`.
>
> Two usage examples:
> {code:java}
> -- raw sql
> INSERT INTO TABLE t1
> SELECT coalesce(c1, c2) as c FROM t2
>
> -- print the column data
> INSERT INTO TABLE t1
> SELECT delegate(
> java_method('scala.Console', 'println', concat('c1: ', c1, ', c2: ', c2)),
> coalesce(c1, c2)
> ) as c FROM t2{code}
>
> {code:java}
> -- raw sql
> SELECT if(spark_partition_id() = 1, c1, raise_error('test error')) FROM t2
>
> -- add a sleep time before throw error
> SELECT if(spark_partition_id() = 1, c1, delegate(
> java_method('java.lang.Thread', 'sleep', 3000l),
> raise_error('test error')
> )) FROM t2{code}
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org