@@ -432,8 +432,7 @@ class FunctionIf : public FunctionIfBase</*null_is_false=*/false>
432432 const PaddedPODArray<UInt8> & cond_data = cond_col->getData ();
433433 size_t rows = cond_data.size ();
434434
435- if ((col_then_fixed || col_then_const_fixed)
436- && (col_else_fixed || col_else_const_fixed))
435+ if (isFixedString (block.getByPosition (result).type ))
437436 {
438437 // / The result is FixedString.
439438
@@ -448,16 +447,19 @@ class FunctionIf : public FunctionIfBase</*null_is_false=*/false>
448447 else if (col_then_const_fixed && col_else_fixed)
449448 conditional (ConstSource<FixedStringSource>(*col_then_const_fixed), FixedStringSource (*col_else_fixed), sink, cond_data);
450449 else if (col_then_const_fixed && col_else_const_fixed)
451- conditional (ConstSource<FixedStringSource>(*col_then_const_fixed), ConstSource<FixedStringSource>(*col_else_const_fixed), sink, cond_data);
450+ conditional (ConstSource<FixedStringSource>(*col_then_const_fixed),
451+ ConstSource<FixedStringSource>(*col_else_const_fixed), sink, cond_data);
452+ else
453+ return false ;
452454
453455 block.getByPosition (result).column = std::move (col_res_untyped);
454456 return true ;
455457 }
456458
457- if ((col_then || col_then_const || col_then_fixed || col_then_const_fixed)
458- && (col_else || col_else_const || col_else_fixed || col_else_const_fixed))
459+ if (isString (block.getByPosition (result).type ))
459460 {
460461 // / The result is String.
462+
461463 auto col_res = ColumnString::create ();
462464 auto sink = StringSink (*col_res, rows);
463465
@@ -485,6 +487,17 @@ class FunctionIf : public FunctionIfBase</*null_is_false=*/false>
485487 conditional (ConstSource<StringSource>(*col_then_const), ConstSource<FixedStringSource>(*col_else_const_fixed), sink, cond_data);
486488 else if (col_then_const_fixed && col_else_const)
487489 conditional (ConstSource<FixedStringSource>(*col_then_const_fixed), ConstSource<StringSource>(*col_else_const), sink, cond_data);
490+ else if (col_then_fixed && col_else_fixed)
491+ conditional (FixedStringSource (*col_then_fixed), FixedStringSource (*col_else_fixed), sink, cond_data);
492+ else if (col_then_fixed && col_else_const_fixed)
493+ conditional (FixedStringSource (*col_then_fixed), ConstSource<FixedStringSource>(*col_else_const_fixed), sink, cond_data);
494+ else if (col_then_const_fixed && col_else_fixed)
495+ conditional (ConstSource<FixedStringSource>(*col_then_const_fixed), FixedStringSource (*col_else_fixed), sink, cond_data);
496+ else if (col_then_const_fixed && col_else_const_fixed)
497+ conditional (ConstSource<FixedStringSource>(*col_then_const_fixed),
498+ ConstSource<FixedStringSource>(*col_else_const_fixed), sink, cond_data);
499+ else
500+ return false ;
488501
489502 block.getByPosition (result).column = std::move (col_res);
490503 return true ;
@@ -590,7 +603,8 @@ class FunctionIf : public FunctionIfBase</*null_is_false=*/false>
590603 return true ;
591604 }
592605
593- static void executeGeneric (const ColumnUInt8 * cond_col, Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count)
606+ static void executeGeneric (
607+ const ColumnUInt8 * cond_col, Block & block, const ColumnNumbers & arguments, size_t result, size_t input_rows_count)
594608 {
595609 // / Convert both columns to the common type (if needed).
596610
0 commit comments