Skip to content

Conversation

@cloud-fan
Copy link
Contributor

@cloud-fan cloud-fan commented Jun 8, 2022

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

@github-actions github-actions bot added the SQL label Jun 8, 2022
@cloud-fan cloud-fan force-pushed the error branch 2 times, most recently from fb4fe23 to adc464f Compare June 14, 2022 14:38
@cloud-fan cloud-fan changed the title [WIP] Simplify the handling of TempResolvedColumn [WIP] Simplify the error handling of TempResolvedColumn Jun 14, 2022
@cloud-fan cloud-fan changed the title [WIP] Simplify the error handling of TempResolvedColumn [SPARK-39488][SQL] Simplify the error handling of TempResolvedColumn Jun 16, 2022
@cloud-fan
Copy link
Contributor Author

cc @LuciferYang @amaliujia @viirya

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

Copy link
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
Contributor Author

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.

Copy link
Contributor

@LuciferYang LuciferYang Jun 16, 2022

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

@cloud-fan cloud-fan closed this in 6d86d41 Jun 16, 2022
@cloud-fan
Copy link
Contributor Author

thanks for review, merging to master!

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.

3 participants