Skip to content

Conversation

@itholic
Copy link
Contributor

@itholic itholic commented Nov 9, 2022

What changes were proposed in this pull request?

This PR proposes to rename UNSUPPORTED_CORRELATED_REFERENCE to CORRELATED_REFERENCE.

Also, show sqlExprs rather than treeNode which is more useful information to users.

Why are the changes needed?

The sub-error class name is duplicated with its main class, UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.

We should make the all error class name clear and briefly.

Does this PR introduce any user-facing change?

No

How was this patch tested?

./build/sbt “sql/testOnly org.apache.spark.sql.SQLQueryTestSuite*”

@itholic
Copy link
Contributor Author

itholic commented Nov 10, 2022

cc @MaxGekk @srielau

},
"CORRELATED_REFERENCE" : {
"message" : [
"Expressions referencing the outer query are not supported outside of WHERE/HAVING clauses<treeNode>"
Copy link
Member

Choose a reason for hiding this comment

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

Let's don't confuse users by treeNode, and show something more useful like problematic SQL expr.

Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, let's show the expression. (having the expression in the context would also be acceptable). No treenode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MaxGekk May I ask if there is any way to extract the SQL expr from LogicalPlan ??

I'm trying to switch planToString(p) to SQL expression but still not sure how.

Copy link
Member

Choose a reason for hiding this comment

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

Expressions referencing the outer query ...

Can you show the expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, just fixed it to show SQL expression!

},
"CORRELATED_REFERENCE" : {
"message" : [
"Expressions referencing the outer query are not supported outside of WHERE/HAVING clauses<treeNode>"
Copy link
Contributor

Choose a reason for hiding this comment

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

Agreed, let's show the expression. (having the expression in the context would also be acceptable). No treenode

Comment on lines 1063 to 1064
val exprs = new ListBuffer[String]()
for (expr <- p.expressions) {
Copy link
Member

Choose a reason for hiding this comment

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

This can be simpler using filter instead of exists and for

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! Just addressed the comments

errorClass = "UNSUPPORTED_SUBQUERY_EXPRESSION_CATEGORY.CORRELATED_REFERENCE",
parameters = Map("sqlExprs" -> "outer(arr_c2#427264)"),
sqlState = None,
parameters = Map("sqlExprs" -> "explode\\(outer\\(arr_c2#.*"),
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be: t2.arr_c2

Copy link
Contributor Author

@itholic itholic Dec 1, 2022

Choose a reason for hiding this comment

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

I squeeze out the outer expression here, but seems like this shows explode(arr_c2) with current behavior of stripOuterReference.

@MaxGekk WDYT? Is there any way, or should we fix the stripOuterReference to display the t2.arr_c2 here?

Copy link
Member

Choose a reason for hiding this comment

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

should we fix the stripOuterReference to display the t2.arr_c2 here?

No, let's fix it separately.

@MaxGekk
Copy link
Member

MaxGekk commented Dec 13, 2022

+1, LGTM. Merging to master.
Thank you, @itholic.

@MaxGekk MaxGekk closed this in e29ada0 Dec 13, 2022
@itholic itholic deleted the SPARK-41062 branch April 22, 2023 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants