Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/14616#discussion_r74588724
--- Diff:
sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/AnalysisSuite.scala
---
@@ -377,4 +377,43 @@ class AnalysisSuite extends AnalysisTest {
assertExpressionType(sum(Divide(Decimal(1), 2.0)), DoubleType)
assertExpressionType(sum(Divide(1.0, Decimal(2.0))), DoubleType)
}
+
+ test("test rule UnresolvedOrdinalSubstitution, replaces ordinal in order
by or group by") {
+ val a = testRelation2.output(0)
+ val b = testRelation2.output(1)
+ val conf = new SimpleCatalystConf(caseSensitiveAnalysis = true)
+
+ // Expression OrderByOrdinal is unresolved.
+ assert(!UnresolvedOrdinal(0).resolved)
+
+ // Tests order by ordinal, apply single rule.
+ val plan = testRelation2.orderBy(Literal(1).asc, Literal(2).asc)
+ comparePlans(
+ new UnresolvedOrdinalSubstitution(conf).apply(plan),
--- End diff --
actually we don't have unit test for single analyzer rule yet, this suite
is for the whole analyzer. We should write test like
```
val query = testRelation2.orderBy(Literal(1).asc, Literal(2).asc)
val expected = testRelation2.orderBy('a.asc, 'b.asc)
checkAnalysis(query, expected)
```
Or we can create a new suite and begin to test single analyzer rule
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]