-
-
Notifications
You must be signed in to change notification settings - Fork 29
add DuckDB::ScalarFunction class #970
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This is the first step of DuckDB::ScalarFunction class. Currently, this class does nothing.
WalkthroughA new Ruby C extension class, Changes
Sequence Diagram(s)sequenceDiagram
participant RubyApp as Ruby Application
participant DuckDBExt as DuckDB Ruby Extension
participant ScalarFunc as ScalarFunction Class
RubyApp->>DuckDBExt: require 'duckdb'
DuckDBExt->>DuckDBExt: Init_duckdb_native()
DuckDBExt->>DuckDBExt: rbduckdb_init_duckdb_scalar_function()
DuckDBExt->>ScalarFunc: Define DuckDB::ScalarFunction class
Note right of ScalarFunc: ScalarFunction ready for use (construction only)
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
ext/duckdb/scalar_function.h (1)
14-14: Remove extra blank line for consistency.The extra blank line at the end of the file is unnecessary and should be removed for consistency with other header files.
-
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (5)
CHANGELOG.md(1 hunks)ext/duckdb/duckdb.c(1 hunks)ext/duckdb/ruby-duckdb.h(2 hunks)ext/duckdb/scalar_function.c(1 hunks)ext/duckdb/scalar_function.h(1 hunks)
🧰 Additional context used
🧠 Learnings (6)
📓 Common learnings
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:37:32.786Z
Learning: In Ruby-DuckDB C extensions, when initializing resources like prepared statements, store them directly in the context structure instead of using temporary variables to prevent memory leaks, especially when exceptions might be thrown.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-25T05:20:48.677Z
Learning: In Ruby C extensions, prefer using Ruby's string functions (like rb_str_new2) over C string functions (like strdup) to avoid manual memory management and potential memory leaks.
Learnt from: suketa
PR: suketa/ruby-duckdb#871
File: ext/duckdb/appender.c:170-178
Timestamp: 2025-01-26T00:37:44.001Z
Learning: In ruby-duckdb's DuckDB::Appender#append_uint8, values larger than uint8 max (255) are silently truncated to maintain backward compatibility, following C's implicit truncation behavior. Range checking is intentionally omitted to avoid breaking changes.
CHANGELOG.md (2)
Learnt from: suketa
PR: suketa/ruby-duckdb#871
File: ext/duckdb/appender.c:170-178
Timestamp: 2025-01-26T00:37:44.001Z
Learning: In ruby-duckdb's DuckDB::Appender#append_uint8, values larger than uint8 max (255) are silently truncated to maintain backward compatibility, following C's implicit truncation behavior. Range checking is intentionally omitted to avoid breaking changes.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
ext/duckdb/ruby-duckdb.h (3)
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:37:32.786Z
Learning: In Ruby-DuckDB C extensions, when initializing resources like prepared statements, store them directly in the context structure instead of using temporary variables to prevent memory leaks, especially when exceptions might be thrown.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
Learnt from: suketa
PR: suketa/ruby-duckdb#871
File: ext/duckdb/appender.c:170-178
Timestamp: 2025-01-26T00:37:44.001Z
Learning: In ruby-duckdb's DuckDB::Appender#append_uint8, values larger than uint8 max (255) are silently truncated to maintain backward compatibility, following C's implicit truncation behavior. Range checking is intentionally omitted to avoid breaking changes.
ext/duckdb/duckdb.c (2)
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:37:32.786Z
Learning: In Ruby-DuckDB C extensions, when initializing resources like prepared statements, store them directly in the context structure instead of using temporary variables to prevent memory leaks, especially when exceptions might be thrown.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
ext/duckdb/scalar_function.c (3)
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:37:32.786Z
Learning: In Ruby-DuckDB C extensions, when initializing resources like prepared statements, store them directly in the context structure instead of using temporary variables to prevent memory leaks, especially when exceptions might be thrown.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-25T05:20:48.677Z
Learning: In Ruby C extensions, prefer using Ruby's string functions (like rb_str_new2) over C string functions (like strdup) to avoid manual memory management and potential memory leaks.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
ext/duckdb/scalar_function.h (2)
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:37:32.786Z
Learning: In Ruby-DuckDB C extensions, when initializing resources like prepared statements, store them directly in the context structure instead of using temporary variables to prevent memory leaks, especially when exceptions might be thrown.
Learnt from: suketa
PR: suketa/ruby-duckdb#0
File: :0-0
Timestamp: 2025-01-24T22:18:24.630Z
Learning: When using ruby-asan (AddressSanitizer), avoid letting DuckDB throw C++ exceptions by checking conditions (like table existence) beforehand and raising Ruby exceptions directly to prevent ASAN from intercepting the C++ exceptions.
🧬 Code Graph Analysis (2)
ext/duckdb/duckdb.c (2)
ext/duckdb/scalar_function.h (1)
rbduckdb_init_duckdb_scalar_function(10-10)ext/duckdb/scalar_function.c (1)
rbduckdb_init_duckdb_scalar_function(30-36)
ext/duckdb/scalar_function.c (1)
ext/duckdb/scalar_function.h (1)
rbduckdb_init_duckdb_scalar_function(10-10)
🔇 Additional comments (9)
ext/duckdb/ruby-duckdb.h (2)
32-32: LGTM! Proper header inclusion.The inclusion of the scalar function header follows the established pattern in the codebase.
46-46: LGTM! Consistent external variable declaration.The external variable declaration follows the same pattern as other Ruby class variables in the codebase.
CHANGELOG.md (1)
9-9: LGTM! Appropriate changelog documentation.The changelog entry properly documents the new class addition and correctly notes it's under construction, following the established pattern.
ext/duckdb/duckdb.c (1)
44-44: LGTM! Proper initialization integration.The initialization call follows the established pattern and is correctly placed in the initialization sequence.
ext/duckdb/scalar_function.h (1)
1-12: LGTM! Well-structured header file.The header file follows proper C conventions with include guards, appropriate struct definition, and clear function declaration.
ext/duckdb/scalar_function.c (4)
9-13: LGTM! Proper Ruby data type descriptor.The data type descriptor correctly defines the deallocate and memsize functions for Ruby's garbage collection system, following established patterns in the codebase.
15-19: LGTM! Proper resource cleanup.The deallocate function correctly calls
duckdb_destroy_scalar_functionto clean up the DuckDB resource before freeing the memory, following the established pattern for resource management.
21-24: LGTM! Proper memory allocation.The allocate function uses
xcallocto initialize a zeroed instance and properly wraps it as a Ruby object, consistent with other classes in the codebase.
30-36: LGTM! Proper Ruby class initialization.The initialization function correctly defines the
ScalarFunctionclass under the existingDuckDBmodule and associates the custom allocator, following the established pattern.
This is the first step of DuckDB::ScalarFunction class. Currently, this class does nothing.
Summary by CodeRabbit
New Features
DuckDB::ScalarFunctionclass (currently under construction) to the Ruby extension, laying the groundwork for future scalar function support.Documentation
DuckDB::ScalarFunctionclass.