Skip to content

fix: Add option for SQLite for perform decimal_cmp instead of BETWEEN#333

Merged
peasee merged 3 commits into
spiceaifrom
fix/sqlite-between-decimal
May 9, 2025
Merged

fix: Add option for SQLite for perform decimal_cmp instead of BETWEEN#333
peasee merged 3 commits into
spiceaifrom
fix/sqlite-between-decimal

Conversation

@peasee
Copy link
Copy Markdown
Collaborator

@peasee peasee commented May 9, 2025

  • Introduces a new AST analzyer rule for the SQLite table provider, to rewrite BETWEEN rules that use numerics in the low and high values to use decimal_cmp() instead.
  • decimal_cmp() and associated decimal() functions are only supported when the SQLite library is built with decimal.c, which a user may not always. Because of this, the analyzer rule is opt-in by specifying .with_decimal_between(true) in the provider factory or builder.

This resolves situations like l_discount BETWEEN 0.06-0.01 AND 0.06+0.01 into decimal_cmp(l_discount, decimal('0.06')-decimal('0.01')) >= 0 AND ... to perform accurate arbitrary-precision BETWEEN queries against SQLite numeric values.

@peasee peasee self-assigned this May 9, 2025
@peasee peasee added the bug Something isn't working label May 9, 2025
@peasee peasee changed the title fix: Add option for SQLite for perform instead of BETWEEN fix: Add option for SQLite for perform decimal_cmp instead of BETWEEN May 9, 2025
@peasee peasee merged commit 15d2c7c into spiceai May 9, 2025
3 checks passed
@peasee peasee deleted the fix/sqlite-between-decimal branch May 9, 2025 07:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants