nastra commented on code in PR #11729:
URL: https://github.com/apache/iceberg/pull/11729#discussion_r1879880071
##########
spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveViews.scala:
##########
@@ -65,6 +85,25 @@ case class ResolveViews(spark: SparkSession) extends
Rule[LogicalPlan] with Look
if query.resolved && !c.rewritten =>
val aliased = aliasColumns(query, columnAliases, columnComments)
c.copy(query = aliased, queryColumnNames = query.schema.fieldNames,
rewritten = true)
+
+ case s: Sort if conf.orderByOrdinal && s.order.exists(o =>
containIntLiteral(o.child)) =>
Review Comment:
this is the wrong place to fix this. We rather need to do this when creating
the view relation. This diff should be enough:
```
---
a/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveViews.scala
+++
b/spark/v3.5/spark-extensions/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveViews.scala
@@ -124,10 +124,10 @@ case class ResolveViews(spark: SparkSession) extends
Rule[LogicalPlan] with Look
private def rewriteIdentifiers(
plan: LogicalPlan,
catalogAndNamespace: Seq[String]): LogicalPlan = {
- // Substitute CTEs within the view, then rewrite unresolved functions
and relations
+ // Substitute CTEs and Unresolved Ordinals within the view, then
rewrite unresolved functions and relations
qualifyTableIdentifiers(
qualifyFunctionIdentifiers(
- CTESubstitution.apply(plan),
+ SubstituteUnresolvedOrdinals.apply(CTESubstitution.apply(plan)),
catalogAndNamespace),
catalogAndNamespace)
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]