Repository navigation
Conversation
Signed-off-by: vishal-wk <tac1ee7@gmail.com>
Contributor
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the changes preserving decimal metadata in compiled expressions.
No open issues 🎉
What changed in this PR
Fixes #22126 by preserving decimal size and scale in compiled EvalEngine expressions, preventing fractional seconds from being rounded away when used with TIME().
Changes:
- Preserve the argument’s decimal metadata when compiling
ABS. - Preserve aggregated size and scale when compiling
COALESCE. - Add regression coverage comparing interpreted and compiled results for decimal-to-time expressions.
| File | Description |
|---|---|
go/vt/vtgate/evalengine/fn_numeric.go |
Retains decimal size and scale in compiled ABS. |
go/vt/vtgate/evalengine/fn_compare.go |
Returns aggregated size and scale from compiled COALESCE. |
go/vt/vtgate/evalengine/compiler_test.go |
Checks fractional-second preservation for TIME(d), TIME(ABS(d)), and TIME(COALESCE(d, d)) within CASE. |
Review effort: Balanced
3 of 9 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes decimal precision and scale being lost in the compiled EvalEngine implementations of
ABSandCOALESCE.ABS.COALESCE.TIME(d),TIME(ABS(d)), andTIME(COALESCE(d, d))using aDECIMAL(10,2)value of12.55.Motivation
The compiled evaluator was dropping decimal metadata, causing fractional seconds to be rounded away when decimal expressions were used with
TIME().For example,
TIME(ABS(d))andTIME(COALESCE(d, d))could return00:00:13instead of00:00:12.55.This change ensures that the compiled evaluator preserves the decimal metadata and produces results consistent with the interpreter.
How do you use Vitess? (pick one)
Did you run this change against a real Vitess deployment?
No. I reproduced the issue using the EvalEngine regression tests and additionally compared the affected expressions against a local MySQL instance using Vitess's MySQL differential integration test harness.
Related Issue(s)
Fixes #22126
Checklist
Deployment Notes
No deployment steps, schema migrations, or configuration changes are required.
AI Disclosure
ChatGPT assisted with regression test design; I reviewed, implemented, and validated the final changes.