Skip to content
This repository was archived by the owner on Sep 18, 2023. It is now read-only.
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion native-sql-engine/cpp/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 && ";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions native-sql-engine/cpp/src/precompile/wscgapi.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
#include <arrow/buffer.h>
#include <arrow/compute/api.h>
#include <arrow/record_batch.h>
#include <arrow/util/value_parsing.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#include <arrow/vendored/fast_float/parse_number.h> should be added here.
And also this arrow pr should be added before this pr merged. https://github.com/oap-project/arrow/pull/173/files


#include <algorithm>
#include <charconv>
#include <cmath>
#include <numeric>
#include <tuple>
Expand Down