[release-19.0] Implement temporal comparisons (#17826) (#17852)#143
Merged
mhamza15 merged 1 commit intorelease-19.0-githubfrom Mar 3, 2025
Merged
[release-19.0] Implement temporal comparisons (#17826) (#17852)#143mhamza15 merged 1 commit intorelease-19.0-githubfrom
mhamza15 merged 1 commit intorelease-19.0-githubfrom
Conversation
…sio#17852) Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com> Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
There was a problem hiding this comment.
PR Overview
This pull request implements temporal comparison support by updating date/time conversion functions and multi‐comparison logic, while extending support for the TIMESTAMP type throughout the evalengine. Key changes include:
- Updates to conversion functions (e.g. Convert_xDTs, toTimestamp) to treat TIMESTAMP and DATETIME uniformly where appropriate.
- Refactoring of multi‐comparison operators in fn_compare.go so that temporal values are handled correctly via both direct temporal comparisons and string-fallback conversions.
- Adjustments in bind variable, column push, and test functions to incorporate the new TIMESTAMP support.
Reviewed Changes
| File | Description |
|---|---|
| go/vt/vtgate/evalengine/compiler_asm.go | Modified Collate signature and added new conversion and multi‐comparison functions for TIMESTAMP. |
| go/vt/vtgate/evalengine/eval_temporal.go | Updated temporal conversion logic to combine DATETIME and TIMESTAMP handling. |
| go/vt/vtgate/evalengine/expr_bvar.go and expr_column.go | Split handling of DATETIME and TIMESTAMP in bind variable and column push operations. |
| go/vt/vtgate/evalengine/compiler.go | Extended compileToTemporal and compileToDecimal to support TIMESTAMP conversions. |
| go/vt/vtgate/evalengine/compiler_asm_push.go | Added push_timestamp routines for TIMESTAMP column and bind variable support. |
| go/vt/vtgate/evalengine/fn_compare.go | Major refactoring of multi-comparison functions to support temporal types including TIMESTAMP. |
| go/vt/vtgate/evalengine/fn_time.go | Adjusted various time functions to include sqltypes.Timestamp in their conversion case lists. |
Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (5)
go/vt/vtgate/evalengine/compiler_asm.go:770
- Ensure that all Collate calls and related usage are updated to accept TypedCollation consistently, and verify that this change does not inadvertently alter collation behavior.
func (asm *assembler) Collate(col collations.TypedCollation) {
go/vt/vtgate/evalengine/compiler_asm.go:1173
- Verify that the logic in Convert_xDTs properly distinguishes TIMESTAMP from DATETIME conversions and that downstream usage of the converted values correctly reflects TIMESTAMP semantics.
func (asm *assembler) Convert_xDTs(offset, prec int, allowZero bool) {
go/vt/vtgate/evalengine/eval_temporal.go:108
- Confirm that toTimestamp handles all expected SQL types (including DATETIME, DATE, and TIMESTAMP) consistently, to ensure there are no inconsistencies in temporal comparisons and conversions.
func (e *evalTemporal) toTimestamp(l int, now time.Time) *evalTemporal {
go/vt/vtgate/evalengine/fn_compare.go:260
- Review the fallback mechanism in compareAllTemporalAsString to ensure it correctly converts temporal values to VARCHAR when direct temporal comparison is not feasible.
func compareAllTemporalAsString(f func(env *ExpressionEnv, arg eval, prec int) *evalTemporal) multiComparisonFunc {
go/vt/vtgate/evalengine/fn_time.go:311
- Ensure that including sqltypes.Timestamp in time conversion switch cases is semantically correct and that the conversion functions handle timestamp-specific edge cases appropriately.
case sqltypes.Datetime, sqltypes.Date, sqltypes.Time, sqltypes.Timestamp:
Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more
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
Related Issue(s)
Checklist
Deployment Notes