Skip to content

fix: store Lance tables in HMS as external tables#146

Merged
jackye1995 merged 1 commit into
lance-format:mainfrom
jackye1995:fix-hive2-external-table
Jul 3, 2026
Merged

fix: store Lance tables in HMS as external tables#146
jackye1995 merged 1 commit into
lance-format:mainfrom
jackye1995:fix-hive2-external-table

Conversation

@jackye1995

Copy link
Copy Markdown
Contributor

Fixes #145

HMS silently rewrites tableType=EXTERNAL_TABLE to MANAGED_TABLE when the EXTERNAL=TRUE table parameter is not set (ObjectStore.convertToMTable in Hive 2.3.9 and 3.1.3), so tables registered by Hive2Namespace/Hive3Namespace ended up as managed tables. DropTable purged data only because of this: HMS deletes data on drop only for managed tables.

Changes:

  • Set the EXTERNAL=TRUE table parameter alongside tableType=EXTERNAL_TABLE in Hive2Namespace and Hive3Namespace, so HMS stores and reports EXTERNAL_TABLE.
  • Since HMS never deletes data for external tables, doDropTable now drops metadata with deleteData=false and deletes the Lance dataset explicitly (best-effort Dataset.drop, mirroring GlueNamespace). This keeps purge working for pre-existing tables stored as managed, and deregisterTable still preserves data.
  • Update hive2.md/hive3.md: document the EXTERNAL=TRUE requirement, correct the DropTable description, and align Lance table identification with the code (parameter-based, so pre-fix tables stay recognized).
  • Add regression tests against the embedded metastore: table stored as external in HMS, drop purges data, deregister keeps data, declared-only drop succeeds.

HMS silently rewrites tableType EXTERNAL_TABLE to MANAGED_TABLE when the
EXTERNAL=TRUE table parameter is not set. Set the parameter in Hive2/Hive3
table creation, and since HMS never deletes data for external tables, drop
metadata only and delete the Lance dataset explicitly on dropTable.

Fixes lance-format#145
@github-actions github-actions Bot added bug Something isn't working java docs labels Jul 3, 2026
@jackye1995 jackye1995 merged commit 931ba8a into lance-format:main Jul 3, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working docs java

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Is a Lance table on HMS2 a MANAGED_TABLE or an EXTERNAL_TABLE?

1 participant