-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-17996][SQL] Fix unqualified catalog.getFunction(...) #15542
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Test build #67161 has finished for PR 15542 at commit
|
|
Test build #67171 has finished for PR 15542 at commit
|
srinathshankar
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some minor comments
| return db; | ||
| } | ||
|
|
||
| public ExpressionInfo(String className, String name, String usage, String extended, String db) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could we put the db name before the expression name in the params ? Not a big deal if this requires more surgery.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
| case _ => | ||
| try { | ||
| val info = sparkSession.sessionState.catalog.lookupFunctionInfo(functionName) | ||
| val db = if (info.getDb != null) info.getDb + "." else "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just inline the definition of val db into the definition of val name ? You don't use it anywhere else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
| description = null, // for now, this is always undefined | ||
| className = metadata.getClassName, | ||
| isTemporary = funcIdent.database.isEmpty) | ||
| isTemporary = metadata.getDb == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this still the right way to do this ? What about global temp tables ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do not support global temp functions. So this is the right way to do it.
|
Test build #67883 has finished for PR 15542 at commit
|
|
Merging to master. Thanks for the review. |
## What changes were proposed in this pull request?
Currently an unqualified `getFunction(..)`call returns a wrong result; the returned function is shown as temporary function without a database. For example:
```
scala> sql("create function fn1 as 'org.apache.hadoop.hive.ql.udf.generic.GenericUDFAbs'")
res0: org.apache.spark.sql.DataFrame = []
scala> spark.catalog.getFunction("fn1")
res1: org.apache.spark.sql.catalog.Function = Function[name='fn1', className='org.apache.hadoop.hive.ql.udf.generic.GenericUDFAbs', isTemporary='true']
```
This PR fixes this by adding database information to ExpressionInfo (which is used to store the function information).
## How was this patch tested?
Added more thorough tests to `CatalogSuite`.
Author: Herman van Hovell <hvanhovell@databricks.com>
Closes apache#15542 from hvanhovell/SPARK-17996.
What changes were proposed in this pull request?
Currently an unqualified
getFunction(..)call returns a wrong result; the returned function is shown as temporary function without a database. For example:This PR fixes this by adding database information to ExpressionInfo (which is used to store the function information).
How was this patch tested?
Added more thorough tests to
CatalogSuite.