Repository navigation
fix: accept native temporal operands in unary bitwise NOT - #32927
Conversation
matrixorigin#32642 declared the native DATE/TIME/DATETIME/TIMESTAMP-to-integer conversion as a per-parameter contract (temporalOnlyIntegerParameter) for `&`, `|`, `^`, `<<`, `>>` and BIT_COUNT, but left UNARY_TILDE without the declaration. Neither the argument-type normalization nor the binder inserted the temporal integer cast for `~`, and unaryTildeTypeMatch only handles text inputs, so `~CAST(... AS DATE)` failed with "invalid argument operator unary_tilde". Declare the same temporal-only integer parameter on UNARY_TILDE so it shares the conversion of the other bitwise consumers. Other source types are unaffected. Fixes matrixorigin#32873
Binding unary NOT operands in the integer-source context dropped the DEFAULT column type, so ~X'0102' changed from a bytewise BINARY value to a uint64 and tables created before the upgrade failed table dump verification. Bind the operand in its ordinary context and insert the temporal integer conversion only after binding proves a native DATE/TIME/DATETIME/TIMESTAMP source.
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
Queue requested — the merge queue status continues in this comment ↓. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
Reviewed head 38dd56444eff142cfe35358acfce0f95e5c9112f.
The change routes native temporal operands through the existing integer conversion and keeps ordinary operand binding for other types, including persisted defaults. I traced AST binding, plan rebinding, prepared-parameter specialization and ENUM/SET handling; I found no blocking correctness, lifecycle, performance or design issue in this delta. There are no unresolved prior reviewer comments on this PR.
Validation: current-head required CI, UT and relevant BVT jobs are green. Locally, the temporal literal/column and prepared-parameter tests, ordinary operand/default binding tests, historical table-dump fixtures, and function metadata test all passed. The new tests cover NULLs, signed/fractional TIME, TIMESTAMP and repeated prepared executions; I did not run an additional live upgrade test.
🚫 Left the queue · pull request dequeued2 h 31 min in the queue, with no time running CI. So far
Reason Pull request #32927 has been dequeued Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.
To get back in the queue
Merge conditions not met when it left the queue
Tick the box to put this pull request back in the merge queue (same as
2 merge conditions met
Times in UTC · dashboard · how the merge queue works |
What type of PR is this?
Which issue(s) this PR fixes:
issue #32873
What this PR does / why we need it:
Unary bitwise NOT (
~) rejected native DATE, TIME, DATETIME and TIMESTAMP operands:Root cause
#32642 made the native temporal-to-integer conversion a per-parameter contract (
integerParameterswithtemporalOnlyIntegerParameter). That declaration drives both argument-type normalization (checkArgumentTypes) and the binder'sappendSourceDependentIntegerArgument, which insertsTemporalIntegerArgumentCastOverload. It was added to&,|,^,<<,>>andBIT_COUNT, but not toUNARY_TILDE. For~,unaryTildeTypeMatchonly adds an implicit cast for CHAR/VARCHAR/TEXT, so a temporal operand fell through to direct overload matching and was rejected.Fix
Declare
integerParameters: {{position: 0, mode: temporalOnlyIntegerParameter}}onUNARY_TILDE. No new mechanism is needed. For any non-temporal source,sourceTargetreports "not applicable", so integer, text, binary and BIT behavior is unchanged.Validation
invalid argument operator unary_tilde, bad value [DATE|DATETIME|TIME|TIMESTAMP]and pass with the fix. They cover literals, columns (NULL, zero value, negative and fractional TIME, TIMESTAMP in UTC), a prepared~?with native temporal parameters and template reuse, and integer/text controls.temporal_numeric_consumeris extended with~cases, including the equivalence from the issue (~(d & -1) = ~CAST(d AS SIGNED) = 18446744073689310997)..resultwas generated by mo-tester against a locally built standalone service. The case passes 60/60. Related cases also pass:func_bit_count210/210,mysql_compat_temporal_numeric_cast30/30,bit_integer_parameter_coercion47/47,integer_parameter_coercion118/118,mysql_compat_bitwise_expr25/25../pkg/sql/planand./pkg/sql/plan/functionpass in full, and so doesTestTypeSwitchFamilies.go vetand incrementalgolangci-lintreport no issues.