apache / polaris

Apache Polaris, the interoperable, open source catalog for Apache Iceberg
https://polaris.apache.org/
Apache License 2.0
1.17k stars 130 forks source link

Fix Azure path comparison when filePath is root ("/") #385

Closed tzuan16 closed 1 month ago

tzuan16 commented 1 month ago

Description

The AzureLocation.isChildOf method is currently broken if the parent path points to the root of the container (e.g. abfss://container@acc.blob.core.windows.net or abfss://container@acc.blob.core.windows.net/). The filePath of the path in this case would be parsed as / since we always add a "trailing slash". Now if the comparing child path looks something like abfss://container@acc.blob.core.windows.net/some/file/path/metadata, the filePath would be parsed as some/file/path/metadata/ after applying the trailing slash, leading to the failure of the childFilePath.startsWith(parentFilePath) check since the childFilePath doesn't start with a slash.

Fix is to always ensure a leading slash on top of ensuring a trailing slash.

Type of change

Please delete options that are not relevant.

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

Test Configuration:

Checklist:

Please delete options that are not relevant.