Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-19.0] Implement temporal comparisons (#17826) (#17852) #143

Merged
merged 1 commit into from
Mar 3, 2025

Conversation

mhamza15
Copy link

@mhamza15 mhamza15 commented Mar 3, 2025

Description

Related Issue(s)

Checklist

  • "Backport to:" labels have been added if this change should be back-ported
  • Tests were added or are not required
  • Documentation was added or is not required

Deployment Notes

…sio#17852)

Signed-off-by: Dirkjan Bussink <[email protected]>
Co-authored-by: vitess-bot[bot] <108069721+vitess-bot[bot]@users.noreply.github.com>
@mhamza15 mhamza15 self-assigned this Mar 3, 2025
@Copilot Copilot bot review requested due to automatic review settings March 3, 2025 17:02
@mhamza15 mhamza15 closed this Mar 3, 2025
@mhamza15 mhamza15 reopened this Mar 3, 2025
@mhamza15 mhamza15 merged commit a0d4776 into release-19.0-github Mar 3, 2025
175 of 295 checks passed

Choose a reason for hiding this comment

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

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

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.

1 participant