diff --git a/src/sql/engine/expr/ob_expr_json_func_helper.cpp b/src/sql/engine/expr/ob_expr_json_func_helper.cpp index b12ac7d16a..8d5d50a7c8 100644 --- a/src/sql/engine/expr/ob_expr_json_func_helper.cpp +++ b/src/sql/engine/expr/ob_expr_json_func_helper.cpp @@ -759,8 +759,7 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum, case ObUSmallIntType: case ObUMediumIntType: case ObUInt32Type: - case ObUInt64Type: - case ObYearType: { + case ObUInt64Type: { buf = allocator->alloc(sizeof(ObJsonUint)); if (OB_ISNULL(buf)) { ret = OB_ALLOCATE_MEMORY_FAILED; @@ -770,6 +769,19 @@ int ObJsonExprHelper::transform_scalar_2jsonBase(const T &datum, } break; } + case ObYearType: { + buf = allocator->alloc(sizeof(ObJsonInt)); + int64_t value = 0; + if (OB_FAIL(ObTimeConverter::year_to_int(datum.get_year(), value))) { + LOG_WARN("fail to get year data", K(ret)); + } else if (OB_ISNULL(buf)) { + ret = OB_ALLOCATE_MEMORY_FAILED; + LOG_WARN("buf allocate failed", K(ret), K(type)); + } else { + json_node = (ObJsonInt*)new(buf)ObJsonInt(value); + } + break; + } case ObDateTimeType: case ObTimestampType: case ObTimestampNanoType: