Skip to content

[SPARK-39488][SQL] Simplify the error handling of TempResolvedColumn - #36809

Closed
cloud-fan wants to merge 7 commits into
apache:masterfrom
cloud-fan:error
Closed

[SPARK-39488][SQL] Simplify the error handling of TempResolvedColumn#36809
cloud-fan wants to merge 7 commits into
apache:masterfrom
cloud-fan:error

Conversation

@cloud-fan

@cloud-fancloud-fan commented Jun 8, 2022

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

This is a followup of #35404 and #36746 , to simplify the error handling of TempResolvedColumn.

The idea is:

  1. The rule ResolveAggregationFunctions in the main resolution batch creates TempResolvedColumn and only removes it if the aggregate expression is fully resolved. It either strips TempResolvedColumn if it's inside aggregate function or group expression, or restores TempResolvedColumn to UnresolvedAttribute otherwise, hoping other rules can resolve it.
  2. The rule RemoveTempResolvedColumn in a latter batch can still hit TempResolvedColumn if the aggregate expression is unresolved (due to input type mismatch for example, e.g. avg(bool_col), date_add(int_group_col, 1)). At this stage, there is no way to restore TempResolvedColumn to UnresolvedAttribute and resolve it differently. The query will fail and we should blindly strip TempResolvedColumn to provide better error message.

Why are the changes needed?

code cleanup

Does this PR introduce any user-facing change?

no

How was this patch tested?

existing tests

@cloud-fan
cloud-fanforce-pushed the error branch 2 times, most recently from fb4fe23 to adc464fCompareJune 14, 2022 14:38
@cloud-fancloud-fan changed the title [WIP] Simplify the handling of TempResolvedColumn[WIP] Simplify the error handling of TempResolvedColumnJun 14, 2022
@cloud-fancloud-fan changed the title [WIP] Simplify the error handling of TempResolvedColumn[SPARK-39488][SQL] Simplify the error handling of TempResolvedColumnJun 16, 2022
@cloud-fan

Copy link
Copy Markdown
ContributorAuthor

Comment on lines -53 to -54
val DATA_TYPE_MISMATCH_ERROR_MESSAGE = TreeNodeTag[String]("dataTypeMismatchError")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

just to make sure this isn't related to TempResolvedColumn, right?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

It was used to do error handling of TempResolvedColumn, but we don't need it now as the logic is simplified.

@LuciferYangLuciferYangJun 16, 2022

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just to make sure this isn't related to TempResolvedColumn, right?

Yes, I added this in #36746. It is not needed after this pr

…ysis/Analyzer.scala
Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
@cloud-fan

Copy link
Copy Markdown
ContributorAuthor

thanks for review, merging to master!

Sign up for freeto 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.

3 participants

@cloud-fan@viirya@LuciferYang