@@ -40,6 +40,15 @@ func TestNullRejectBuiltinRegistrySnapshot(t *testing.T) {
4040 require .NotEmpty (t , names )
4141 require .Equal (t , "729f5252bcd91efe1a4bbf0c383a36c5a2e52ed2d90d7aab0a3e0b450322294c" , hex .EncodeToString (sum [:]))
4242
43+ internalScalarNames := map [string ]struct {}{
44+ ast .Cast : {},
45+ }
46+ for name := range nullRejectNullPreservingFunctions {
47+ if _ , ok := internalScalarNames [name ]; ok {
48+ continue
49+ }
50+ require .Contains (t , names , name )
51+ }
4352 for name := range nullRejectRejectNullTests {
4453 require .Contains (t , names , name )
4554 }
@@ -55,7 +64,8 @@ func TestIsNullRejectedProofModes(t *testing.T) {
5564 outerC := newNullRejectIntColumn (3 )
5665 innerS := newNullRejectStringColumn (4 )
5766 innerUnsignedD := newNullRejectUintColumn (5 )
58- innerSchema := expression .NewSchema (innerA , innerB , innerS , innerUnsignedD )
67+ innerDate := newNullRejectDatetimeColumn (6 )
68+ innerSchema := expression .NewSchema (innerA , innerB , innerS , innerUnsignedD , innerDate )
5969
6070 gtInnerAZero := newNullRejectFunc (t , exprCtx , ast .GT , types .NewFieldType (mysql .TypeTiny ), innerA , expression .NewZero ())
6171 eqInnerAZero := newNullRejectFunc (t , exprCtx , ast .EQ , types .NewFieldType (mysql .TypeTiny ), innerA , expression .NewZero ())
@@ -181,6 +191,38 @@ func TestIsNullRejectedProofModes(t *testing.T) {
181191 newNullRejectStringConst ("abc" ),
182192 innerS ,
183193 )
194+ weekWithNullableMode := newNullRejectFunc (
195+ t ,
196+ exprCtx ,
197+ ast .Week ,
198+ types .NewFieldType (mysql .TypeLonglong ),
199+ newNullRejectStringConst ("2024-01-08" ),
200+ innerA ,
201+ )
202+ yearWeekWithNullableMode := newNullRejectFunc (
203+ t ,
204+ exprCtx ,
205+ ast .YearWeek ,
206+ types .NewFieldType (mysql .TypeLonglong ),
207+ newNullRejectStringConst ("2024-01-08" ),
208+ innerA ,
209+ )
210+ weekWithNullableDateAndOuterMode := newNullRejectFunc (
211+ t ,
212+ exprCtx ,
213+ ast .Week ,
214+ types .NewFieldType (mysql .TypeLonglong ),
215+ innerDate ,
216+ outerC ,
217+ )
218+ yearWeekWithNullableDateAndOuterMode := newNullRejectFunc (
219+ t ,
220+ exprCtx ,
221+ ast .YearWeek ,
222+ types .NewFieldType (mysql .TypeLonglong ),
223+ innerDate ,
224+ outerC ,
225+ )
184226 deferredInnerGTZero := newNullRejectDeferredConst (exprCtx , gtInnerAZero )
185227 deferredCoalesceInnerATwoGTTwo := newNullRejectDeferredConst (exprCtx ,
186228 newNullRejectFunc (t , exprCtx , ast .GT , types .NewFieldType (mysql .TypeTiny ), coalesceInnerATwo , newNullRejectIntConst (2 )),
@@ -342,6 +384,54 @@ func TestIsNullRejectedProofModes(t *testing.T) {
342384 expr : newNullRejectNotNull (t , exprCtx , jsonSearchNullableEscape ),
343385 expected : false ,
344386 },
387+ {
388+ name : "week_nullable_mode_uses_default_mode_zero" ,
389+ expr : newNullRejectFunc (
390+ t ,
391+ exprCtx ,
392+ ast .GE ,
393+ types .NewFieldType (mysql .TypeTiny ),
394+ weekWithNullableMode ,
395+ expression .NewZero (),
396+ ),
397+ expected : false ,
398+ },
399+ {
400+ name : "yearweek_nullable_mode_uses_default_mode_zero" ,
401+ expr : newNullRejectFunc (
402+ t ,
403+ exprCtx ,
404+ ast .GE ,
405+ types .NewFieldType (mysql .TypeTiny ),
406+ yearWeekWithNullableMode ,
407+ expression .NewZero (),
408+ ),
409+ expected : false ,
410+ },
411+ {
412+ name : "week_nullable_date_rejects_null_even_with_outer_mode" ,
413+ expr : newNullRejectFunc (
414+ t ,
415+ exprCtx ,
416+ ast .GE ,
417+ types .NewFieldType (mysql .TypeTiny ),
418+ weekWithNullableDateAndOuterMode ,
419+ expression .NewZero (),
420+ ),
421+ expected : true ,
422+ },
423+ {
424+ name : "yearweek_nullable_date_rejects_null_even_with_outer_mode" ,
425+ expr : newNullRejectFunc (
426+ t ,
427+ exprCtx ,
428+ ast .GE ,
429+ types .NewFieldType (mysql .TypeTiny ),
430+ yearWeekWithNullableDateAndOuterMode ,
431+ expression .NewZero (),
432+ ),
433+ expected : true ,
434+ },
345435 {
346436 name : "deferred_expr_uses_symbolic_null_reject_proof" ,
347437 expr : deferredInnerGTZero ,
@@ -393,6 +483,15 @@ func newNullRejectUintColumn(id int64) *expression.Column {
393483 }
394484}
395485
486+ func newNullRejectDatetimeColumn (id int64 ) * expression.Column {
487+ return & expression.Column {
488+ UniqueID : id ,
489+ ID : id ,
490+ Index : int (id ),
491+ RetType : types .NewFieldType (mysql .TypeDatetime ),
492+ }
493+ }
494+
396495func newNullRejectStringConst (value string ) * expression.Constant {
397496 return & expression.Constant {
398497 Value : types .NewStringDatum (value ),
0 commit comments