This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit 52d6e2cad2704506457580d92839063c02e99219 Author: Ashin Gau <[email protected]> AuthorDate: Fri May 26 20:04:45 2023 +0800 [fix](multi-catalog) values in sqlserver should be enclosed by single quotes (#19971) Fix errors when inserting string/date/datetime values into SQLServer: ERROR 1105 (HY000): errCode = 2, detailMessage = (172.21.0.101)[INTERNAL_ERROR]UdfRuntimeException: JDBC executor sql has error: CAUSED BY: SQLServerException: Invalid column name '2021-10-30'. When using double quotes enclose string values, it will be parsed as column name, so we should enclose string values with single quotes. --- be/src/exec/table_connector.cpp | 11 ++++++++--- be/src/olap/tablet.cpp | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/be/src/exec/table_connector.cpp b/be/src/exec/table_connector.cpp index b803d7fea5..15047d9846 100644 --- a/be/src/exec/table_connector.cpp +++ b/be/src/exec/table_connector.cpp @@ -318,15 +318,20 @@ Status TableConnector::convert_column_data(const vectorized::ColumnPtr& column_p const TypeDescriptor& type, int row, TOdbcTableType::type table_type) { auto extra_convert_func = [&](const std::string_view& str, const bool& is_date) -> void { - if (table_type != TOdbcTableType::ORACLE && table_type != TOdbcTableType::SAP_HANA) { - fmt::format_to(_insert_stmt_buffer, "\"{}\"", str); - } else { + if (table_type == TOdbcTableType::ORACLE || table_type == TOdbcTableType::SAP_HANA) { //if is ORACLE and date type, insert into need convert if (is_date) { fmt::format_to(_insert_stmt_buffer, "to_date('{}','yyyy-mm-dd')", str); } else { fmt::format_to(_insert_stmt_buffer, "to_date('{}','yyyy-mm-dd hh24:mi:ss')", str); } + } else if (table_type == TOdbcTableType::POSTGRESQL) { + fmt::format_to(_insert_stmt_buffer, "'{}'::date", str); + } else if (table_type == TOdbcTableType::SQLSERVER) { + // Values in sqlserver should be enclosed by single quotes + fmt::format_to(_insert_stmt_buffer, "'{}'", str); + } else { + fmt::format_to(_insert_stmt_buffer, "\"{}\"", str); } }; const vectorized::IColumn* column = column_ptr; diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index 8b42a18788..7bba605b67 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -2101,7 +2101,7 @@ Status Tablet::calc_delete_bitmap(RowsetId rowset_id, delete_bitmap->add({rowset_id, loc.segment_id, 0}, loc.row_id); } else if (st.is<ALREADY_EXIST>()) { delete_bitmap->add({rowset_id, seg->id(), 0}, row_id); - } else if (!st.is_not_found()) { + } else if (!st.is<NOT_FOUND>()) { // some unexpected error LOG(WARNING) << "some unexpected error happen while looking up keys " << "in pre segments: " << st; --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
