cloud-fan commented on a change in pull request #35936:
URL: https://github.com/apache/spark/pull/35936#discussion_r835342575
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
##########
@@ -909,6 +912,53 @@ abstract class SQLViewSuite extends QueryTest with
SQLTestUtils {
}
}
+ test("CurrentOrigin is correctly set in and out of the View") {
+ withTable("t") {
+ Seq((1, 1), (2, 2)).toDF("a",
"b").write.format("parquet").saveAsTable("t")
+ Seq("", "temp")
+ withView("v") {
+ val viewText = "SELECT a + b c FROM t"
+ sql(
+ s"""
+ |CREATE VIEW v AS
+ |-- the body of the view
+ |$viewText
+ |""".stripMargin)
+ val plan = sql("select c / 2.0D d from v").logicalPlan
+ val add = plan.collectFirst {
+ case Project(Seq(Alias(a: Add, _)), _) =>
+ a
+ }
+ assert(add.isDefined)
+ val expectedAddOrigin = Origin(
+ line = Some(1),
+ startPosition = Some(7),
+ startIndex = Some(7),
+ stopIndex = Some(11),
+ sqlText = Some("SELECT a + b c FROM t"),
+ objectType = Some("VIEW"),
+ objectName = Some("default.v")
+ )
+ assert(add.get.origin == expectedAddOrigin)
+
+ val divide = plan.collectFirst {
+ case Project(Seq(Alias(d: Divide, _)), _) =>
+ d
Review comment:
```suggestion
case Project(Seq(Alias(d: Divide, _)), _) => d
```
--
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]