Skip to content

Commit

Permalink
feat: upgrade substrait to 0.23.0
Browse files Browse the repository at this point in the history
  • Loading branch information
jacques-n authored and chaojun-zhang committed Feb 8, 2023
1 parent 590af58 commit d16550d
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 105 deletions.
7 changes: 6 additions & 1 deletion include/substrait/type/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,12 @@ class ParameterizedType {
/// Deserialize substrait raw type string into Substrait extension type.
/// @param rawType - substrait extension raw string type
static std::shared_ptr<const ParameterizedType> decode(
const std::string& rawType);
const std::string& rawType){
return decode(rawType, true);
}

static std::shared_ptr<const ParameterizedType> decode(
const std::string& rawType,bool isParameterized);

[[nodiscard]] const bool& nullable() const {
return nullable_;
Expand Down
89 changes: 0 additions & 89 deletions scripts/setup-macos.sh

This file was deleted.

4 changes: 2 additions & 2 deletions substrait/function/Extension.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bool decodeFunctionVariant(
std::string lastReturnType;
while (std::getline(ss, lastReturnType, '\n')) {
}
function.returnType = io::substrait::Type::decode(lastReturnType);
function.returnType = io::substrait::ParameterizedType::decode(lastReturnType);
}
const auto& args = node["args"];
if (args && args.IsSequence()) {
Expand Down Expand Up @@ -77,7 +77,7 @@ struct YAML::convert<io::substrait::ValueArgument> {
const auto& value = node["value"];
if (value && value.IsScalar()) {
auto valueType = value.as<std::string>();
argument.type = io::substrait::Type::decode(valueType);
argument.type = io::substrait::ParameterizedType::decode(valueType);
return true;
}
return false;
Expand Down
69 changes: 57 additions & 12 deletions substrait/type/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#include <algorithm>
#include <sstream>
#include <stdexcept>
#include "substrait/type/Type.h"
#include "substrait/common/Exceptions.h"
#include "substrait/type/Type.h"

namespace io::substrait {

Expand All @@ -27,7 +27,7 @@ size_t findNextComma(const std::string& str, size_t start) {

} // namespace

ParameterizedTypePtr ParameterizedType::decode(const std::string& rawType) {
ParameterizedTypePtr ParameterizedType::decode(const std::string& rawType, bool isParameterized) {
std::string matchingType = rawType;
std::transform(
matchingType.begin(),
Expand Down Expand Up @@ -97,38 +97,83 @@ ParameterizedTypePtr ParameterizedType::decode(const std::string& rawType) {
auto commaPos = findNextComma(rawType, prevPos);
while (commaPos != std::string::npos) {
auto token = rawType.substr(prevPos, commaPos - prevPos);
nestedTypes.emplace_back(decode(token));
nestedTypes.emplace_back(decode(token,isParameterized));
prevPos = commaPos + 1;
commaPos = findNextComma(rawType, prevPos);
}
auto token = rawType.substr(prevPos, rightAngleBracketPos - prevPos);
nestedTypes.emplace_back(decode(token));
nestedTypes.emplace_back(decode(token,isParameterized));

if (TypeTraits<TypeKind::kList>::typeString == baseType) {
return std::make_shared<ParameterizedList>(nestedTypes[0], nullable);
if (isParameterized) {
return std::make_shared<ParameterizedList>(nestedTypes[0], nullable);
} else {
return std::make_shared<List>(
std::dynamic_pointer_cast<const Type>(nestedTypes[0]), nullable);
}
} else if (TypeTraits<TypeKind::kMap>::typeString == baseType) {
return std::make_shared<ParameterizedMap>(
nestedTypes[0], nestedTypes[1], nullable);
if (isParameterized) {
return std::make_shared<ParameterizedMap>(
nestedTypes[0], nestedTypes[1], nullable);
} else {
return std::make_shared<Map>(
std::dynamic_pointer_cast<const Type>(nestedTypes[0]),
std::dynamic_pointer_cast<const Type>(nestedTypes[1]),
nullable);
}

} else if (TypeTraits<TypeKind::kStruct>::typeString == baseType) {
return std::make_shared<ParameterizedStruct>(nestedTypes, nullable);
if (isParameterized) {
return std::make_shared<const ParameterizedStruct>(
nestedTypes, nullable);
} else {
std::vector<TypePtr> types;
types.reserve(nestedTypes.size());
for (int i = 0; i < nestedTypes.size(); i++) {
types.emplace_back(
std::dynamic_pointer_cast<const Type>(nestedTypes.at(i)));
}
return std::make_shared<Struct>(types, nullable);
}
} else if (TypeTraits<TypeKind::kDecimal>::typeString == baseType) {
StringLiteralPtr precision =
std::dynamic_pointer_cast<const StringLiteral>(nestedTypes[0]);
StringLiteralPtr scale =
std::dynamic_pointer_cast<const StringLiteral>(nestedTypes[1]);
return std::make_shared<ParameterizedDecimal>(precision, scale, nullable);
if (isParameterized) {
return std::make_shared<ParameterizedDecimal>(
precision, scale, nullable);
} else {
return std::make_shared<Decimal>(
std::stoi(precision->value()), std::stoi(scale->value()), nullable);
}
} else if (TypeTraits<TypeKind::kVarchar>::typeString == baseType) {
auto length =
std::dynamic_pointer_cast<const StringLiteral>(nestedTypes[0]);
return std::make_shared<ParameterizedVarchar>(length, nullable);
if (isParameterized) {
return std::make_shared<ParameterizedVarchar>(length, nullable);
} else {
return std::make_shared<Varchar>(std::stoi(length->value()), nullable);
}

} else if (TypeTraits<TypeKind::kFixedChar>::typeString == baseType) {
auto length =
std::dynamic_pointer_cast<const StringLiteral>(nestedTypes[0]);
return std::make_shared<ParameterizedFixedChar>(length, nullable);
if (isParameterized) {
return std::make_shared<ParameterizedFixedChar>(length, nullable);
} else {
return std::make_shared<FixedChar>(
std::stoi(length->value()), nullable);
}
} else if (TypeTraits<TypeKind::kFixedBinary>::typeString == baseType) {
auto length =
std::dynamic_pointer_cast<const StringLiteral>(nestedTypes[0]);
return std::make_shared<ParameterizedFixedBinary>(length, nullable);
if (isParameterized) {
return std::make_shared<ParameterizedFixedBinary>(length, nullable);
} else {
return std::make_shared<FixedBinary>(
std::stoi(length->value()), nullable);
}
} else {
SUBSTRAIT_UNSUPPORTED("Unsupported type: " + rawType);
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/fmt
Submodule fmt updated 86 files
+6 −0 .github/issue_template.md
+5 −1 .github/workflows/doc.yml
+32 −11 .github/workflows/linux.yml
+5 −2 .github/workflows/macos.yml
+53 −21 .github/workflows/windows.yml
+15 −40 CMakeLists.txt
+953 −10 ChangeLog.rst
+20 −15 README.rst
+11 −2 doc/CMakeLists.txt
+266 −165 doc/api.rst
+3 −1 doc/basic-bootstrap/layout.html
+11 −2 doc/build.py
+2 −2 doc/index.rst
+48 −20 doc/syntax.rst
+6 −4 include/fmt/args.h
+1,085 −230 include/fmt/chrono.h
+136 −112 include/fmt/color.h
+54 −82 include/fmt/compile.h
+906 −571 include/fmt/core.h
+841 −1,709 include/fmt/format-inl.h
+2,207 −724 include/fmt/format.h
+0 −2 include/fmt/locale.h
+79 −129 include/fmt/os.h
+151 −95 include/fmt/ostream.h
+19 −31 include/fmt/printf.h
+391 −136 include/fmt/ranges.h
+289 −0 include/fmt/std.h
+51 −39 include/fmt/xchar.h
+0 −1 src/fmt.cc
+16 −47 src/format.cc
+81 −44 src/os.cc
+0 −43 support/appveyor-build.py
+0 −31 support/appveyor.yml
+1 −0 support/bazel/.bazelrc
+1 −0 support/bazel/.bazelversion
+28 −0 support/bazel/BUILD.bazel
+73 −0 support/bazel/README.md
+1 −0 support/bazel/WORKSPACE.bazel
+16 −32 support/cmake/cxx14.cmake
+4 −1 support/cmake/fmt-config.cmake.in
+19 −6 support/manage.py
+201 −0 support/printable.py
+43 −43 test/CMakeLists.txt
+24 −11 test/args-test.cc
+390 −40 test/chrono-test.cc
+12 −0 test/color-test.cc
+209 −47 test/compile-error-test/CMakeLists.txt
+62 −0 test/compile-fp-test.cc
+42 −8 test/compile-test.cc
+168 −29 test/core-test.cc
+18 −0 test/detect-stdfs.cc
+12 −9 test/enforce-checks-test.cc
+1 −2 test/find-package-test/main.cc
+0 −856 test/format
+263 −96 test/format-impl-test.cc
+454 −224 test/format-test.cc
+1 −1 test/fuzzing/CMakeLists.txt
+5 −3 test/fuzzing/build.sh
+6 −5 test/fuzzing/chrono-duration.cc
+32 −0 test/fuzzing/chrono-timepoint.cc
+5 −5 test/fuzzing/float.cc
+7 −5 test/fuzzing/fuzzer-common.h
+5 −3 test/fuzzing/named-arg.cc
+8 −7 test/fuzzing/one-arg.cc
+4 −3 test/fuzzing/two-args.cc
+1 −1 test/gtest-extra-test.cc
+4 −5 test/gtest-extra.cc
+8 −2 test/gtest-extra.h
+7 −0 test/gtest/CMakeLists.txt
+1 −1 test/gtest/gmock-gtest-all.cc
+4 −0 test/header-only-test.cc
+23 −16 test/module-test.cc
+18 −0 test/noexception-test.cc
+31 −48 test/os-test.cc
+95 −55 test/ostream-test.cc
+2 −109 test/posix-mock-test.cc
+1 −11 test/printf-test.cc
+17 −0 test/ranges-odr-test.cc
+166 −6 test/ranges-test.cc
+16 −11 test/scan.h
+0 −161 test/std-format-test.cc
+149 −0 test/std-test.cc
+3 −3 test/test-main.cc
+4 −4 test/unicode-test.cc
+6 −2 test/util.h
+144 −47 test/xchar-test.cc

0 comments on commit d16550d

Please sign in to comment.