You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Wenchen Fan (Jira)" <ji...@apache.org> on 2025/07/14 12:40:00 UTC
[jira] [Assigned] (SPARK-52565) Enforce ordinal resolution before other sort order expressions
[ https://issues.apache.org/jira/browse/SPARK-52565?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Wenchen Fan reassigned SPARK-52565:
-----------------------------------
Assignee: Mihailo Aleksic
> Enforce ordinal resolution before other sort order expressions
> --------------------------------------------------------------
>
> Key: SPARK-52565
> URL: https://issues.apache.org/jira/browse/SPARK-52565
> Project: Spark
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 4.1.0
> Reporter: Mihailo Aleksic
> Assignee: Mihailo Aleksic
> Priority: Major
> Labels: pull-request-available
>
> The following query passes, but should fail:
> SELECT col2 FROM values(1,2) ORDER BY 2,col1
> As it can be seen in the query, we try to order by 2 which is an ordinal in this case and it should fail with ORDER_BY_POS_OUT_OF_RANGE. It doesn't because of Analyzer rule ordering issue.
> We first resolve the sort order col1 using the ResolveReferencesInSort rule. It turns out to be a missing input and thus we add it to the Project below and add another Project on top of sort to retain original output. At that point, plan looks like:
> Project\[col1#x]
> +- Sort\['UnresolvedOrdinal(2), col1#x]
> +- Project\[col2#x, col1#x]
> ...
>
> Then we go to ResolveOrdinalInOrderByAndGroupBy and successfully resolve the UnresolvedOrdinal because there are two elements in the Project below. This shouldn't happen and we should fail.
> In this issue I propose that we fix it by enforcing ordinal resolution before other sort order expressions.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org