Skip to content

Move metadata queries to DuckLakeMetadataManager::Query/Execute#895

Draft
qsliu2017 wants to merge 5 commits into
duckdb:mainfrom
qsliu2017:move-metadata-queries
Draft

Move metadata queries to DuckLakeMetadataManager::Query/Execute#895
qsliu2017 wants to merge 5 commits into
duckdb:mainfrom
qsliu2017:move-metadata-queries

Conversation

@qsliu2017
Copy link
Copy Markdown
Contributor

@qsliu2017 qsliu2017 commented Mar 24, 2026

Summary

  • Move all metadata query execution from DuckLakeTransaction to DuckLakeMetadataManager (~70 call sites in ducklake_metadata_manager.cpp, 3 in ducklake_flush_inlined_data.cpp), so DuckLakeTransaction::Query is now only for DuckDB-internal queries
  • Move template replacement (FillSnapshotArgs, FillSnapshotCommitArgs, FillCatalogArgs) from DuckLakeTransaction to DuckLakeMetadataManager as static helpers
  • Reshape Query/Execute signatures: add (string) and (DuckLakeSnapshot, string) overloads on DuckLakeMetadataManager, remove DuckLakeTransaction::Query(DuckLakeSnapshot, string)
  • Update PostgresMetadataManager to override the new no-snapshot Query/Execute signatures, and add overrides for ListAggregation, CastStatsToTarget, CastColumnToTarget, LoadTags, LoadInlinedDataTables, LoadMacroImplementations, TransformInlinedData

Part of the work from #731 (item 2). This makes it easier for custom metadata managers (e.g. pg_ducklake) to override query execution.

🤖 Generated with Claude Code

@qsliu2017 qsliu2017 marked this pull request as draft March 24, 2026 10:01
@qsliu2017 qsliu2017 force-pushed the move-metadata-queries branch from 5e1bd18 to f0c7a7c Compare March 24, 2026 10:05
DuckLakeTransaction::Query now only handles DuckDB-internal queries
(ATTACH, duckdb_secrets, read_blob, etc). All metadata queries go
through DuckLakeMetadataManager::Query (SELECT) or Execute (mutations).

- Add FillSnapshotArgs, FillSnapshotCommitArgs, FillCatalogArgs static
  helpers to DuckLakeMetadataManager for template replacement
- Add Query/Execute overloads: (string) and (DuckLakeSnapshot, string)
- Remove DuckLakeTransaction::Query(DuckLakeSnapshot, string) overload
- Update ~70 call sites in ducklake_metadata_manager.cpp
- Update 3 call sites in ducklake_flush_inlined_data.cpp
- Update PostgresMetadataManager to match new signatures

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
qsliu2017 and others added 2 commits April 16, 2026 12:28
Resolve conflicts to maintain metadata query routing through
DuckLakeMetadataManager::Query/Execute instead of direct
DuckLakeTransaction::Query calls. Incorporate upstream additions:
logging/timing in Transaction::Query, partitioned flush logic,
roaring bitmap deletion vectors, ORDER BY in inlined data reads,
and improved error handling.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Use GenerateUUID() instead of SQL UUID() for schema initialization,
which is not available on all metadata backends (e.g. Postgres).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qsliu2017 qsliu2017 force-pushed the move-metadata-queries branch from 0e5a03b to e23c673 Compare April 16, 2026 06:28
Replace DuckDB-specific LIST(STRUCT_PACK(...)) with the virtual
ListAggregation method so Postgres gets json_agg(json_build_object(...)).
Add LoadInlinedDeletions virtual for parsing the result (DuckDB uses
ListValue/StructValue, Postgres uses yyjson).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@qsliu2017 qsliu2017 force-pushed the move-metadata-queries branch 4 times, most recently from eca5e46 to ce26e4c Compare April 16, 2026 12:16
@qsliu2017 qsliu2017 force-pushed the move-metadata-queries branch from ce26e4c to 0f1d86f Compare April 16, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants