-
Notifications
You must be signed in to change notification settings - Fork 29.3k
[SPARK-37173][SQL] SparkGetFunctionOperation return builtin function only once #34453
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
Changes from 7 commits
118af14
a1b21fe
3362038
75131c8
29da65a
4bbc8cc
89bb678
479d533
366eed7
392c5ea
2b74561
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -210,11 +210,14 @@ class SparkMetadataOperationSuite extends HiveThriftServer2TestBase { | |
| } | ||
|
|
||
| test("Spark's own GetFunctionsOperation(SparkGetFunctionsOperation)") { | ||
| def checkResult(rs: ResultSet, functionNames: Seq[String]): Unit = { | ||
| def checkResult( | ||
| rs: ResultSet, | ||
| functionNames: Seq[String], | ||
| functionSchema: String = "default"): Unit = { | ||
| functionNames.foreach { func => | ||
| val exprInfo = FunctionRegistry.expressions(func)._1 | ||
| assert(rs.next()) | ||
| assert(rs.getString("FUNCTION_SCHEM") === "default") | ||
| assert(rs.getString("FUNCTION_SCHEM") === functionSchema) | ||
| assert(rs.getString("FUNCTION_NAME") === exprInfo.getName) | ||
| assert(rs.getString("REMARKS") === | ||
| s"Usage: ${exprInfo.getUsage}\nExtended Usage:${exprInfo.getExtended}") | ||
|
|
@@ -226,6 +229,7 @@ class SparkMetadataOperationSuite extends HiveThriftServer2TestBase { | |
| } | ||
|
|
||
| withJdbcStatement() { statement => | ||
| statement.execute(s"SET ${SQLConf.THRIFTSERVER_SEPARATE_DISPLAY_SYSTEM_FUNCTION.key}=false") | ||
| val metaData = statement.getConnection.getMetaData | ||
| // Hive does not have an overlay function, we use overlay to test. | ||
| checkResult(metaData.getFunctions(null, null, "overlay"), Seq("overlay")) | ||
|
|
@@ -236,6 +240,17 @@ class SparkMetadataOperationSuite extends HiveThriftServer2TestBase { | |
| checkResult(metaData.getFunctions(null, "default", "shift*"), | ||
| Seq("shiftleft", "shiftright", "shiftrightunsigned")) | ||
| checkResult(metaData.getFunctions(null, "default", "upPer"), Seq("upper")) | ||
|
|
||
| statement.execute(s"SET ${SQLConf.THRIFTSERVER_SEPARATE_DISPLAY_SYSTEM_FUNCTION.key}=true") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add a test with two schemas and run an unfiltered getFunctions call to show that previously we'd see duplicates, whereas now the functions are unique?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great, thanks! |
||
| checkResult(metaData.getFunctions(null, null, "overlay"), Seq("overlay"), "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, null, "overla*"), Seq("overlay"), "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, "", "overla*"), Seq("overlay"), "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, null, "does-not-exist*"), Seq.empty, "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, "default", "overlay"), Seq("overlay"), "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, "default", "shift*"), | ||
| Seq("shiftleft", "shiftright", "shiftrightunsigned"), "SYSTEM") | ||
| checkResult(metaData.getFunctions(null, "default", "upPer"), Seq("upper"), "SYSTEM") | ||
|
|
||
| } | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.