@@ -594,7 +594,7 @@ impl<'a> TypeChecker<'a> {
594594 let registry = & BUILTIN_FUNCTIONS ;
595595 let checked_expr = type_check:: check ( & raw_expr, registry) ?;
596596
597- if let Some ( constant) = self . try_fold_constant ( & checked_expr) {
597+ if let Some ( constant) = self . try_fold_constant ( & checked_expr, false ) {
598598 return Ok ( constant) ;
599599 }
600600 // if the source type is nullable, cast target type should also be nullable.
@@ -637,7 +637,7 @@ impl<'a> TypeChecker<'a> {
637637 let registry = & BUILTIN_FUNCTIONS ;
638638 let checked_expr = type_check:: check ( & raw_expr, registry) ?;
639639
640- if let Some ( constant) = self . try_fold_constant ( & checked_expr) {
640+ if let Some ( constant) = self . try_fold_constant ( & checked_expr, false ) {
641641 return Ok ( constant) ;
642642 }
643643
@@ -1086,7 +1086,6 @@ impl<'a> TypeChecker<'a> {
10861086
10871087 Expr :: Hole { .. } => unreachable ! ( "hole is impossible in trivial query" ) ,
10881088 } ;
1089-
10901089 Ok ( Box :: new ( ( scalar, data_type) ) )
10911090 }
10921091
@@ -2749,7 +2748,7 @@ impl<'a> TypeChecker<'a> {
27492748 } => {
27502749 let mut folded_args = Vec :: with_capacity ( args. len ( ) ) ;
27512750 for ( checked_arg, arg) in checked_args. iter ( ) . zip ( args. iter ( ) ) {
2752- match self . try_fold_constant ( checked_arg) {
2751+ match self . try_fold_constant ( checked_arg, true ) {
27532752 Some ( constant) if arg. evaluable ( ) => {
27542753 folded_args. push ( constant. 0 ) ;
27552754 }
@@ -2767,7 +2766,7 @@ impl<'a> TypeChecker<'a> {
27672766 self . ctx . set_cacheable ( false ) ;
27682767 }
27692768
2770- if let Some ( constant) = self . try_fold_constant ( & expr) {
2769+ if let Some ( constant) = self . try_fold_constant ( & expr, true ) {
27712770 return Ok ( constant) ;
27722771 }
27732772
@@ -5067,8 +5066,9 @@ impl<'a> TypeChecker<'a> {
50675066 fn try_fold_constant < Index : ColumnIndex > (
50685067 & self ,
50695068 expr : & EExpr < Index > ,
5069+ enable_shrink : bool ,
50705070 ) -> Option < Box < ( ScalarExpr , DataType ) > > {
5071- if expr. is_deterministic ( & BUILTIN_FUNCTIONS ) {
5071+ if expr. is_deterministic ( & BUILTIN_FUNCTIONS ) && enable_shrink {
50725072 if let ( EExpr :: Constant { scalar, .. } , _) =
50735073 ConstantFolder :: fold ( expr, & self . func_ctx , & BUILTIN_FUNCTIONS )
50745074 {
0 commit comments