MaxGekk opened a new pull request #31549:
URL: https://github.com/apache/spark/pull/31549


   ### What changes were proposed in this pull request?
   TODO
   
   ### Why are the changes needed?
   The changes fix the bug demonstrated by the example:
   1. There are partitioned parquet files (file format doesn't matter):
   ```
   
/private/var/folders/p3/dfs6mf655d7fnjrsjvldh0tc0000gn/T/spark-e09eae99-7ecf-4ab2-b99b-f63f8dea658d
   ├── _SUCCESS
   ├── part=-0
   │   └── part-00001-02144398-2896-4d21-9628-a8743d098cb4.c000.snappy.parquet
   └── part=AA
       └── part-00000-02144398-2896-4d21-9628-a8743d098cb4.c000.snappy.parquet
   ```
   placed to two partitions "AA" and **"-0"**.
   
   2. When reading them w/o specified schema:
   ```
   val df = spark.read.parquet(path)
   df.printSchema()
   root
    |-- id: integer (nullable = true)
    |-- part: string (nullable = true)
   ```
   the inferred type of the partition column `part` is the **string** type.
   3. The expected values in the column `part` are "AA" and "-0" but we get:
   ```
   df.show(false)
   +---+----+
   |id |part|
   +---+----+
   |0  |AA  |
   |1  |0   |
   +---+----+
   ```
   So, Spark returns **"0"** instead of **"-0"**.
   
   ### Does this PR introduce _any_ user-facing change?
   This PR can change query results.
   
   ### How was this patch tested?
   By running new test and existing test suites:
   ```
   $ build/sbt "test:testOnly *FileIndexSuite"
   $ build/sbt "test:testOnly *ParquetV1PartitionDiscoverySuite"
   $ build/sbt "test:testOnly *ParquetV2PartitionDiscoverySuite"
   ```


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

Reply via email to