Skip to content

fix(isthmus)!: validate unary arithmetic option preferences - #1395

Merged
nielspardon merged 10 commits into
substrait-io:mainfrom
alexandrefimov:unary-arithmetic-options-1173
Oct 9, 2026
Merged

nielspardon merged 10 commits into
substrait-io:mainfrom
alexandrefimov:unary-arithmetic-options-1173

Conversation

@alexandrefimov

@alexandrefimov alexandrefimov commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Integer negate supports SILENT/ERROR; integer abs supports SILENT. FP64 asin/acos support on_domain_error=NAN. Export these policies and select the first supported preference on import.

Explicit SQRT and transcendental rounding policies, FP32 asin/acos domain policies, and factorial overflow policies remain unsupported. Optionless SQRT retains its POWER conversion. Matching is case-insensitive; undeclared values are rejected before fallback selection.

Part of #1173.

BREAKING CHANGE: Unsupported unary preferences are rejected. Export names SILENT for integer negate/abs and NAN for FP64 asin/acos. Consumers without those policies must reject these plans. Undeclared values fail even with a supported fallback.

SQL CONCAT and || now emit null_handling ACCEPT_NULLS for the standard
Substrait concat function. Import accepts that behavior, including as a
fallback preference, instead of silently discarding options.

BREAKING CHANGE: Standard concat calls with null_handling preferences that do not include ACCEPT_NULLS, unknown options, or empty preference lists are rejected. Include ACCEPT_NULLS only when null propagation is acceptable.
Use one option policy for the standard concat, like, replace, starts_with,
ends_with, strpos, substring, lower, upper and initcap mappings. Export the
behavior implemented by the Calcite operator and reject import preferences
that do not permit it. Other extensions and unmapped option policies are
unchanged.

BREAKING CHANGE: The covered standard string functions reject unknown options, empty preferences and preferences that do not include the mapped Calcite behavior. Allow that behavior only when it is acceptable for the query.
Select and export supported unary arithmetic policies from spec v0.103.0:
checked or silent integer negation, silent integer abs, and NAN domain
errors for FP64 asin/acos. Reject explicit preferences without a proven
native policy rather than dropping them.

BREAKING CHANGE: Isthmus rejects unsupported unary arithmetic option preferences instead of silently ignoring them.
@coderabbitai

coderabbitai Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository: substrait-io/substrait-java/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 75624933-1da1-4b90-be6f-508923432b87

📥 Commits

Reviewing files that changed from the base of the PR and between 73232c3 and 2796424.


📒 Files selected for processing (4)
  • isthmus/src/main/java/io/substrait/isthmus/expression/ScalarFunctionConverter.java
  • isthmus/src/main/java/io/substrait/isthmus/expression/UnaryArithmeticOptions.java
  • isthmus/src/test/java/io/substrait/isthmus/SqrtImportTest.java
  • isthmus/src/test/java/io/substrait/isthmus/UnaryArithmeticOptionsTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 1 remain after this review.



📝 Summary

Summary by CodeRabbit

  • New Features
    • Unary arithmetic functions now support explicit overflow behavior for integer negation and absolute value, and domain-error handling for supported inverse trigonometric functions.
    • Integer negation can select checked or standard arithmetic based on its overflow setting.
  • Bug Fixes
    • Unsupported or conflicting arithmetic options are rejected instead of being silently interpreted. For example, square root calls with an explicit error-on-domain setting are no longer imported as supported expressions.

Walkthrough

The scalar function converter now applies unary arithmetic options for supported arithmetic variants. Tests cover option selection and rejection, Rex execution, and SQL export.

Changes

Unary arithmetic options

Layer / File(s) Summary
Apply and validate unary arithmetic options
isthmus/src/main/java/io/substrait/isthmus/expression/ScalarFunctionConverter.java, isthmus/src/main/java/io/substrait/isthmus/expression/UnaryArithmeticOptions.java, isthmus/src/test/java/io/substrait/isthmus/UnaryArithmeticOptionsTest.java, isthmus/src/test/java/io/substrait/isthmus/SqrtImportTest.java
The converter applies overflow options for integer negate and abs, and domain-error options for FP64 asin and acos. Tests cover option resolution, unsupported options, execution behavior, and SQL export. The sqrt import test now expects UnsupportedOperationException for on_domain_error=ERROR.

Priority: ➖ Normal

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Suggested reviewers: nielspardon


Merge Risk: ⚪ Minimal · up to 27964

The supported unary options appear to round-trip consistently, with no outstanding issue identified that would prevent merging after normal checks.

Pre-merge checks | Passed 4 | Failed 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%. Docstring coverage is scoped to functions touched by this diff. Analyzed 31 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check Passed The description states the supported unary arithmetic policies, unsupported cases, import and export behavior, validation rules, related issue, and breaking change. It provides the required rationale …
Title check Passed The title is a valid Conventional Commit title. It clearly identifies the isthmus scope and the main change: validating unary arithmetic option preferences.
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.


  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR


  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@nielspardon nielspardon left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Same ask as on #1393 and #1394: please rebase this onto the shared option seam once it lands. This PR changes the same defaultConvert, generateBinding and getSqlOperatorFromSubstraitFunc lines as #1392, #1393 and #1394, and the CHECKED_UNARY_MINUS remap here belongs next to #1392's CHECKED_PLUS/MINUS/MULTIPLY/DIVIDE remap in that seam.

Comment thread isthmus/src/main/java/io/substrait/isthmus/expression/UnaryArithmeticOptions.java Outdated
Comment thread isthmus/src/main/java/io/substrait/isthmus/expression/UnaryArithmeticOptions.java Outdated
@nielspardon

Copy link
Copy Markdown
Member

next one needing conflicts resolved

@nielspardon
nielspardon merged commit c3def2c into substrait-io:main Oct 9, 2026
14 checks passed
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