Skip to content

Implement copy_to_get_written_statistics for DuckDB COPY function#7821

Open
vortex-claude[bot] wants to merge 3 commits intodevelopfrom
claude/issue-7819-20260506-2106
Open

Implement copy_to_get_written_statistics for DuckDB COPY function#7821
vortex-claude[bot] wants to merge 3 commits intodevelopfrom
claude/issue-7819-20260506-2106

Conversation

@vortex-claude
Copy link
Copy Markdown

@vortex-claude vortex-claude Bot commented May 6, 2026

Fixes #7819

Generated with Claude Code.

View Claude run

Implements the copy_to_get_written_statistics callback across the full
C/C++/Rust stack, enabling duck-lake (and similar table-format) layers
to collect per-file write statistics (row_count, file_size_bytes) after
a COPY TO operation completes.

Changes:
- Add duckdb_vx_written_statistics_t C struct and optional
  copy_to_get_written_statistics callback (returning bool) to the vtable
  in copy_function.h
- Bridge the callback through c_get_written_statistics in copy_function.cpp,
  which converts the C struct into a DuckDB vector<Value> STRUCT; returns
  an empty vector when the callback returns false (no stats available)
- Add WrittenStatistics type and get_written_statistics trait method to
  the CopyFunction trait with a default no-op implementation
- Add copy_to_get_written_statistics_callback shim in callback.rs
- Store WriteSummary in GlobalState after copy_to_finalize and implement
  get_written_statistics for VortexCopyFunction to expose row_count and
  file_size_bytes

Co-authored-by: Nicholas Gates <gatesn@users.noreply.github.com>
Signed-off-by: "Claude" <claude@anthropic.com>
@gatesn gatesn added the changelog/feature A new feature label May 6, 2026
@gatesn
Copy link
Copy Markdown
Contributor

gatesn commented May 6, 2026

@claude fix the CI, and update AGENTS.md to include the necessary pre-commit checks to avoid this in the future

@vortex-claude
Copy link
Copy Markdown
Author

vortex-claude Bot commented May 6, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

1 similar comment
@vortex-claude
Copy link
Copy Markdown
Author

vortex-claude Bot commented May 6, 2026

Claude encountered an error —— View job


I'll analyze this and get back to you.

gatesn and others added 2 commits May 6, 2026 17:51
The C++ shim returned vector<Value> from c_get_written_statistics, but
DuckDB's copy_to_get_written_statistics_t typedef is a void-returning
callback that fills a CopyFunctionFileStatistics out-parameter. This
caused the C++ build to fail in any job that links vortex-duckdb.

Also re-run nightly rustfmt over copy.rs and copy_function/mod.rs to
match CI's nightly fmt check, and add the lessons (verify FFI signatures
against bundled DuckDB headers; always run nightly fmt) to AGENTS.md.

Signed-off-by: Nicholas Gates <nick@spiraldb.com>

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
…ions

Move the lessons learned out of the "Common Mistakes" do-not list into a
dedicated "Native FFI in vortex-duckdb" section that states what to do.

Signed-off-by: Nicholas Gates <nick@spiraldb.com>

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Nicholas Gates <nick@nickgates.com>
@gatesn gatesn requested a review from robert3005 May 6, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement copy_to_get_written_statistics for DuckDB COPY function

1 participant