Skip to content

Rename DuckDB::TableFunction bind data accessors to Ruby style - #1439

Open
otegami wants to merge 1 commit into
suketa:mainfrom
otegami:feature/bind-data-rubyish-alias
Open

Rename DuckDB::TableFunction bind data accessors to Ruby style#1439
otegami wants to merge 1 commit into
suketa:mainfrom
otegami:feature/bind-data-rubyish-alias

Conversation

@otegami

@otegami otegami commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

GitHub: GH-1123

Storing and reading bind data is attribute access, so name it that way:

  • BindInfo#set_bind_data#bind_data=
  • FunctionInfo#get_bind_data#bind_data
  • InitInfo#get_bind_data#bind_data

Rename rather than alias, because all three are unreleased.
Nothing that shipped changes, and the API keeps one name per concept.
DataChunk#size= is the same shape: it wraps duckdb_data_chunk_set_size and no set_size exists.

Summary by CodeRabbit

  • API Updates
    • Renamed table-function bind-data methods for a more consistent interface:
      • Use bind_data = value to set bind data.
      • Use bind_data to retrieve bind data.
    • Existing bind-data storage and initialization behavior remain unchanged.
  • Documentation
    • Updated changelog entries and API references to reflect the new method names.

GitHub: suketaGH-1123

#set_bind_data / #get_bind_data mirrored the C API names, but storing and
reading bind data is attribute access, so spell it that way: BindInfo#bind_data=
and FunctionInfo#bind_data / InitInfo#bind_data. Both old names are unreleased
(suketaGH-1436, suketaGH-1438), so nothing that ever shipped changes, and the API keeps one
name per concept instead of two.
@coderabbitai

coderabbitai Bot commented Aug 4, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The Ruby table-function bind-data APIs were renamed from set_bind_data and get_bind_data to bind_data= and bind_data. Documentation, registrations, and tests were updated. Bind-data storage and lifecycle behavior remain unchanged.

Changes

Bind-data API

Layer / File(s) Summary
Rename bind-data APIs
ext/duckdb/table_function_bind_info.c, ext/duckdb/table_function_function_info.c, ext/duckdb/table_function_init_info.c, CHANGELOG.md
BindInfo now exposes bind_data=, while FunctionInfo and InitInfo expose bind_data. Obsolete aliases and references were removed.
Update bind-data tests
test/duckdb_test/table_function/function_info_test.rb, test/duckdb_test/table_function/init_info_test.rb
Tests now use the renamed APIs and cover round-trip, overwrite, and unset bind-data behavior.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: suketa

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: renaming DuckDB::TableFunction bind data accessors to Ruby-style names.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
test/duckdb_test/table_function/init_info_test.rb (1)

151-157: 🗄️ Data Integrity & Integration | 🔵 Trivial | ⚡ Quick win

Keep an identity check for bind data.

This test now checks only hash equality. Use a named bind-data object and assert_same for the retrieved object. assert_equal does not detect a copied hash.

Proposed test adjustment
+      bind_data = { token: 'init-round-trip', n: 7 }
       table_function.bind do |bind_info|
         bind_info.add_result_column('value', DuckDB::LogicalType::BIGINT)
-        bind_info.bind_data = { token: 'init-round-trip', n: 7 }
+        bind_info.bind_data = bind_data
       end
...
       assert_equal({ token: 'init-round-trip', n: 7 }, observed_bind_data)
+      assert_same(bind_data, observed_bind_data)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/duckdb_test/table_function/init_info_test.rb` around lines 151 - 157,
Update the table_function.init test around observed_bind_data to assign a named
bind-data object before setting bind_info.bind_data, then retrieve it through
init_info.bind_data and assert_same that object rather than relying only on
assert_equal, preserving the existing field-value checks.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ext/duckdb/table_function_function_info.c`:
- Line 46: The renamed C helpers still lack the required rbduckdb_ prefix. In
ext/duckdb/table_function_function_info.c at lines 8-8, 46-46, and 85-85, rename
the declaration, implementation, and Ruby registration to
rbduckdb_table_function_function_info_bind_data; in
ext/duckdb/table_function_init_info.c at lines 12-12, 128-128, and 148-148,
apply the corresponding rbduckdb_table_function_init_info_bind_data name
consistently.

---

Nitpick comments:
In `@test/duckdb_test/table_function/init_info_test.rb`:
- Around line 151-157: Update the table_function.init test around
observed_bind_data to assign a named bind-data object before setting
bind_info.bind_data, then retrieve it through init_info.bind_data and
assert_same that object rather than relying only on assert_equal, preserving the
existing field-value checks.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 08b192b4-f420-4798-bcb6-42b64c2a940b

📥 Commits

Reviewing files that changed from the base of the PR and between 130b13f and 12217ad.

📒 Files selected for processing (6)
  • CHANGELOG.md
  • ext/duckdb/table_function_bind_info.c
  • ext/duckdb/table_function_function_info.c
  • ext/duckdb/table_function_init_info.c
  • test/duckdb_test/table_function/function_info_test.rb
  • test/duckdb_test/table_function/init_info_test.rb

* data = function_info.bind_data
*/
static VALUE table_function_function_info_get_bind_data(VALUE self) {
static VALUE table_function_function_info_bind_data(VALUE self) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Prefix both renamed C helpers with rbduckdb_.

The Ruby API rename is consistent. The renamed C symbols still use table_function_*. Apply the required prefix to each declaration, definition, and registration.

  • ext/duckdb/table_function_function_info.c#L46-L46: rename the implementation to rbduckdb_table_function_function_info_bind_data.
  • ext/duckdb/table_function_function_info.c#L8-L8: update the forward declaration.
  • ext/duckdb/table_function_function_info.c#L85-L85: update the Ruby method registration.
  • ext/duckdb/table_function_init_info.c#L128-L128: rename the implementation to rbduckdb_table_function_init_info_bind_data.
  • ext/duckdb/table_function_init_info.c#L12-L12: update the forward declaration.
  • ext/duckdb/table_function_init_info.c#L148-L148: update the Ruby method registration.

As per coding guidelines, all C symbols in ext/duckdb/**/*.c must be prefixed with rbduckdb_.

📍 Affects 2 files
  • ext/duckdb/table_function_function_info.c#L46-L46 (this comment)
  • ext/duckdb/table_function_function_info.c#L8-L8
  • ext/duckdb/table_function_function_info.c#L85-L85
  • ext/duckdb/table_function_init_info.c#L128-L128
  • ext/duckdb/table_function_init_info.c#L12-L12
  • ext/duckdb/table_function_init_info.c#L148-L148
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ext/duckdb/table_function_function_info.c` at line 46, The renamed C helpers
still lack the required rbduckdb_ prefix. In
ext/duckdb/table_function_function_info.c at lines 8-8, 46-46, and 85-85, rename
the declaration, implementation, and Ruby registration to
rbduckdb_table_function_function_info_bind_data; in
ext/duckdb/table_function_init_info.c at lines 12-12, 128-128, and 148-148,
apply the corresponding rbduckdb_table_function_init_info_bind_data name
consistently.

Source: Coding guidelines

@suketa suketa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thank you, Please change CHANGELOG.md

Comment thread CHANGELOG.md
- add `DuckDB::TableFunction::InitInfo#bind_data` (and `#get_bind_data`) to retrieve, during the init phase, the object stored by `BindInfo#set_bind_data`.
- add `DuckDB::TableFunction::BindInfo#bind_data=` to store an arbitrary Ruby object as a custom table function's bind data.
- add `DuckDB::TableFunction::FunctionInfo#bind_data` to retrieve, during execution, the object stored by `BindInfo#bind_data=`.
- add `DuckDB::TableFunction::InitInfo#bind_data` to retrieve, during the init phase, the object stored by `BindInfo#bind_data=`.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Could you change these entries into Braking changes section?

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.

2 participants