You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Erik Jansen (Jira)" <ji...@apache.org> on 2022/05/21 10:26:00 UTC

[jira] [Created] (SPARK-39247) Support returning a table or set of rows in CREATE FUNCTION

Erik Jansen created SPARK-39247:
-----------------------------------

             Summary: Support returning a table or set of rows in CREATE FUNCTION
                 Key: SPARK-39247
                 URL: https://issues.apache.org/jira/browse/SPARK-39247
             Project: Spark
          Issue Type: New Feature
          Components: SQL
    Affects Versions: 3.3.0
            Reporter: Erik Jansen


The Databricks version supports create a function which returns a result set:
_"Creates a SQL scalar or table function that takes a set of arguments and returns a scalar value or a set of rows."_
Such functions are very useful as the user can pass a list of parameters which can be used in the function to create a dynamic result set (a query which will use the passed parameters). 

See the example from databricks:
{_}"{_}{_}-- Produce all weekdays between two dates > CREATE FUNCTION weekdays(start DATE, end DATE) RETURNS TABLE(day_of_week STRING, day DATE) RETURN SELECT extract(DAYOFWEEK_ISO FROM day), day FROM (SELECT sequence(weekdays.start, weekdays.end)) AS T(days) LATERAL VIEW explode(days) AS day WHERE extract(DAYOFWEEK_ISO FROM day) BETWEEN 1 AND 5;"{_}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org