1. [SPARK-23523][SQL][BACKPORT-2.3] Fix the incorrect result caused by the (commit: 33ba8db8d8c8bf388606a6f5e34b082469038205) (details)
Commit 33ba8db8d8c8bf388606a6f5e34b082469038205 by gatorsmile
[SPARK-23523][SQL][BACKPORT-2.3] Fix the incorrect result caused by the
rule OptimizeMetadataOnlyQuery
This PR is to backport and to Spark 2.3 branch
## What changes were proposed in this pull request?
```Scala val tablePath = new
Seq(("a", "b", "c", "d", "e")).toDF("cOl1", "cOl2", "cOl3", "cOl4",
val df ="CoL1", "CoL5",
It generates a wrong result.
We have a bug in the rule `OptimizeMetadataOnlyQuery `. We should
respect the attribute order in the original leaf node. This PR is to fix
## How was this patch tested? Added a test case
Author: Xingbo Jiang <> Author: gatorsmile
Closes #20763 from gatorsmile/backport23523.
(commit: 33ba8db8d8c8bf388606a6f5e34b082469038205)
The file was modifiedsql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/LocalRelation.scala (diff)
The file was modifiedsql/core/src/main/scala/org/apache/spark/sql/execution/OptimizeMetadataOnlyQuery.scala (diff)
The file was modifiedsql/core/src/main/scala/org/apache/spark/sql/execution/datasources/HadoopFsRelation.scala (diff)
The file was modifiedsql/core/src/test/scala/org/apache/spark/sql/execution/OptimizeMetadataOnlyQuerySuite.scala (diff)