yuqi1129 opened a new pull request, #14894:
URL: https://github.com/apache/gravitino/pull/14894

   ### What changes were proposed in this pull request?
   
   - A new Lance table, whether created, registered or declared, cannot use a 
location that equals, contains or is inside the location of another table in 
the same catalog. The check uses Gravitino metadata, runs before any storage 
access, and does not name the other table.
   - Rename the catalog property `lance.allow-external-table-purge` to 
`lance.allow-external-dataset-modification`. It has not been released yet.
   - Require this property for column and index changes on registered or 
declared tables. The catalog marks these tables with a new reserved property, 
`lance.dataset-adopted=true`. Without the property, Lance REST returns HTTP 406.
   - In create mode `CREATE`, reject an existing table name before any dataset 
is written.
   - If metadata registration fails after the dataset is created, do not call 
`Dataset.drop` on an external location. Log a warning and keep the data.
   
   ### Why are the changes needed?
   
   After #14870, the following paths still change or delete another table's 
data with the default catalog settings. All were reproduced locally on main 
with authorization enabled. The caller has `CREATE_TABLE` on its own schema 
only, and gets 403 when it describes the victim table.
   
   1. Create a table with a name the caller already owns. Set 
`x-lance-table-location` to the parent directory of another table's dataset. 
The request returns 409, but the failure cleanup drops the whole parent 
directory, including the other dataset.
   2. Register a table at another table's dataset location, then call 
`drop_columns`. The request returns 200 and the column is dropped from the 
other table's dataset.
   3. Declare a table at another table's dataset location and describe it. Then 
`drop_columns` succeeds in the same way. The describe step loads the schema and 
clears `lance.declared`, so a new marker is needed.
   4. Create a managed Lance table through the Gravitino API with `location` 
set to the parent directory of another table's dataset, then drop it. The drop 
deletes the other dataset. #14870 does not cover managed tables.
   
   The location check blocks all four inside one catalog. The adopted-dataset 
guard still applies when the other dataset belongs to a table in another 
catalog, or to no table. Location ownership across catalogs and storage 
authorization remain follow-up work in #14788.
   
   Refs #13696, #14788.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes.
   - Creating, registering or declaring a Lance table at a location that 
overlaps another table in the same catalog now fails with an 
`IllegalArgumentException` (HTTP 400 in Lance REST). Tables that already 
overlap are not changed.
   - The catalog property `lance.allow-external-table-purge` is renamed to 
`lance.allow-external-dataset-modification`.
   - By default, column and index changes on registered or declared tables are 
rejected (HTTP 406 in Lance REST). Tables created through `CreateTable` are not 
affected.
   - New reserved table property `lance.dataset-adopted`. Declared tables 
created before this change are not marked.
   - After a failed create, the dataset at an external location is kept and 
must be removed manually.
   
   ### How was this patch tested?
   
   - New unit tests in `TestLanceTableOperations`:
     - location normalization, and the overlap check for parent, same and child 
locations;
     - an existing name rejected before the dataset is written;
     - an external location kept after a conflict;
     - the adopted marker for register, declare and create;
     - alter rejected for adopted and legacy registered tables.
   - The new create and alter cases fail without the fix.
   - New cross-user cases in `LanceTableAuthorizationIT` for the four paths 
above.
   - `TestLanceTableOperations`, `TestPropertiesMetadata`, 
`TestGenericCatalogOperations`, `LanceTableAuthorizationIT`, 
`LanceRESTServiceIT`, `LanceFormatBoundaryIT` and 
`CatalogGenericCatalogLanceIT` (embedded) pass. Scoped Spotless passes.
   


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

Reply via email to