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


   ### What changes were proposed in this pull request?
   1. Preprocess partition specs `ResolvePartitionSpec`, and convert partition 
names according to the partition schema and the SQL config 
`spark.sql.caseSensitive`. In the PR, I propose to invoke 
`normalizePartitionSpec` for that. The function is used in DSv1 commands.
   2. Move `normalizePartitionSpec()` from 
`sql/core/.../datasources/PartitioningUtils` to 
`sql/catalyst/.../util/PartitioningUtils` to use it in Catalyst's rule 
`ResolvePartitionSpec`
   
   ### Why are the changes needed?
   DSv1 commands like `ALTER TABLE .. ADD PARTITION` and `ALTER TABLE .. DROP 
PARTITION` respect the SQL config `spark.sql.caseSensitive` while resolving 
partition specs. For example:
   ```sql
   spark-sql> CREATE TABLE tbl1 (id bigint, data string) USING parquet 
PARTITIONED BY (id);
   spark-sql> ALTER TABLE tbl1 ADD PARTITION (ID=1);
   spark-sql> SHOW PARTITIONS tbl1;
   id=1
   ```
   The same command fails on V2 Table catalog with error:
   ```
   AnalysisException: Partition key ID not exists
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. After the changes, partition spec resolution works as for DSv1 (without 
the exception showed above).
   
   ### How was this patch tested?
   By running `AlterTablePartitionV2SQLSuite`.


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