Skip to content
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

[SPARK-39880][SQL] V2 SHOW FUNCTIONS command should print qualified function name like v1 #37301

Closed
wants to merge 1 commit into from

Conversation

cloud-fan
Copy link
Contributor

What changes were proposed in this pull request?

This PR fixes a mismatch between v1 and v2 SHOW FUNCTIONS command: v1 prints qualified function names such as spark_catalog.db1.f1, but v2 only prints the function name. V2 command should follow v1 behavior which makes more sense.

This PR also updates the SHOW FUNCTIONS test suites to match the new behavior.

Why are the changes needed?

keep v1 and v2 commands consistent.

Does this PR introduce any user-facing change?

No, v2 SHOW FUNCTIONS is new in Spark 3.4 (not released)

How was this patch tested?

updated tests

@cloud-fan
Copy link
Contributor Author

cc @MaxGekk

}
}

test("show a function by its id") {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing it because it's almost the same as show a function in the USER name space

override protected def createFunction(name: String): Unit = {
spark.udf.register(name, (arg1: Int, arg2: String) => arg2 + arg1)
sql(s"CREATE FUNCTION $name AS '${classOf[MyDoubleSum].getName}'")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

V1 in memory catalog supports persistent functions as well: the UDAF interface.

@github-actions github-actions bot added the SQL label Jul 26, 2022
} else Seq.empty
val allFunctions = StringUtils.filterPattern(
userFunctions ++ systemFunctions,
pattern.getOrElse("*")).distinct.sorted
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my minor opinion, the origin code only call StringUtils.filterPattern once, it seems no need create a new method applyPattern.

Copy link
Contributor Author

@cloud-fan cloud-fan Jul 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't apply only once after this PR. The pattern should be applied to function names only, not qualified names. So I have to apply the pattern separately for persistent functions before generating qualified names.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. function names has been qualified.

@MaxGekk
Copy link
Member

MaxGekk commented Jul 27, 2022

+1, LGTM. Merging to master.
Thank you, @cloud-fan and @beliefer for review.

@MaxGekk MaxGekk closed this in 47f0303 Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants