feat: add DuckDB::LogicalType.create_map to create a map logical type#1194
feat: add DuckDB::LogicalType.create_map to create a map logical type#1194suketa merged 1 commit intosuketa:mainfrom
DuckDB::LogicalType.create_map to create a map logical type#1194Conversation
📝 WalkthroughWalkthroughAdds a public Ruby factory Changes
Sequence Diagram(s)sequenceDiagram
participant Ruby as Ruby (caller)
participant Ext as C extension (ext/duckdb/logical_type.c)
participant DuckDB as DuckDB C API
Ruby->>Ext: LogicalType.create_map(key_type, value_type)
Ext-->>Ruby: call LogicalType.resolve (for each arg)
Ruby->>Ext: resolved key_type, value_type
Ext->>DuckDB: duckdb_create_map_type(key, value)
DuckDB-->>Ext: duckdb_logical_type* (or NULL)
alt success
Ext-->>Ruby: wrapped DuckDB::LogicalType(:map)
else failure
Ext-->>Ruby: raise eDuckDBError("Failed to create map type")
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
96ba26d to
ff7c0b1
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ext/duckdb/logical_type.c (1)
28-28: Prefix the new C symbol withrbduckdb_for convention compliance.The newly added symbol
duckdb_logical_type_s_create_map_typeshould follow the project’s C symbol prefix convention.♻️ Suggested rename
-static VALUE duckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value); +static VALUE rbduckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value); ... -static VALUE duckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value) { +static VALUE rbduckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value) { ... - rb_define_private_method(rb_singleton_class(cDuckDBLogicalType), "_create_map_type", - duckdb_logical_type_s_create_map_type, 2); + rb_define_private_method(rb_singleton_class(cDuckDBLogicalType), "_create_map_type", + rbduckdb_logical_type_s_create_map_type, 2);As per coding guidelines, C symbols must be prefixed with
rbduckdb_to avoid namespace conflicts.Also applies to: 475-491, 535-536
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ext/duckdb/logical_type.c` at line 28, Rename the C symbol duckdb_logical_type_s_create_map_type to follow project convention by prefixing it with rbduckdb_ (e.g., rbduckdb_logical_type_s_create_map_type), and update all declarations, definitions, and call sites to use the new name; also apply the same rbduckdb_ prefix to the other newly added/related symbols called out in the review so all C symbols in this file consistently follow the rbduckdb_ naming convention.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ext/duckdb/logical_type.c`:
- Line 28: Rename the C symbol duckdb_logical_type_s_create_map_type to follow
project convention by prefixing it with rbduckdb_ (e.g.,
rbduckdb_logical_type_s_create_map_type), and update all declarations,
definitions, and call sites to use the new name; also apply the same rbduckdb_
prefix to the other newly added/related symbols called out in the review so all
C symbols in this file consistently follow the rbduckdb_ naming convention.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 6bd164be-142d-4c4f-8ed6-853696a29afa
📒 Files selected for processing (4)
CHANGELOG.mdext/duckdb/logical_type.clib/duckdb/logical_type.rbtest/duckdb_test/logical_type_test.rb
suketa
left a comment
There was a problem hiding this comment.
Thank you. Pls resolve conflicts. code and test are LGTM.
refs: suketaGH-940 In this PR, we add `DuckDB::LogicalType.create_map` to create a map logical type by wrapping the following C API: - [duckdb_logical_type duckdb_create_map_type(duckdb_logical_type key_type, duckdb_logical_type value_type);](https://duckdb.org/docs/stable/clients/c/api#duckdb_create_map_type) The method accepts either symbols (e.g., `:integer`, `:varchar`) or `DuckDB::LogicalType` instances for both key and value types. This is one of the steps for supporting the duckdb_create_xxxx_type C APIs.
ff7c0b1 to
601f0a1
Compare
|
@suketa Thank you so much for reviewing it. I've just resolved it. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@ext/duckdb/logical_type.c`:
- Line 28: Rename the public symbol to follow the extension convention (prefix
with rbduckdb_)—e.g., change duckdb_logical_type_s_create_map_type to
rbduckdb_logical_type_s_create_map_type—and replace direct rb_raise calls in
this entrypoint with the error helper exported from error.c (use that helper to
raise/format errors consistently). Also audit the other
non-prefixed/error-raising entrypoints referenced in the review (the other
logical-type factory functions near the same changes) and apply the same rename
+ error-helper replacement so all logical_type factories use rbduckdb_ prefixes
and the centralized error helper.
🪄 Autofix (Beta)
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
Run ID: 64d103e5-b188-4a4e-bc4c-f87e8367354e
📒 Files selected for processing (4)
CHANGELOG.mdext/duckdb/logical_type.clib/duckdb/logical_type.rbtest/duckdb_test/logical_type_test.rb
✅ Files skipped from review due to trivial changes (1)
- CHANGELOG.md
🚧 Files skipped from review as they are similar to previous changes (1)
- lib/duckdb/logical_type.rb
| static VALUE duckdb_logical_type__set_alias(VALUE self, VALUE aname); | ||
| static VALUE duckdb_logical_type_s_create_array_type(VALUE klass, VALUE child, VALUE array_size); | ||
| static VALUE duckdb_logical_type_s_create_list_type(VALUE klass, VALUE child); | ||
| static VALUE duckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value); |
There was a problem hiding this comment.
Align the new map factory with C-extension conventions.
The new entrypoint uses a non-rbduckdb_ symbol name and raises directly via rb_raise. Please align with the extension conventions (prefixed symbol + error helper from error.c).
Suggested rename diff (symbol prefix consistency)
-static VALUE duckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value);
+static VALUE rbduckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value);
...
-static VALUE duckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value) {
+static VALUE rbduckdb_logical_type_s_create_map_type(VALUE klass, VALUE key, VALUE value) {
...
- rb_define_private_method(rb_singleton_class(cDuckDBLogicalType), "_create_map_type",
- duckdb_logical_type_s_create_map_type, 2);
+ rb_define_private_method(rb_singleton_class(cDuckDBLogicalType), "_create_map_type",
+ rbduckdb_logical_type_s_create_map_type, 2);As per coding guidelines ext/duckdb/**/*.c: “C symbols must be prefixed with rbduckdb_ to avoid namespace conflicts” and “Use rb_raise for errors in C extension, wrapped in error.c helpers”.
Also applies to: 481-488, 535-536
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@ext/duckdb/logical_type.c` at line 28, Rename the public symbol to follow the
extension convention (prefix with rbduckdb_)—e.g., change
duckdb_logical_type_s_create_map_type to
rbduckdb_logical_type_s_create_map_type—and replace direct rb_raise calls in
this entrypoint with the error helper exported from error.c (use that helper to
raise/format errors consistently). Also audit the other
non-prefixed/error-raising entrypoints referenced in the review (the other
logical-type factory functions near the same changes) and apply the same rename
+ error-helper replacement so all logical_type factories use rbduckdb_ prefixes
and the centralized error helper.
refs: GH-940
In this PR, we add
DuckDB::LogicalType.create_mapto create a map logical type by wrapping the following C API:The method accepts either symbols (e.g.,
:integer,:varchar) orDuckDB::LogicalTypeinstances for both key and value types.This is one of the steps for supporting the duckdb_create_xxxx_type C APIs.
Summary by CodeRabbit
New Features
Tests