Skip to content

Implement dropTable for UnityV2 - #124481

Merged
asya-ch merged 6 commits into
masterfrom
asya/drop
Oct 21, 2026
Merged

asya-ch merged 6 commits into
masterfrom
asya/drop

Conversation

@asya-ch

@asya-ch asya-ch commented Oct 7, 2026 •

Copy link
Copy Markdown
Collaborator

Closes: #124438

Changelog category (leave one):

  • Experimental Feature

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Support DROP TABLE in the DataLakeCatalog database engine with the Unity catalog v2.


Workflow [PR]
Sync PR [sync-upstream/pr/124481]

Version info

  • Merged into: 26.11.1.379-master (included in 26.11 and later)

@asya-ch
asya-ch requested a review from scanhex12 October 7, 2026 20:25
@clickhouse-gh

clickhouse-gh Bot commented Oct 7, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [3f8ef51]

Summary: ✅


AI Review

Summary

The PR implements DROP TABLE for Unity v2 in DataLakeCatalog, checks that iceberg_delete_data_on_drop matches the catalog's deletion behavior, and handles missing-table responses. Reviewed head 3f8ef517b72d40a116ac2e773d7f17b8b7d6ad47, including all prior discussion. No new implementation defect found; one previously raised regression-coverage concern remains.

Findings

⚠️ Majors

  • src/Databases/DataLake/UnityV2Catalog.cpp:473 — The managed-table data-preservation safeguard lacks regression coverage. [dismissed by author -- https://github.com/Implement dropTable for UnityV2 #124481#discussion_r4318641011] The author reports successful manual testing, but test_drop_table still exercises only an EXTERNAL table. Replacing the classification with data_will_be_deleted = false would pass that test while allowing a MANAGED table's data to be deleted with the default setting. Reuse the existing cluster/proxy for a MANAGED response: with iceberg_delete_data_on_drop = 0, assert SUPPORT_IS_DISABLED and no catalog DELETE; with 1, assert successful deletion.
Missing context / blind spots
  • ⚠️ No local build or integration suite was run; managed-table behavior was assessed from the current code and the author's manual-test report.
Final Verdict

⚠️ Request changes — Add the focused managed-table regression case above. This concern already has a thread, so no duplicate inline finding or thread reply was posted.

@clickhouse-gh clickhouse-gh Bot added the pr-experimental Experimental Feature label Oct 7, 2026
}
catch (const DB::HTTPException & e)
{
if (e.getHTTPStatus() != Poco::Net::HTTPResponse::HTTP_NOT_FOUND)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This 404 swallow is too broad for Unity. existsTable in this file already documents that the tables endpoint also returns 404 when the schema or catalog itself is missing, so returning false here regresses broken-namespace lookups into UNKNOWN_TABLE / “does not exist” instead of surfacing the real catalog error. Please mirror the existsTable logic here: on 404, call checkNamespaceExists(schema_name) before treating it as an absent table.

@asya-ch asya-ch Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "schema does not exist" error message is very marginally better than the "table does not" error message and is not worth the extra request.

@clickhouse-gh clickhouse-gh Bot added the comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. label Oct 7, 2026
@asya-ch

asya-ch commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator Author

Manual testing against Databricks

CREATE DATABASE unity
ENGINE = DataLakeCatalog('https://dbc-xxxxx.cloud.databricks.com/api/2.1/unity-catalog')
SETTINGS catalog_type = 'unity', use_unity_catalog_v2 = 1,
         warehouse = 'asya-test-catalog', catalog_credential = 'dapi...';

Dropped three kinds of tables; in each case DROP TABLE returned Ok, the table disappeared from SHOW TABLES, a subsequent SELECT gave UNKNOWN_TABLE, and the table was confirmed gone from Unity via Databricks:

DROP TABLE unity.`default.ch_iceberg_2`;   -- CH-created external Iceberg (IcebergS3)
DROP TABLE unity.`default.drop_managed`;   -- Databricks-created managed Iceberg
DROP TABLE unity.`default.ch_created`;     -- CH-created Delta

Nonexistent table and schema:

DROP TABLE unity.`default.nope`;                -- UNKNOWN_TABLE: Table unity.`default.nope` does not exist
DROP TABLE IF EXISTS unity.`default.nope`;      -- Ok.
DROP TABLE unity.`no_such_schema.t`;            -- UNKNOWN_TABLE: Table unity.`no_such_schema.t` does not exist
DROP TABLE IF EXISTS unity.`no_such_schema.t`;  -- Ok.

@Diskein Diskein self-assigned this Oct 15, 2026
checkNamespaceExists(namespace_name);
}

void UnityV2Catalog::dropTable(const String & namespace_name, const String & table_name, bool /*delete_data*/) const

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK this delete will drop the data, but we ignore delete_data flag, shouldn't we support it here?

@asya-ch asya-ch Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, we should be more careful with the delete_data flag.

Unity supports both managed and external tables. It will drop the data for managed and leave it for external. I think, if possible, we should check if the table is managed or external, and then:

  1. If it's external, ignore delete_data.
  2. If it's managed and delete_data=true, continue.
  3. If it's managed and delete_data=false, throw. This is the S3 tables approach.

WDYT?

@asya-ch asya-ch Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, while trying to test the behavior, I discovered some bugs in the flag wiring. I'll fix them in #126110.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, we should be more careful with the delete_data flag.

Unity supports both managed and external tables. It will drop the data for managed and leave it for external. I think, if possible, we should check if the table is managed or external, and then:

  1. If it's external, ignore delete_data.
  2. If it's managed and delete_data=true, continue.
  3. If it's managed and delete_data=false, throw. This is the S3 tables approach.

WDYT?

Sounds reasonable

@Diskein Diskein left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!


user = unique_name("v2_drop_user")
node.query(f"CREATE USER {user}")
assert "ACCESS_DENIED" in node.query_and_get_error(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure that we should run drop without grants first, or there was a bug as well?

LOG_DEBUG(log, "Unity table {} does not exist", full_table_name);
return false;
}
const Poco::JSON::Object::Ptr & object = json.extract<Poco::JSON::Object::Ptr>();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: 'const auto &' would be shorter

@clickhouse-gh

clickhouse-gh Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 3f8ef517b with master c7531f5ee (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes

programs/clickhouse-stripped: smaller than the master baseline by the known offset between the two builds, so the difference is not shown. A delta that differs from the offset by more than 50% of it is shown, in either direction.

The official master build is compiled with -g and a pull request build is not, and XRay counts debug instructions towards its instrumentation threshold, so master instruments thousands of functions more and its binary is ~0.4% larger no matter what the pull request does.

Object file sizes

11 object files changed (+25.42 KiB total), 0 added.

Object file Master PR Δ
src/CMakeFiles/dbms.dir/Databases/DataLake/UnityV2Catalog.cpp.o 649.55 KiB 676.28 KiB +26.73 KiB (+4.11%)

719 more object files are built by the master warmup baseline only (it builds every object-file target, a pull request build only clickhouse-bundle) and not compared.

Compile time of recompiled translation units

8 translation units recompiled, 30 s compile time in total, 8 of them have a recent master baseline.

Job report

@asya-ch
asya-ch enabled auto-merge October 20, 2026 23:17
@asya-ch
asya-ch added this pull request to the merge queue Oct 21, 2026
Merged via the queue into master with commit 7a18fa4 Oct 21, 2026
180 checks passed
@asya-ch
asya-ch deleted the asya/drop branch October 21, 2026 03:09
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 21, 2026
groeneai added a commit to groeneai/ClickHouse that referenced this pull request Oct 22, 2026
UnityV2Catalog now implements dropTable (ClickHouse#124481): for an external table it
refuses `iceberg_delete_data_on_drop = 1` with SUPPORT_IS_DISABLED before
sending anything, instead of the base ICatalog NOT_IMPLEMENTED. The file and
row assertions are unchanged; a mutant that sends Unity down the client-side
delete path still fails them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@clickhouse-gh clickhouse-gh Bot added comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... and removed comp-datalake Data lake table formats (Iceberg/Delta/Hudi) integration. labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp-datalake-catalogs Data lake catalogs: the DataLakeCatalog database engine and its catalog clients - Iceberg REST, A... pr-experimental Experimental Feature pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unity v2 DataLakeCatalog: DROP TABLE on an Iceberg table returns "dropTable is not implemented"

3 participants