Skip to content

[#11893] fix(lance): Add external table guard to deregisterTable#11896

Open
jiangxt2 wants to merge 1 commit into
apache:mainfrom
jiangxt2:fix/lance-deregister-external-check
Open

[#11893] fix(lance): Add external table guard to deregisterTable#11896
jiangxt2 wants to merge 1 commit into
apache:mainfrom
jiangxt2:fix/lance-deregister-external-check

Conversation

@jiangxt2

@jiangxt2 jiangxt2 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Add a guard in GravitinoLanceTableOperations.deregisterTable() that rejects
non-external (managed) tables with UnsupportedOperationException before calling
dropTable.

The guard reads PROPERTY_EXTERNAL from the loaded table properties using the same
Optional.ofNullable + Boolean.parseBoolean pattern as the downstream
LanceTableOperations.dropTable(), ensuring consistent behavior across both layers.

Why are the changes needed?

deregisterTable() delegates to dropTable(), which for managed tables deletes the
underlying Lance dataset — violating the interface contract ("It will not delete the
underlying lance data").

The current code is safe only because all REST-created tables are forced to
PROPERTY_EXTERNAL=true (lines 190, 221, 248). This is an implementation coincidence,
not a semantic guarantee. If a managed table path is ever introduced, deregisterTable
would silently delete physical data.

The guard converts this implicit assumption into an explicit invariant: refuse
non-external tables rather than risk silent data loss. This mirrors
HiveCatalogOperations.purgeTable(), which throws UnsupportedOperationException for
external tables — same exception type, opposite direction (purge rejects external
tables; deregister rejects managed tables).

Fix: #11893

Does this PR introduce any user-facing change?

deregisterTable now throws UnsupportedOperationException for managed tables, which
LanceExceptionMapper maps to HTTP 406 (Not Acceptable). Clients would receive an
explicit error instead of silent data loss. This path is currently unreachable via the
REST API (all REST tables are external), so no existing clients are affected.

How was this patch tested?

  • Unit test testDeregisterTableRejectsManagedTable mocks a managed table (empty
    properties) and verifies:
    • UnsupportedOperationException is thrown
    • dropTable is never called on the catalog
  • Existing integration test LanceRESTServiceIT covers the external table happy path
    (deregister preserves physical data).

deregisterTable() delegates to dropTable(), which deletes underlying
Lance data for managed tables. Add a guard that rejects non-external
tables with UnsupportedOperationException, preventing silent data
loss if a managed table path is ever introduced.

Signed-off-by: jiangxt2 <jiangxt2@vip.qq.com>
@FANNG1

FANNG1 commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

LGTM

@github-actions

github-actions Bot commented Jul 4, 2026

Copy link
Copy Markdown

Code Coverage Report

Overall Project 67.45% -0.16% 🟢
Files changed 0.0% 🔴

Module Coverage
aliyun 1.72% 🔴
api 46.52% 🟢
authorization-common 85.96% 🟢
aws 42.04% 🟢
azure 2.47% 🔴
catalog-common 9.92% 🔴
catalog-fileset 80.23% 🟢
catalog-glue 66.91% 🟢
catalog-hive 79.42% 🟢
catalog-jdbc-clickhouse 80.55% 🟢
catalog-jdbc-common 44.22% 🟢
catalog-jdbc-doris 80.28% 🟢
catalog-jdbc-hologres 54.03% 🟢
catalog-jdbc-mysql 79.23% 🟢
catalog-jdbc-oceanbase 80.91% 🟢
catalog-jdbc-postgresql 82.29% 🟢
catalog-jdbc-starrocks 78.51% 🟢
catalog-kafka 77.01% 🟢
catalog-lakehouse-generic 58.53% 🟢
catalog-lakehouse-hudi 79.1% 🟢
catalog-lakehouse-iceberg 85.94% 🟢
catalog-lakehouse-paimon 84.25% 🟢
catalog-model 77.72% 🟢
cli 44.51% 🟢
client-java 78.01% 🟢
common 50.17% 🟢
core 82.58% 🟢
filesystem-hadoop3 77.3% 🟢
flink 0.0% 🔴
flink-common 47.09% 🟢
flink-runtime 0.0% 🔴
gcp 14.12% 🔴
hadoop-auth 66.67% 🟢
hadoop-common 12.7% 🔴
hive-metastore-common 53.29% 🟢
iceberg-common 58.3% 🟢
iceberg-rest-server 74.01% 🟢
idp-basic 85.71% 🟢
integration-test-common 0.0% 🔴
jobs 66.17% 🟢
lance-common 20.67% -6.18% 🔴
lance-rest-server 64.84% 🟢
lineage 53.02% 🟢
optimizer 83.17% 🟢
optimizer-api 21.95% 🔴
server 85.94% 🟢
server-common 74.62% 🟢
spark 28.57% 🔴
spark-common 46.01% 🟢
tencent 69.84% 🟢
trino-connector 40.29% 🟢
Files
Module File Coverage
lance-common GravitinoLanceTableOperations.java 0.0% 🔴

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Lance deregisterTable relies on coincidence (all tables external) for correctness

2 participants