snmvaughan opened a new issue, #7819:
URL: https://github.com/apache/datafusion-comet/issues/7819

   ### Describe the bug
   
   [SPARK-60262](https://issues.apache.org/jira/browse/SPARK-60262) 
(apache/spark#59510) is in Spark 4.0.5, 4.1.4, 4.2.1 and 4.3.0. With 
`spark.sql.parquet.fieldId.read.enabled=true`, the Parquet reader now fails the 
read with `PARQUET_FIELD_REQUESTED_MORE_THAN_ONCE` when two requested fields of 
one group, the root or a struct, resolve to the same Parquet field. That covers 
a field matched by id plus one matched by name, and two fields with the same 
id. Earlier releases read such a file without an error.
   
   The native Parquet scan resolves these fields itself (#6994, #7196). It 
gives the file column to the id match and NULL to the name match, so on a Spark 
with SPARK-60262 Spark fails the read where Comet returns rows.
   
   ### Steps to reproduce
   
   In a `CometTestBase` suite on Spark 4.1.4 (`-Pspark-4.1 
-Dspark.version=4.1.4`):
   
   ```scala
   def withId(id: Int) =
     new MetadataBuilder().putLong(ParquetUtils.FIELD_ID_METADATA_KEY, 
id.toLong).build()
   withSQLConf(SQLConf.PARQUET_FIELD_ID_WRITE_ENABLED.key -> "true") {
     spark
       .createDataFrame(
         spark.sparkContext.parallelize(Seq(Row(7L))),
         new StructType().add("A", LongType, true, withId(1)))
       .write
       .parquet(path)
   }
   val readSchema = new StructType()
     .add("x", LongType, true, withId(1))
     .add("a", LongType, true)
   withSQLConf(SQLConf.PARQUET_FIELD_ID_READ_ENABLED.key -> "true") {
     spark.read.schema(readSchema).parquet(path).collect()
   }
   ```
   
   `x` selects the file column `A` by its id, and `a` selects it by name, 
because the match is case-insensitive by default.
   
   ### Expected behavior
   
   The read fails as it does in Spark, with the same error:
   
   ```
   [FAILED_READ_FILE.NO_HINT] Encountered error while reading file ...
   Caused by: org.apache.spark.SparkRuntimeException: 
[PARQUET_FIELD_REQUESTED_MORE_THAN_ONCE]
   Requested fields `x`, `a` resolve to the same Parquet field `A`, which can 
be read only once. ...
   ```
   
   The Spark releases without SPARK-60262 keep their behavior.
   
   ### Additional context
   
   The conflict depends on the file's own schema, so scan planning cannot see 
it, and nothing in the plan tells Comet which behavior applies. The fix has to 
pick it by Spark version, as #7171 and #7522 do for other Spark fixes. The 
`Parquet field claims` tests added in #7196 compare Comet with Spark's own 
read, so on a Spark with SPARK-60262 they need to expect Spark's error instead 
of a result.
   
   #7207 is a related gap at the root: the shape of a root field that loses its 
file column is not checked yet.
   
   I have a fix and will open a pull request for it.
   


-- 
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]

Reply via email to