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-40324][SQL][FOLLOWUP] Fix a bug in setting query context in Analyzer #37861

Closed
wants to merge 9 commits into from

Conversation

gengliangwang
Copy link
Member

What changes were proposed in this pull request?

This is a followup of #37841. The code change in https://github.com/apache/spark/pull/37841/files#diff-ed19f376a63eba52eea59ca71f3355d4495fad4fad4db9a3324aade0d4986a47R212 is wrong. The context ofanalyzed.origin is not accurate at all. Thus this PR is to revert it

Why are the changes needed?

Fix a wrong query context in previous PR #37841

Does this PR introduce any user-facing change?

No

How was this patch tested?

GA tests

@gengliangwang
Copy link
Member Author

gengliangwang commented Sep 13, 2022

For throwing AnalysisException, we should use the method

    def failAnalysis(errorClass: String, messageParameters: Array[String]): Nothing = {
      throw new AnalysisException(
        errorClass = errorClass,
        messageParameters = messageParameters,
        origin = t.origin)
    }

or similar approaches.
For example: #37811 (comment)

Comment on lines -236 to -243
},
"queryContext" : [ {
"objectType" : "",
"objectName" : "",
"startIndex" : 56,
"stopIndex" : 65,
"fragment" : "GROUP BY b"
} ]
Copy link
Member

Choose a reason for hiding this comment

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

Why does the context disappear completely?

Copy link
Member Author

Choose a reason for hiding this comment

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

Previously it is set as analyzed.origin which is wrong. It should point to a instead of GROUP BY b anyway.

@gengliangwang
Copy link
Member Author

@cloud-fan @MaxGekk Thanks for the review. Merging this one 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