Skip to content

[SPARK-50497][SQL] Fail queries with proper message if MultiAlias contains non-generator function#49072

Closed
mihailomilosevic2001 wants to merge 5 commits intoapache:masterfrom
mihailomilosevic2001:fixGenerators
Closed

[SPARK-50497][SQL] Fail queries with proper message if MultiAlias contains non-generator function#49072
mihailomilosevic2001 wants to merge 5 commits intoapache:masterfrom
mihailomilosevic2001:fixGenerators

Conversation

@mihailomilosevic2001
Copy link
Contributor

@mihailomilosevic2001 mihailomilosevic2001 commented Dec 5, 2024

What changes were proposed in this pull request?

MultiAlias fails if the underlying function is not a generator.

Why are the changes needed?

Syntax for multi aliasing should return proper error and not fail in check analysis with unresolved.

Does this PR introduce any user-facing change?

Yes, error message changes

How was this patch tested?

Added test.

Was this patch authored or co-authored using generative AI tooling?

Yes.

@github-actions github-actions bot added the SQL label Dec 5, 2024
# Conflicts:
#	sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/CheckAnalysis.scala
@mihailomilosevic2001 mihailomilosevic2001 changed the title Fix generators [SPARK-50497][SQL] Fail queries with proper message if MultiAlias contains non-generator function Dec 5, 2024
@mihailomilosevic2001
Copy link
Contributor Author

@MaxGekk please review this.

@mihailomilosevic2001
Copy link
Contributor Author

@vladimirg-db for context.

errorClass = "UNBOUND_SQL_PARAMETER",
messageParameters = Map("name" -> p.name))

case ma@MultiAlias(child, names) if child.resolved && !child.isInstanceOf[Generator] =>
Copy link
Contributor

Choose a reason for hiding this comment

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

Why exactly do we check for child.resolved here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If child is unresolved, we cannot check for Generator, as we would usually have UnresolvedFunction.

},
"MULTI_ALIAS_WITHOUT_GENERATOR" : {
"message" : [
"Multi part aliasing (<names>) is not supported with <expr> as it is not a generator function."
Copy link
Contributor

Choose a reason for hiding this comment

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

is Multi part aliasing an official name in SQL standard?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It's not a concept at all. I don't have a better name.

@cloud-fan
Copy link
Contributor

thanks, merging to master!

@cloud-fan cloud-fan closed this in 88102d3 Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants