提交 2b51e4f0 编写于 作者: B bf0 提交者: wangzelin.wzl

fix load data handle empty filed bug

上级 0b7773c4
......@@ -1231,7 +1231,7 @@ int ObLoadDataImpl::handle_one_line(ObExecContext& ctx, ObPhysicalPlanCtx& plan_
return ret;
}
const char* ObCSVParser::ZERO_STRING = "0";
const char* ObCSVParser::ZERO_STRING = "\xFF\xFF";
int ObCSVParser::init(
int64_t file_column_nums, const ObCSVFormats& formats, const common::ObBitSet<>& string_type_column)
......@@ -1355,7 +1355,7 @@ void ObCSVParser::deal_with_empty_field(ObString& field_str, int64_t index)
{
if (formats_.null_column_fill_zero_string_ && !string_type_column_.has_member(index)) {
// a non-string value will be set to "0", "0" will be cast to zero value of target types
field_str.assign_ptr(ZERO_STRING, 1);
field_str.assign_ptr(ZERO_STRING, 2);
} else {
// a string value will be set to ''
field_str.reset();
......@@ -2831,6 +2831,8 @@ int ObLoadDataSPImpl::exec_insert(ObInsertTask& task, ObInsertResult& result)
}
if (ObLoadDataUtils::is_null_field(single_row_values[c])) {
OZ(sql_str.append(ObString(ObLoadDataUtils::NULL_STRING)));
} else if (ObLoadDataUtils::is_zero_field(single_row_values[c])) {
OZ(sql_str.append("0"));
} else {
if (is_string_column) {
OZ(sql_str.append("'", 1));
......
......@@ -147,6 +147,15 @@ public:
return ret_bool;
}
static inline bool is_zero_field(const common::ObString& field_str)
{
int ret_bool = false;
if (field_str.length() == 2 && field_str.ptr()[0] == '\xff' && field_str.ptr()[1] == '\xff') {
ret_bool = true;
}
return ret_bool;
}
static common::ObString escape_quotation(const common::ObString& value, common::ObDataBuffer& data_buf);
static int init_empty_string_array(common::ObIArray<common::ObString>& new_array, int64_t array_size);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册