Skip to content

docs: add guidance on disabling constant folding for literal tests#3200

Merged
comphead merged 1 commit intoapache:mainfrom
andygrove:docs/constant-folding-test-advice
Jan 16, 2026
Merged

docs: add guidance on disabling constant folding for literal tests#3200
comphead merged 1 commit intoapache:mainfrom
andygrove:docs/constant-folding-test-advice

Conversation

@andygrove
Copy link
Member

Which issue does this PR close?

N/A - Documentation improvement

Rationale for this change

When testing expressions with literal values (e.g., SELECT my_func('literal')), Spark's constant folding optimizer may evaluate the expression at planning time rather than execution time. This means the Comet implementation might not actually be exercised during the test, leading to false confidence in test coverage.

What changes are included in this PR?

Adds a new "Testing with Literal Values" section to the contributor guide for adding new expressions, explaining:

  • Why constant folding can cause issues with literal tests
  • How to disable constant folding using SQLConf.OPTIMIZER_EXCLUDED_RULES
  • When this is particularly important (edge cases, special values)
  • The recommendation to prefer column references when possible

How are these changes tested?

Documentation only - no code changes.


Note: This PR was generated with AI assistance.

When testing expressions with literal values, Spark's constant folding
optimizer may evaluate the expression at planning time, bypassing the
Comet implementation entirely. This adds documentation on how to disable
constant folding to ensure literal tests actually exercise Comet code.

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@andygrove andygrove force-pushed the docs/constant-folding-test-advice branch from 117686e to b6a65cc Compare January 16, 2026 14:34
Copy link
Contributor

@comphead comphead left a comment

Choose a reason for hiding this comment

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

Thanks @andygrove this good to note, we exclude it some tests like when testing literals and expressions but it was not documented in tests, but should really be

@comphead comphead merged commit d19e1f2 into apache:main Jan 16, 2026
1 check passed
@andygrove andygrove deleted the docs/constant-folding-test-advice branch January 16, 2026 20:30
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