https://github.com/apache/spark
Revision 35953cd630dba5ff35b42a46ab63347805837275 authored by Bo Zhang on 24 February 2022, 07:07:38 UTC, committed by Wenchen Fan on 24 February 2022, 07:08:08 UTC
### What changes were proposed in this pull request?
After https://github.com/apache/spark/pull/28527, we change to create table under the database location when the table location is relative. However the criteria to determine if a table location is relative/absolute is `URI.isAbsolute`, which basically checks if the table location URI has a scheme defined. So table URIs like `/table/path` are treated as relative and the scheme and authority of the database location URI are used to create the table. For example, when the database location URI is `s3a://bucket/db`, the table will be created at `s3a://bucket/table/path`, while it should be created under the file system defined in `SessionCatalog.hadoopConf` instead.

This change fixes that by treating table location as absolute when the first letter of its path is slash.

This also applies to alter table.

### Why are the changes needed?
This is to fix the behavior described above.

### Does this PR introduce _any_ user-facing change?
Yes. When users try to create/alter a table with a location that starts with a slash but without a scheme defined, the table will be created under/altered to the file system defined in `SessionCatalog.hadoopConf`, instead of the one defined in the database location URI.

### How was this patch tested?
Updated unit tests.

Closes #35591 from bozhang2820/spark-31709-3.2.

Authored-by: Bo Zhang <bo.zhang@databricks.com>
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
(cherry picked from commit 915f0cc5a594da567b9e83fba05a3eb7897c739c)
Signed-off-by: Wenchen Fan <wenchen@databricks.com>
1 parent 687494a
History
Tip revision: 35953cd630dba5ff35b42a46ab63347805837275 authored by Bo Zhang on 24 February 2022, 07:07:38 UTC
[SPARK-38236][SQL][3.2][3.1] Check if table location is absolute by "new Path(locationUri).isAbsolute" in create/alter table
Tip revision: 35953cd

README.md

back to top