wangyum opened a new pull request #31993:
URL: https://github.com/apache/spark/pull/31993
### What changes were proposed in this pull request?
This pr add workaround(`set
spark.sql.optimizer.nestedSchemaPruning.enabled=false`) to error message when
`OrcUtils.requestedColumnIds` fails. For example:
```scala
spark.sql(
"""
|CREATE TABLE `t1` (
| `_col0` INT,
| `_col1` STRING,
| `_col2` STRUCT<`c1`: STRING, `c2`: STRING, `c3`: STRING, `c4`:
BIGINT>,
| `_col3` STRING)
|USING orc
|PARTITIONED BY (_col3)
|""".stripMargin)
spark.sql("INSERT INTO `t1` values(1, '2', null, '2021-02-01')")
spark.sql("SELECT _col2.c1, _col0 FROM `t1` WHERE _col3 = '2021-02-01'").show
```
Before this pr:
```
java.lang.AssertionError: assertion failed: The given data schema
struct<_col0:int,_col2:struct<c1:string>> has less fields than the actual ORC
physical schema, no idea which columns were dropped, fail to read.
at scala.Predef$.assert(Predef.scala:223)
at
org.apache.spark.sql.execution.datasources.orc.OrcUtils$.requestedColumnIds(OrcUtils.scala:160)
```
After this pr:
```
java.lang.AssertionError: assertion failed: The given data schema
struct<_col0:int,_col2:struct<c1:string>> has less fields than the actual ORC
physical schema, no idea which columns were dropped, fail to read. Try to
disable spark.sql.optimizer.nestedSchemaPruning.enabled to workaround this
issue.
at scala.Predef$.assert(Predef.scala:223)
at
org.apache.spark.sql.execution.datasources.orc.OrcUtils$.requestedColumnIds(OrcUtils.scala:160)
```
### Why are the changes needed?
Add a workaround.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Manual test
--
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]