sunchao opened a new issue, #7849: URL: https://github.com/apache/datafusion-comet/issues/7849
### Describe the bug A V1 Parquet relation shared through a global temporary view can belong to a different session from the one querying it. Spark [passes the relation's session](https://github.com/apache/spark/blob/v4.1.3/sql/core/src/main/scala/org/apache/spark/sql/execution/DataSourceScanExec.scala#L717-L730) to [the reader](https://github.com/apache/spark/blob/v4.1.3/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/parquet/ParquetFileFormat.scala#L176-L198). Comet uses the planning session for case sensitivity and filter pushdown. This can change a returned value or raise on a row group Spark skips. [Reported in the review of #7731](https://github.com/apache/datafusion-comet/pull/7731#discussion_r4793705610). Both examples follow from the code on main at `ef771f2` and predate that PR. ### Steps to reproduce Use Spark 4.1, UTC, V1 Parquet and nested predicate pushdown for Parquet. Write this [two-row fixture](https://github.com/apache/datafusion-comet/blob/2f87d1c8a3df14267ceaab9c420f430984c7d0a6/spark/src/test/scala/org/apache/comet/parquet/ParquetReadSuite.scala#L655-L683) in one row group with statistics. Both timestamps use INT64 annotated as TIMESTAMP_MILLIS. The table gives the raw millisecond values. | id | match_id | ts | s.k | s.ts | | --- | --- | --- | --- | --- | | 0 | 0 | 0 | 0 | 0 | | 1 | 0 | 9223372036854776 | 1 | 9223372036854776 | Create the views in `val owner = spark.newSession()`. In the original session, plan and collect each query separately with Comet disabled and with the Comet native scan enabled. **Case sensitivity** Keep pushdown on in both sessions. Set `spark.sql.caseSensitive` to true in the owner and false in the querying session. ```scala owner.read.schema("id long, match_id long, TS timestamp").parquet(path) .createOrReplaceGlobalTempView("millis_case") spark.sql("SELECT TS FROM global_temp.millis_case WHERE id <=> match_id").collect() ``` Spark treats uppercase `TS` as missing and returns one null. Comet matches lowercase `ts` and returns the Unix epoch. Selecting the other row hides the difference because its timestamp overflows and the filtered Comet scan also returns null. **Filter pushdown** Match the case settings. Set `spark.sql.parquet.filterPushdown` to true in the owner and false in the querying session. ```scala owner.read.parquet(path).createOrReplaceGlobalTempView("millis_prune") spark.sql("SELECT s.ts FROM global_temp.millis_prune WHERE s.k < 0").collect() ``` Spark skips the row group because its minimum `s.k` is zero. Comet omits the scan predicate and treats the scan as unfiltered. It raises `long overflow` on the second row before applying the residual filter. ### Expected behavior Return one null for the first query and no rows for the second. Match the relation owner's reader settings while retaining the querying session for SQL analysis. Cover both directions of each mismatch and verify which reader executes. ### Additional context [CometNativeScan](https://github.com/apache/datafusion-comet/blob/ef771f2b875ece9a79b3295cd5cc2db87275c04c/spark/src/main/scala/org/apache/comet/serde/operator/CometNativeScan.scala#L277-L287) passes `scan.conf` into [filter serialization](https://github.com/apache/datafusion-comet/blob/ef771f2b875ece9a79b3295cd5cc2db87275c04c/spark/src/main/scala/org/apache/comet/serde/operator/CometNativeScan.scala#L344-L355) and [field matching](https://github.com/apache/datafusion-comet/blob/ef771f2b875ece9a79b3295cd5cc2db87275c04c/spark/src/main/scala/org/apache/comet/serde/operator/CometNativeScan.scala#L420-L424). With no filters, the [planner](https://github.com/apache/datafusion-comet/blob/ef771f2b875ece9a79b3295cd5cc2db87275c04c/native/core/src/execution/planner.rs#L526-L533) selects [checked conversion](https://github.com/apache/datafusion-comet/blob/ef771f2b875ece9a79b3295cd5cc2db87275c04c/native/core/src/parquet/parquet_exec.rs#L125-L131). #7731 guards its additional overflow check. T he underlying scan settings need a separate fix. -- 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]
