fix: mark Lance HMS tables as EXTERNAL to prevent data purge on DROP#142
Open
xingsuo-zbz wants to merge 1 commit into
Open
fix: mark Lance HMS tables as EXTERNAL to prevent data purge on DROP#142xingsuo-zbz wants to merge 1 commit into
xingsuo-zbz wants to merge 1 commit into
Conversation
## Summary - Add `parameters.EXTERNAL=TRUE` in `Hive2Util`/`Hive3Util` `createLanceTableParams` - HMS's `MetaStoreUtils.isExternalTable()` reads `parameters.EXTERNAL`, not `Table.tableType`. Without this parameter, `DROP TABLE` (Hive CLI, Spark session catalog, HMS's own `drop_table_core`) treats the table as MANAGED and purges the Lance dataset at the storage location — even though `tableType` was already set to `EXTERNAL_TABLE`. - The docs already require Lance HMS tables to be EXTERNAL: https://lance.org/format/namespace/supported-catalogs/hive2/ ## Test plan - New `testDeclareTableMarksTableAsExternal` (hive2 + hive3) — asserts `tableType=EXTERNAL_TABLE` AND `parameters.EXTERNAL=TRUE` are both persisted in HMS after `declareTable`. - New `testDropTablePreservesDataForDeclaredTable` (hive2 + hive3) — declares a table with a data file at its location, drops it via raw HMS `dropTable(deleteData=true)` (the same call path used by Hive CLI / Spark `DROP TABLE`), asserts the data file survives. - Reverting the fix in either `Hive2Util`/`Hive3Util` causes the drop-preserves-data test to fail — the marker file gets purged. - `mvn test -pl lance-namespace-hive2,lance-namespace-hive3 -am`: 31 tests pass, 0 failures.
Author
|
Hi, @jackye1995 please take a look at this PR. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
parameters.EXTERNAL=TRUEinHive2Util/Hive3UtilcreateLanceTableParamsMetaStoreUtils.isExternalTable()readsparameters.EXTERNAL, notTable.tableType. Without this parameter,DROP TABLE(Hive CLI, Spark session catalog, HMS's owndrop_table_core) treats the table as MANAGED and purges the Lance dataset at the storage location — even thoughtableTypewas already set toEXTERNAL_TABLE.Test plan
testDeclareTableMarksTableAsExternal(hive2 + hive3) — assertstableType=EXTERNAL_TABLEANDparameters.EXTERNAL=TRUEare both persisted in HMS afterdeclareTable.testDropTablePreservesDataForDeclaredTable(hive2 + hive3) — declares a table with a data file at its location, drops it via raw HMSdropTable(deleteData=true)(the same call path used by Hive CLI / SparkDROP TABLE), asserts the data file survives.Hive2Util/Hive3Utilcauses the drop-preserves-data test to fail — the marker file gets purged.mvn test -pl lance-namespace-hive2,lance-namespace-hive3 -am: 31 tests pass, 0 failures.