Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

enable C++17 support #1142

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 2 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,27 @@ 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

miss a semicolon after 0 and an #include <charconv> in wscgapi.hpp.

} 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

miss a semicolon after 0

} 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;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

} else {
func_str = " = std::stod";
func_str = " = ::arrow_vendored::fast_float::from_chars";
prepare_ss << "double result = 0" << std::endl;
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

}
prepare_ss << "try {" << std::endl;
prepare_ss << codes_str_ << func_str << "(" << child_visitor_list[0]->GetResult()
<< ");" << std::endl;
<< ".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