diff --git a/native-sql-engine/cpp/src/CMakeLists.txt b/native-sql-engine/cpp/src/CMakeLists.txt index da7540651..df7a1ec20 100644 --- a/native-sql-engine/cpp/src/CMakeLists.txt +++ b/native-sql-engine/cpp/src/CMakeLists.txt @@ -7,7 +7,7 @@ include(FindPkgConfig) include(GNUInstallDirs) include(CheckCXXCompilerFlag) -set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc index 1d99cd435..302950a4f 100644 --- a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc +++ b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/codegen_common.cc @@ -657,7 +657,7 @@ arrow::Status CompileCodes(std::string codes, std::string signature) { struct stat pch_stat; auto ret = stat(libwscg_pch.c_str(), &pch_stat); if (ret == -1) { - cmd += env_gcc + " -std=c++14 -Wno-deprecated-declarations " + arrow_header + + cmd += env_gcc + " -std=c++17 -Wno-deprecated-declarations " + arrow_header + arrow_lib + arrow_lib2 + nativesql_header + nativesql_header_2 + " -c " + libwscgfile + env_codegen_option + " -fPIC && "; } diff --git a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/expression_codegen_visitor.cc b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/expression_codegen_visitor.cc index 9207dc63d..da2bd8116 100644 --- a/native-sql-engine/cpp/src/codegen/arrow_compute/ext/expression_codegen_visitor.cc +++ b/native-sql-engine/cpp/src/codegen/arrow_compute/ext/expression_codegen_visitor.cc @@ -671,17 +671,28 @@ arrow::Status ExpressionCodegenVisitor::Visit(const gandiva::FunctionNode& node) std::string func_str; if (func_name.compare("castINTOrNull") == 0) { - func_str = " = std::stoi"; + // C++17 based from_chars + // std::from_chars(str.data(), str.data() + str.size(), result); + func_str = " std::from_chars"; + prepare_ss << "int result = 0;" << std::endl; } else if (func_name.compare("castBIGINTOrNull") == 0) { - func_str = " = std::stol"; + // C++17 based from_chars + // std::from_chars(str.data(), str.data() + str.size(), result); + func_str = " std::from_chars"; + prepare_ss << "long int result = 0;" << std::endl; } else if (func_name.compare("castFLOAT4OrNull") == 0) { - func_str = " = std::stof"; + func_str = " ::arrow_vendored::fast_float::from_chars"; + prepare_ss << "float result = 0;" << std::endl; } else { - func_str = " = std::stod"; + func_str = " ::arrow_vendored::fast_float::from_chars"; + prepare_ss << "double result = 0;" << std::endl; } prepare_ss << "try {" << std::endl; - prepare_ss << codes_str_ << func_str << "(" << child_visitor_list[0]->GetResult() - << ");" << std::endl; + prepare_ss << func_str << "(" << child_visitor_list[0]->GetResult() << ".data(), " + << child_visitor_list[0]->GetResult() << ".data() + " + << child_visitor_list[0]->GetResult() << ".length(), " + << "result);" << std::endl; + prepare_ss << codes_str_ << " = result;" << std::endl; prepare_ss << "} catch (std::invalid_argument) {" << std::endl; prepare_ss << validity << " = false;" << std::endl; prepare_ss << "} catch (std::out_of_range) {" << std::endl; diff --git a/native-sql-engine/cpp/src/precompile/wscgapi.hpp b/native-sql-engine/cpp/src/precompile/wscgapi.hpp index 49bd18cf3..f9ae1d6ca 100644 --- a/native-sql-engine/cpp/src/precompile/wscgapi.hpp +++ b/native-sql-engine/cpp/src/precompile/wscgapi.hpp @@ -3,8 +3,10 @@ #include #include #include +#include #include +#include #include #include #include