Skip to content

Add FLOAT support to ScalarFunction return type#1073

Merged
suketa merged 1 commit intomainfrom
add-float-support-to-scalar-function
Feb 7, 2026
Merged

Add FLOAT support to ScalarFunction return type#1073
suketa merged 1 commit intomainfrom
add-float-support-to-scalar-function

Conversation

@suketa
Copy link
Owner

@suketa suketa commented Feb 7, 2026

Completes Phase 1 - all simple numeric types now supported!

Extends vector_set_value_at() to support FLOAT (single-precision float) return values.

This completes Phase 1 of the type support plan - all simple numeric types
(BOOLEAN, INTEGER, BIGINT, FLOAT, DOUBLE) are now supported!

Changes:
- Add DUCKDB_TYPE_FLOAT case to vector_set_value_at() switch
- Convert Ruby value to float using (float)NUM2DBL macro
- Update type validation to allow :float
- Add test_scalar_function_float_return_type test case

Implementation follows TDD approach:
1. RED: Added failing test for FLOAT return type
2. GREEN: Added FLOAT case to C switch statement
3. GREEN: Updated Ruby type validation
4. Verified all 15 tests pass with 23 assertions

Type conversion:
- Ruby → DuckDB: (float)NUM2DBL (convert to double, then cast to float)
- DuckDB → Ruby: DBL2NUM (already supported in vector_value_at)

Test coverage:
- Tests floating-point arithmetic: 2.5 + 0.5 = 3.0
- Uses assert_in_delta for floating-point comparison

Type ID: DUCKDB_TYPE_FLOAT = 10

Phase 1 Complete! Supported types:
- BOOLEAN (bool) - PR #1072
- INTEGER (int32_t) - Original
- BIGINT (int64_t) - PR #1070
- FLOAT (float) - This PR
- DOUBLE (double) - PR #1071

Related to plan: extend-vector-set-value-at-types.md Phase 1.4
@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

Warning

Rate limit exceeded

@suketa has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-float-support-to-scalar-function

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 and usage tips.

@suketa suketa merged commit a9a8acc into main Feb 7, 2026
39 checks passed
@suketa suketa deleted the add-float-support-to-scalar-function branch February 7, 2026 22:00
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.

1 participant