diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 87a1fe14..e69559ea 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -35,11 +35,15 @@ jobs: with: submodules: recursive - name: Setup Ubuntu - run: ./scripts/setup-ubuntu.sh - - run: mkdir build + run: | + ./scripts/setup-ubuntu.sh + mkdir build - name: Run cmake - run: cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TZ_LIB=ON + run: | + cmake --version + cmake -Bbuild -GNinja -DCMAKE_BUILD_TYPE=Debug -DBUILD_TZ_LIB=ON - name: Build run: ninja -C build - name: Test - run: ctest --test-dir build --output-on-failure + run: ctest --test-dir build --output-on-failure --timeout 30 + diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c977ce3..025d6c22 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE TRUE) option(SUBSTRAIT_CPP_SANITIZE_DEBUG_BUILD "Turns on address and undefined memory sanitization runtime checking." - ON) + OFF) if(${SUBSTRAIT_CPP_SANITIZE_DEBUG_BUILD}) add_compile_options($<$:-fsanitize=undefined>) diff --git a/export/planloader/CMakeLists.txt b/export/planloader/CMakeLists.txt index 2294572c..e33353a9 100644 --- a/export/planloader/CMakeLists.txt +++ b/export/planloader/CMakeLists.txt @@ -1,12 +1,5 @@ # SPDX-License-Identifier: Apache-2.0 -if(CMAKE_BUILD_TYPE MATCHES Debug) - message( - WARNING - "The planloader library does not work well in Debug mode due to bundled heap checking." - ) -endif() - add_library(planloader SHARED planloader.cpp) add_dependencies(planloader substrait_io) diff --git a/src/substrait/common/CMakeLists.txt b/src/substrait/common/CMakeLists.txt index 38338e7e..d706c63f 100644 --- a/src/substrait/common/CMakeLists.txt +++ b/src/substrait/common/CMakeLists.txt @@ -27,3 +27,7 @@ endif() install(TARGETS substrait_io LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}) install(FILES ../../../include/substrait/common/Io.h DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/substrait/common") + +add_executable(plantransformer PlanTransformerTool.cpp) + +target_link_libraries(plantransformer substrait_io) diff --git a/src/substrait/common/PlanTransformerTool.cpp b/src/substrait/common/PlanTransformerTool.cpp new file mode 100644 index 00000000..8717916d --- /dev/null +++ b/src/substrait/common/PlanTransformerTool.cpp @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: Apache-2.0 */ + +#include + +#include "substrait/common/Io.h" + +namespace io::substrait { +namespace { + +PlanFileFormat planFileFormatFromText(std::string_view str) { + std::string foo; + foo.resize(str.size()); + std::transform(str.begin(), str.end(), foo.begin(), [](unsigned char c) { + return std::tolower(c); + }); + if (foo == "binary") { + return PlanFileFormat::kBinary; + } else if (foo == "json") { + return PlanFileFormat::kJson; + } else if (foo == "prototext") { + return PlanFileFormat::kProtoText; + } else if (foo == "text") { + return PlanFileFormat::kText; + } + // If the format can't be understood, default to text. + return PlanFileFormat::kText; +} + +} // namespace +} // namespace io::substrait + +int main(int argc, char* argv[]) { + if (argc <= 3) { + printf( + "Usage: plantransformer [BINARY|JSON|PROTOTEXT|TEXT]\n"); + return EXIT_FAILURE; + } + + auto planOrError = io::substrait::loadPlan(argv[1]); + if (!planOrError.ok()) { + std::cerr << planOrError.status() << std::endl; + return EXIT_FAILURE; + } + + auto format = io::substrait::planFileFormatFromText(argv[3]); + + auto result = io::substrait::savePlan(*planOrError, argv[2], format); + if (!result.ok()) { + std::cerr << result << std::endl; + return EXIT_FAILURE; + } + + return EXIT_SUCCESS; +}