You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by gatorsmile <gi...@git.apache.org> on 2017/04/12 05:32:59 UTC

[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

GitHub user gatorsmile opened a pull request:

    https://github.com/apache/spark/pull/17615

    [SPARK-20303][SQL] Rename createTempFunction to registerFunction

    ### What changes were proposed in this pull request?
    Session catalog API `createTempFunction` is being used by Hive build-in functions, persistent functions, and temporary functions. Thus, the name is confusing. This PR is to rename it by `registerFunction`. Also we can move construction of `FunctionBuilder` and `ExpressionInfo` into the new `registerFunction`, instead of duplicating the logics everywhere.
    
    In the next PRs, the remaining Function-related APIs also need cleanups. 
    
    ### How was this patch tested?
    Existing test cases.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/gatorsmile/spark cleanupCreateTempFunction

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/17615.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #17615
    
----
commit cc164813d7d775f233f62901e09885fc322bc150
Author: Xiao Li <ga...@gmail.com>
Date:   2017-04-12T05:20:07Z

    fix.

commit e876af1882a53fcd5569594e9ea486dba66850b4
Author: Xiao Li <ga...@gmail.com>
Date:   2017-04-12T05:29:02Z

    fix.

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    Merged build finished. Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/17615


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17615#discussion_r111068131
  
    --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala ---
    @@ -1050,7 +1050,7 @@ class SessionCatalog(
        *
        * This performs reflection to decide what type of [[Expression]] to return in the builder.
        */
    -  def makeFunctionBuilder(name: String, functionClassName: String): FunctionBuilder = {
    +  protected def makeFunctionBuilder(name: String, functionClassName: String): FunctionBuilder = {
    --- End diff --
    
    `registerFunction` is the only caller of `makeFunctionBuilder` after this PR.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75735/
    Test PASSed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    LGTM


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17615#discussion_r111068037
  
    --- Diff: sql/hive/src/main/scala/org/apache/spark/sql/hive/HiveSessionCatalog.scala ---
    @@ -124,13 +124,6 @@ private[sql] class HiveSessionCatalog(
       }
     
       private def lookupFunction0(name: FunctionIdentifier, children: Seq[Expression]): Expression = {
    -    // TODO: Once lookupFunction accepts a FunctionIdentifier, we should refactor this method to
    -    // if (super.functionExists(name)) {
    -    //   super.lookupFunction(name, children)
    -    // } else {
    -    //   // This function is a Hive builtin function.
    -    //   ...
    -    // }
    --- End diff --
    
    `LookupFunction` already accepts `FunctionIdentifier`, but we are unable to do it using the above way because `functionExists` does not consider the difference among Hive built-in, Spark temporary and permanent functions. More following clean-ups are needed. Will try to do it.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    retest this please


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    **[Test build #75735 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75735/testReport)** for PR 17615 at commit [`e876af1`](https://github.com/apache/spark/commit/e876af1882a53fcd5569594e9ea486dba66850b4).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17615#discussion_r111073982
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala ---
    @@ -59,17 +60,13 @@ case class CreateFunctionCommand(
           // We first load resources and then put the builder in the function registry.
           // Please note that it is allowed to overwrite an existing temp function.
           catalog.loadFunctionResources(resources)
    -      val info = new ExpressionInfo(className, functionName)
    -      val builder = catalog.makeFunctionBuilder(functionName, className)
    -      catalog.createTempFunction(functionName, info, builder, ignoreIfExists = false)
    +      catalog.registerFunction(func, ignoreIfExists = false)
         } else {
           // For a permanent, we will store the metadata into underlying external catalog.
           // This function will be loaded into the FunctionRegistry when a query uses it.
           // We do not load it into FunctionRegistry right now.
           // TODO: should we also parse "IF NOT EXISTS"?
    --- End diff --
    
    Nope. : ) 
    
    Oracle has [the `OR REPLACE` clause](https://docs.oracle.com/cd/B19306_01/server.102/b14200/statements_5009.htm). 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    **[Test build #75725 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75725/testReport)** for PR 17615 at commit [`e876af1`](https://github.com/apache/spark/commit/e876af1882a53fcd5569594e9ea486dba66850b4).


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    Merged build finished. Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    Thanks! Merging to master.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/75725/
    Test FAILed.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by cloud-fan <gi...@git.apache.org>.
Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17615#discussion_r111070619
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala ---
    @@ -59,17 +60,13 @@ case class CreateFunctionCommand(
           // We first load resources and then put the builder in the function registry.
           // Please note that it is allowed to overwrite an existing temp function.
           catalog.loadFunctionResources(resources)
    -      val info = new ExpressionInfo(className, functionName)
    -      val builder = catalog.makeFunctionBuilder(functionName, className)
    -      catalog.createTempFunction(functionName, info, builder, ignoreIfExists = false)
    +      catalog.registerFunction(func, ignoreIfExists = false)
         } else {
           // For a permanent, we will store the metadata into underlying external catalog.
           // This function will be loaded into the FunctionRegistry when a query uses it.
           // We do not load it into FunctionRegistry right now.
           // TODO: should we also parse "IF NOT EXISTS"?
    --- End diff --
    
    does hive support it?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request #17615: [SPARK-20303][SQL] Rename createTempFunction to r...

Posted by gatorsmile <gi...@git.apache.org>.
Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17615#discussion_r111068193
  
    --- Diff: sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala ---
    @@ -59,17 +60,13 @@ case class CreateFunctionCommand(
           // We first load resources and then put the builder in the function registry.
           // Please note that it is allowed to overwrite an existing temp function.
           catalog.loadFunctionResources(resources)
    -      val info = new ExpressionInfo(className, functionName)
    -      val builder = catalog.makeFunctionBuilder(functionName, className)
    -      catalog.createTempFunction(functionName, info, builder, ignoreIfExists = false)
    +      catalog.registerFunction(func, ignoreIfExists = false)
         } else {
           // For a permanent, we will store the metadata into underlying external catalog.
           // This function will be loaded into the FunctionRegistry when a query uses it.
           // We do not load it into FunctionRegistry right now.
           // TODO: should we also parse "IF NOT EXISTS"?
    --- End diff --
    
    Should we support it? @cloud-fan @yhuai @rxin 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark issue #17615: [SPARK-20303][SQL] Rename createTempFunction to register...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the issue:

    https://github.com/apache/spark/pull/17615
  
    **[Test build #75735 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/75735/testReport)** for PR 17615 at commit [`e876af1`](https://github.com/apache/spark/commit/e876af1882a53fcd5569594e9ea486dba66850b4).
     * This patch passes all tests.
     * This patch merges cleanly.
     * This patch adds no public classes.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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