-
Notifications
You must be signed in to change notification settings - Fork 16
Initial commit of substrait-cpp #2
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
723eb23
substrait yaml file parser and function lookup support
chaojun-zhang 1add990
Update Cmakelist
chaojun-zhang 59d955d
refactor code structure
a3cce71
Update README.md
chaojun-zhang cc3bf4f
Update README.md
chaojun-zhang f5e9d6f
Update include/substrait/common/Exceptions.h
chaojun-zhang ed29e44
Update substrait/common/Exceptions.cpp
chaojun-zhang a78a513
Update include/substrait/function/FunctionLookup.h
chaojun-zhang ae7299c
Update include/substrait/function/Extension.h
chaojun-zhang db6a202
fix issues
chaojun-zhang 2568fc1
fix issues
chaojun-zhang 70c7a31
rename functionVariant to functionImplementation
chaojun-zhang 3c5acae
use spdx license header
chaojun-zhang 893a974
fix issues
chaojun-zhang 8e60d95
fix issues
chaojun-zhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| --- | ||
| AccessModifierOffset: -1 | ||
| AlignAfterOpenBracket: AlwaysBreak | ||
| AlignConsecutiveAssignments: false | ||
| AlignConsecutiveDeclarations: false | ||
| AlignEscapedNewlinesLeft: true | ||
| AlignOperands: false | ||
| AlignTrailingComments: false | ||
| AllowAllParametersOfDeclarationOnNextLine: false | ||
| AllowShortBlocksOnASingleLine: false | ||
| AllowShortCaseLabelsOnASingleLine: false | ||
| AllowShortFunctionsOnASingleLine: Empty | ||
| AllowShortIfStatementsOnASingleLine: false | ||
| AllowShortLoopsOnASingleLine: false | ||
| AlwaysBreakAfterReturnType: None | ||
| AlwaysBreakBeforeMultilineStrings: true | ||
| AlwaysBreakTemplateDeclarations: true | ||
| BinPackArguments: false | ||
| BinPackParameters: false | ||
| BraceWrapping: | ||
| AfterClass: false | ||
| AfterControlStatement: false | ||
| AfterEnum: false | ||
| AfterFunction: false | ||
| AfterNamespace: false | ||
| AfterObjCDeclaration: false | ||
| AfterStruct: false | ||
| AfterUnion: false | ||
| BeforeCatch: false | ||
| BeforeElse: false | ||
| IndentBraces: false | ||
| BreakBeforeBinaryOperators: None | ||
| BreakBeforeBraces: Attach | ||
| BreakBeforeTernaryOperators: true | ||
| BreakConstructorInitializersBeforeComma: false | ||
| BreakAfterJavaFieldAnnotations: false | ||
| BreakStringLiterals: false | ||
| ColumnLimit: 80 | ||
| CommentPragmas: '^ IWYU pragma:' | ||
| ConstructorInitializerAllOnOneLineOrOnePerLine: true | ||
| ConstructorInitializerIndentWidth: 4 | ||
| ContinuationIndentWidth: 4 | ||
| Cpp11BracedListStyle: true | ||
| DerivePointerAlignment: false | ||
| DisableFormat: false | ||
| ForEachMacros: [ FOR_EACH, FOR_EACH_R, FOR_EACH_RANGE, ] | ||
| IncludeCategories: | ||
| - Regex: '^<.*\.h(pp)?>' | ||
| Priority: 1 | ||
| - Regex: '^<.*' | ||
| Priority: 2 | ||
| - Regex: '.*' | ||
| Priority: 3 | ||
| IndentCaseLabels: true | ||
| IndentWidth: 2 | ||
| IndentWrappedFunctionNames: false | ||
| KeepEmptyLinesAtTheStartOfBlocks: false | ||
| MacroBlockBegin: '' | ||
| MacroBlockEnd: '' | ||
| MaxEmptyLinesToKeep: 1 | ||
| NamespaceIndentation: None | ||
| ObjCBlockIndentWidth: 2 | ||
| ObjCSpaceAfterProperty: false | ||
| ObjCSpaceBeforeProtocolList: false | ||
| PenaltyBreakBeforeFirstCallParameter: 1 | ||
| PenaltyBreakComment: 300 | ||
| PenaltyBreakFirstLessLess: 120 | ||
| PenaltyBreakString: 1000 | ||
| PenaltyExcessCharacter: 1000000 | ||
| PenaltyReturnTypeOnItsOwnLine: 200 | ||
| PointerAlignment: Left | ||
| ReflowComments: true | ||
| SortIncludes: true | ||
| SpaceAfterCStyleCast: false | ||
| SpaceBeforeAssignmentOperators: true | ||
| SpaceBeforeParens: ControlStatements | ||
| SpaceInEmptyParentheses: false | ||
| SpacesBeforeTrailingComments: 1 | ||
| SpacesInAngles: false | ||
| SpacesInContainerLiterals: true | ||
| SpacesInCStyleCastParentheses: false | ||
| SpacesInParentheses: false | ||
| SpacesInSquareBrackets: false | ||
| Standard: Cpp11 | ||
| TabWidth: 8 | ||
| UseTab: Never | ||
| ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,3 +30,5 @@ | |
| *.exe | ||
| *.out | ||
| *.app | ||
|
|
||
| src/proto/substrait | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| [submodule "third_party/yaml-cpp"] | ||
| path = third_party/yaml-cpp | ||
| url = https://github.com/jbeder/yaml-cpp.git | ||
| [submodule "third_party/googletest"] | ||
| path = third_party/googletest | ||
| url = https://github.com/google/googletest.git | ||
| [submodule "third_party/substrait"] | ||
| path = third_party/substrait | ||
| url = https://github.com/substrait-io/substrait.git | ||
| [submodule "third_party/fmt"] | ||
| path = third_party/fmt | ||
| url = https://github.com/fmtlib/fmt |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| cmake_minimum_required(VERSION 3.10) | ||
|
|
||
| # set the project name | ||
| project(substrait-cpp) | ||
|
|
||
| message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") | ||
|
|
||
| set(CMAKE_CXX_STANDARD 17) | ||
| set(CMAKE_CXX_STANDARD_REQUIRED True) | ||
| set(CMAKE_EXPORT_COMPILE_COMMANDS ON) | ||
|
|
||
| option( | ||
| BUILD_TESTING | ||
| "Enable substrait-cpp tests. This will enable all other build options automatically." | ||
| ON) | ||
|
|
||
| find_package(Protobuf REQUIRED) | ||
| include_directories(${PROTOBUF_INCLUDE_DIRS}) | ||
|
|
||
| add_subdirectory(third_party) | ||
| include_directories(include) | ||
| add_subdirectory(substrait) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Licensed to the Apache Software Foundation (ASF) under one | ||
| # or more contributor license agreements. See the NOTICE file | ||
| # distributed with this work for additional information | ||
| # regarding copyright ownership. The ASF licenses this file | ||
| # to you under the Apache License, Version 2.0 (the | ||
| # "License"); you may not use this file except in compliance | ||
| # with the License. You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, | ||
| # software distributed under the License is distributed on an | ||
| # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| # KIND, either express or implied. See the License for the | ||
| # specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| .PHONY: all clean build debug release | ||
|
|
||
| BUILD_TYPE := Release | ||
|
|
||
| all: debug | ||
|
|
||
| clean: | ||
| @rm -rf build-* | ||
|
|
||
| build-common: | ||
| @mkdir -p build-${BUILD_TYPE} | ||
| @cd build-${BUILD_TYPE} && \ | ||
| cmake -Wno-dev \ | ||
| -DCMAKE_BUILD_TYPE=${BUILD_TYPE} \ | ||
| -DPREFER_STATIC_LIBS=OFF \ | ||
| $(FORCE_COLOR) \ | ||
| .. | ||
|
|
||
| build: | ||
| VERBOSE=1 cmake --build build-${BUILD_TYPE} -j $${CPU_COUNT:-`nproc`} || \ | ||
| cmake --build build-${BUILD_TYPE} | ||
|
|
||
| debug: | ||
| @$(MAKE) build-common BUILD_TYPE=Debug | ||
| @$(MAKE) build BUILD_TYPE=Debug | ||
|
|
||
| release: | ||
| @$(MAKE) build-common BUILD_TYPE=Release | ||
| @$(MAKE) build BUILD_TYPE=Release |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,36 @@ | ||
| # substrait-cpp | ||
|
|
||
| Planned home for CPP libraries to help build/consume Substrait query plans. | ||
|
|
||
| ## Getting Started | ||
|
|
||
| We provide scripts to help developers setup and install substrait-cpp dependencies. | ||
|
|
||
| ### Get the substrait-cpp Source | ||
| ``` | ||
| git clone --recursive https://github.com/substrait-io/substrait-cpp.git | ||
| cd substrait-cpp | ||
| # if you are updating an existing checkout | ||
| git submodule sync --recursive | ||
| git submodule update --init --recursive | ||
| ``` | ||
|
|
||
| ### Setting up on Linux (Ubuntu 20.04 or later) | ||
|
|
||
| Once you have checked out substrait-cpp, you can setup and build like so: | ||
|
|
||
| ```shell | ||
| $ ./scripts/setup-ubuntu.sh | ||
| $ make | ||
| ``` | ||
|
|
||
| ## Community | ||
|
|
||
| The main communication channel with the substrait through the | ||
| [substrait chanel](http://substrait.slack.com). | ||
|
|
||
|
|
||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
| ## License | ||
|
|
||
| substrait-cpp is licensed under the Apache 2.0 License. A copy of the license | ||
| [can be found here.](LICENSE) | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,141 @@ | ||
| /* | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <memory> | ||
| #include <utility> | ||
| #include "fmt/format.h" | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
|
|
||
| namespace io::substrait::common { | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
| namespace error_code { | ||
|
|
||
| //====================== User Error Codes ======================: | ||
|
|
||
| // An error raised when an argument verification fails | ||
| inline constexpr auto kInvalidArgument = "INVALID_ARGUMENT"; | ||
|
|
||
| // An error raised when a requested operation is not supported. | ||
| inline constexpr auto kUnsupported = "UNSUPPORTED"; | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
|
|
||
| //====================== Runtime Error Codes ======================: | ||
|
|
||
| // An error raised when the current state of a component is invalid. | ||
| inline constexpr auto kInvalidState = "INVALID_STATE"; | ||
|
|
||
| // An error raised when unreachable code point was executed. | ||
| inline constexpr auto kUnreachableCode = "UNREACHABLE_CODE"; | ||
|
|
||
| // An error raised when a requested operation is not yet supported. | ||
| inline constexpr auto kNotImplemented = "NOT_IMPLEMENTED"; | ||
|
|
||
| // An error raised when a method has been passed an illegal or inappropriate | ||
| // argument. | ||
| inline constexpr auto kIllegalArgument = "ILLEGAL_ARGUMENT"; | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
|
|
||
| } // namespace error_code | ||
|
|
||
| class SubstraitException : public std::exception { | ||
| public: | ||
| enum class Type { kUser = 0, kSystem = 1 }; | ||
|
chaojun-zhang marked this conversation as resolved.
Outdated
|
||
|
|
||
| SubstraitException( | ||
| const std::string& exceptionCode, | ||
| const std::string& exceptionMessage, | ||
| Type exceptionType = Type::kSystem, | ||
| const std::string& exceptionName = "SubstraitException"); | ||
|
|
||
| // Inherited | ||
| [[nodiscard]] const char* what() const noexcept override { | ||
| return msg_.c_str(); | ||
| } | ||
|
|
||
| private: | ||
| const std::string msg_; | ||
| }; | ||
|
|
||
| class SubstraitUserError : public SubstraitException { | ||
| public: | ||
| SubstraitUserError( | ||
| const std::string& exceptionCode, | ||
| const std::string& exceptionMessage, | ||
| const std::string& exceptionName = "SubstraitUserError") | ||
| : SubstraitException( | ||
| exceptionCode, | ||
| exceptionMessage, | ||
| Type::kUser, | ||
| exceptionName) {} | ||
| }; | ||
|
|
||
| class SubstraitRuntimeError final : public SubstraitException { | ||
| public: | ||
| SubstraitRuntimeError( | ||
| const std::string& exceptionCode, | ||
| const std::string& exceptionMessage, | ||
| const std::string& exceptionName = "SubstraitRuntimeError") | ||
| : SubstraitException( | ||
| exceptionCode, | ||
| exceptionMessage, | ||
| Type::kSystem, | ||
| exceptionName) {} | ||
| }; | ||
|
|
||
| template <typename... Args> | ||
| std::string errorMessage(fmt::string_view fmt, const Args&... args) { | ||
| return fmt::vformat(fmt, fmt::make_format_args(args...)); | ||
| } | ||
|
|
||
| #define SUBSTRAIT_THROW(exception, errorCode, ...) \ | ||
| { \ | ||
| auto message = io::substrait::common::errorMessage(__VA_ARGS__); \ | ||
| throw exception(errorCode, message); \ | ||
| } | ||
|
|
||
| #define SUBSTRAIT_UNSUPPORTED(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitUserError, \ | ||
| ::io::substrait::common::error_code::kUnsupported, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| #define SUBSTRAIT_UNREACHABLE(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitRuntimeError, \ | ||
| ::io::substrait::common::error_code::kUnreachableCode, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| #define SUBSTRAIT_FAIL(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitRuntimeError, \ | ||
| ::io::substrait::common::error_code::kInvalidState, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| #define SUBSTRAIT_USER_FAIL(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitUserError, \ | ||
| ::io::substrait::common::error_code::kInvalidState, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| #define SUBSTRAIT_NYI(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitRuntimeError, \ | ||
| ::io::substrait::common::error_code::kNotImplemented, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| #define SUBSTRAIT_ILLEGAL_ARGUMENT(...) \ | ||
| SUBSTRAIT_THROW( \ | ||
| ::io::substrait::common::SubstraitUserError, \ | ||
| ::io::substrait::common::error_code::kIllegalArgument, \ | ||
| ##__VA_ARGS__) | ||
|
|
||
| } // namespace io::substrait::common | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.