Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add substrait query frontend #2075

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Add dummy frontend plugin linked against substrait protobufs
  • Loading branch information
lava committed Feb 9, 2022
commit e95554100fb3d8430d272098c1fce533a9c16748
7 changes: 7 additions & 0 deletions plugins/substrait/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Changelog

This changelog documents all notable changes to the Substrait plugin for VAST.

## v0.1.0

This is the first official release.
66 changes: 66 additions & 0 deletions plugins/substrait/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
cmake_minimum_required(VERSION 3.18...3.22 FATAL_ERROR)

project(
substrait
VERSION 0.1.0
DESCRIPTION "Substrait query language plugin for VAST"
LANGUAGES CXX)

# Enable unit testing. Note that it is necessary to include CTest in the
# top-level CMakeLists.txt file for it to create a test target, so while
# optional for plugins built alongside VAST, it is necessary to specify this
# line manually so plugins can be linked against an installed VAST.
include(CTest)

# FIXME: migrate unit tests
find_package(VAST REQUIRED)
VASTRegisterPlugin(
TARGET substrait
ENTRYPOINT substrait.cpp
TEST_SOURCES tests.cpp)

# Protobuf support

# Note that the `PROTOBUF_GENERATE_CPP()` function provided by the protobuf
# package only works if the `CMakeLists.txt` is in the same directory as the
# protobuf files. Since substrait has a more complicated protobuf layout,
# and we don't want to patch in a new cmake file, we have to use the more
# complicated way below.

find_package(Protobuf REQUIRED)

file(GLOB_RECURSE substrait_protos CONFIGURE_DEPENDS
aux/substrait/proto/substrait/**.proto)

set (PROTO_CPP_OUTDIR "${CMAKE_CURRENT_BINARY_DIR}/proto/")
file(MAKE_DIRECTORY ${PROTO_CPP_OUTDIR})

foreach (file ${substrait_protos})
string(REGEX REPLACE "^.*/aux/substrait/proto/" "" proto_basename ${file})
# Replace .proto -> .pb.cc
string(REGEX REPLACE "[.]proto$" ".pb.cc" proto_cc ${proto_basename})
string(PREPEND proto_cc ${PROTO_CPP_OUTDIR})
# Replace .proto -> .pb.h
string(REGEX REPLACE "[.]proto$" ".pb.h" proto_h ${proto_basename})
string(PREPEND proto_h ${PROTO_CPP_OUTDIR})


add_custom_command(
COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} ${PROTO_FLAGS} --cpp_out=${PROTO_CPP_OUTDIR} ${proto_basename}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/aux/substrait/proto
DEPENDS ${file}
OUTPUT ${proto_cc} ${proto_h}
)

list(APPEND PROTO_HDRS ${proto_h})
list(APPEND PROTO_SRCS ${proto_cc})
endforeach()

message(info "added source ${PROTO_SRCS}")

target_include_directories(substrait PUBLIC ${PROTO_CPP_OUTDIR})
target_sources(substrait PRIVATE ${PROTO_SRCS})
target_link_libraries(substrait PUBLIC protobuf)



3 changes: 3 additions & 0 deletions plugins/substrait/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Sigma Plugin for VAST

to be written
37 changes: 37 additions & 0 deletions plugins/substrait/substrait.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// _ _____ __________
// | | / / _ | / __/_ __/ Visibility
// | |/ / __ |_\ \ / / Across
// |___/_/ |_/___/ /_/ Space and Time
//
// SPDX-FileCopyrightText: (c) 2022 The VAST Contributors
// SPDX-License-Identifier: BSD-3-Clause

#include <vast/data.hpp>
#include <vast/error.hpp>
#include <vast/expression.hpp>
#include <vast/plugin.hpp>

#include <caf/error.hpp>
#include <caf/expected.hpp>
#include <fmt/format.h>

namespace vast::plugins::substrait {

class plugin final : public virtual query_language_plugin {
caf::error initialize(data) override {
return caf::none;
}

[[nodiscard]] const char* name() const override {
return "substrait";
}

[[nodiscard]] caf::expected<expression>
parse(std::string_view query) const override {
return caf::make_error(ec::unspecified, "tbd");
}
};

} // namespace vast::plugins::substrait

VAST_REGISTER_PLUGIN(vast::plugins::substrait::plugin)
15 changes: 15 additions & 0 deletions plugins/substrait/tests.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// _ _____ __________
// | | / / _ | / __/_ __/ Visibility
// | |/ / __ |_\ \ / / Across
// |___/_/ |_/___/ /_/ Space and Time
//
// SPDX-FileCopyrightText: (c) 2022 The VAST Contributors
// SPDX-License-Identifier: BSD-3-Clause

#define SUITE sigma

namespace vast::plugins::sigma {

namespace {} // namespace

} // namespace vast::plugins::sigma