diff --git a/src/sql/engine/expr/ob_expr_cast.cpp b/src/sql/engine/expr/ob_expr_cast.cpp index b05e9ba655..bba1c81d69 100644 --- a/src/sql/engine/expr/ob_expr_cast.cpp +++ b/src/sql/engine/expr/ob_expr_cast.cpp @@ -743,7 +743,10 @@ int ObExprCast::cg_expr(ObExprCGCtx &op_cg_ctx, if (OB_UNLIKELY(UINT_MAX8 < src_res_type.get_length())) { ret = OB_ERR_UNEXPECTED; LOG_WARN("unexpected zerofill length", K(ret), K(src_res_type.get_length())); - } else { + } else if (ob_is_string_or_lob_type(out_type)) { + // The zerofill information will only be used when cast to string/lob type. + // for these types, scale is unused, so the previous design is to save child length + // to the scale of the rt_expr. rt_expr.datum_meta_.scale_ = static_cast(src_res_type.get_length()); } }