From abad7423db9e9612e428b264de484f88763a96c5 Mon Sep 17 00:00:00 2001 From: David Sisson Date: Wed, 6 Mar 2024 16:10:01 -0800 Subject: [PATCH 1/2] feat: add plantransformer tool to convert any plan to any format (#98) --- src/substrait/common/CMakeLists.txt | 4 ++ src/substrait/common/PlanTransformerTool.cpp | 54 ++++++++++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 src/substrait/common/PlanTransformerTool.cpp 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; +} From 3f840144fda667a62b04bb989bc586ae620636f5 Mon Sep 17 00:00:00 2001 From: David Sisson Date: Fri, 15 Mar 2024 00:40:48 -0700 Subject: [PATCH 2/2] fix: get CI working again (#102) Adds an explicit timeout and retry to ensure that we don't run too long (and can identify any tests that are getting stalled out). --- .github/workflows/build_test.yml | 12 ++++++++---- CMakeLists.txt | 2 +- export/planloader/CMakeLists.txt | 7 ------- 3 files changed, 9 insertions(+), 12 deletions(-) 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)