diff --git a/include/substrait/type/Type.h b/include/substrait/type/Type.h index 93208f9f..552befd2 100644 --- a/include/substrait/type/Type.h +++ b/include/substrait/type/Type.h @@ -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 decode( - const std::string& rawType); + const std::string& rawType){ + return decode(rawType, true); + } + + static std::shared_ptr decode( + const std::string& rawType,bool isParameterized); [[nodiscard]] const bool& nullable() const { return nullable_; diff --git a/scripts/setup-macos.sh b/scripts/setup-macos.sh deleted file mode 100755 index 6c3760ef..00000000 --- a/scripts/setup-macos.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash -# 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. - -set -e # Exit on error. -set -x # Print commands that are executed. - -SCRIPTDIR=$(dirname "${BASH_SOURCE[0]}") -source $SCRIPTDIR/setup-helper-functions.sh - -CPU_TARGET="${CPU_TARGET:-avx}" -NPROC=$(getconf _NPROCESSORS_ONLN) -COMPILER_FLAGS=$(get_cxx_flags $CPU_TARGET) - -DEPENDENCY_DIR=${DEPENDENCY_DIR:-$(pwd)} -MACOS_DEPS="ninja bison cmake ccache gflags protobuf" - -function run_and_time { - time "$@" - { echo "+ Finished running $*"; } 2> /dev/null -} - -function prompt { - ( - while true; do - local input="${PROMPT_ALWAYS_RESPOND:-}" - echo -n "$(tput bold)$* [Y, n]$(tput sgr0) " - [[ -z "${input}" ]] && read input - if [[ "${input}" == "Y" || "${input}" == "y" || "${input}" == "" ]]; then - return 0 - elif [[ "${input}" == "N" || "${input}" == "n" ]]; then - return 1 - fi - done - ) 2> /dev/null -} - -function update_brew { - /usr/local/bin/brew update --force --quiet -} - -function install_build_prerequisites { - for pkg in ${MACOS_DEPS} - do - if [[ "${pkg}" =~ ^([0-9a-z-]*):([0-9](\.[0-9\])*)$ ]]; - then - pkg=${BASH_REMATCH[1]} - ver=${BASH_REMATCH[2]} - echo "Installing '${pkg}' at '${ver}'" - tap="local-${pkg}" - brew tap-new "${tap}" - brew extract "--version=${ver}" "${pkg}" "${tap}" - brew install "${tap}/${pkg}@${ver}" - else - brew install --formula "${pkg}" && echo "Installation of ${pkg} is successful" || brew upgrade --formula "$pkg" - fi - done - - pip3 install --user cmake-format regex -} - -function install_deps { - if [ "${INSTALL_PREREQUISITES:-Y}" == "Y" ]; then - run_and_time install_build_prerequisites - fi -} - -(return 2> /dev/null) && return # If script was sourced, don't run commands. - -( - if [[ $# -ne 0 ]]; then - for cmd in "$@"; do - run_and_time "${cmd}" - done - else - install_deps - fi -) - -echo "All deps installed! Now try \"make\"" \ No newline at end of file diff --git a/substrait/function/Extension.cpp b/substrait/function/Extension.cpp index 4d80713e..f7382df9 100644 --- a/substrait/function/Extension.cpp +++ b/substrait/function/Extension.cpp @@ -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()) { @@ -77,7 +77,7 @@ struct YAML::convert { const auto& value = node["value"]; if (value && value.IsScalar()) { auto valueType = value.as(); - argument.type = io::substrait::Type::decode(valueType); + argument.type = io::substrait::ParameterizedType::decode(valueType); return true; } return false; diff --git a/substrait/type/Type.cpp b/substrait/type/Type.cpp index f8b676ac..801b0f36 100644 --- a/substrait/type/Type.cpp +++ b/substrait/type/Type.cpp @@ -3,8 +3,8 @@ #include #include #include -#include "substrait/type/Type.h" #include "substrait/common/Exceptions.h" +#include "substrait/type/Type.h" namespace io::substrait { @@ -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(), @@ -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::typeString == baseType) { - return std::make_shared(nestedTypes[0], nullable); + if (isParameterized) { + return std::make_shared(nestedTypes[0], nullable); + } else { + return std::make_shared( + std::dynamic_pointer_cast(nestedTypes[0]), nullable); + } } else if (TypeTraits::typeString == baseType) { - return std::make_shared( - nestedTypes[0], nestedTypes[1], nullable); + if (isParameterized) { + return std::make_shared( + nestedTypes[0], nestedTypes[1], nullable); + } else { + return std::make_shared( + std::dynamic_pointer_cast(nestedTypes[0]), + std::dynamic_pointer_cast(nestedTypes[1]), + nullable); + } + } else if (TypeTraits::typeString == baseType) { - return std::make_shared(nestedTypes, nullable); + if (isParameterized) { + return std::make_shared( + nestedTypes, nullable); + } else { + std::vector types; + types.reserve(nestedTypes.size()); + for (int i = 0; i < nestedTypes.size(); i++) { + types.emplace_back( + std::dynamic_pointer_cast(nestedTypes.at(i))); + } + return std::make_shared(types, nullable); + } } else if (TypeTraits::typeString == baseType) { StringLiteralPtr precision = std::dynamic_pointer_cast(nestedTypes[0]); StringLiteralPtr scale = std::dynamic_pointer_cast(nestedTypes[1]); - return std::make_shared(precision, scale, nullable); + if (isParameterized) { + return std::make_shared( + precision, scale, nullable); + } else { + return std::make_shared( + std::stoi(precision->value()), std::stoi(scale->value()), nullable); + } } else if (TypeTraits::typeString == baseType) { auto length = std::dynamic_pointer_cast(nestedTypes[0]); - return std::make_shared(length, nullable); + if (isParameterized) { + return std::make_shared(length, nullable); + } else { + return std::make_shared(std::stoi(length->value()), nullable); + } + } else if (TypeTraits::typeString == baseType) { auto length = std::dynamic_pointer_cast(nestedTypes[0]); - return std::make_shared(length, nullable); + if (isParameterized) { + return std::make_shared(length, nullable); + } else { + return std::make_shared( + std::stoi(length->value()), nullable); + } } else if (TypeTraits::typeString == baseType) { auto length = std::dynamic_pointer_cast(nestedTypes[0]); - return std::make_shared(length, nullable); + if (isParameterized) { + return std::make_shared(length, nullable); + } else { + return std::make_shared( + std::stoi(length->value()), nullable); + } } else { SUBSTRAIT_UNSUPPORTED("Unsupported type: " + rawType); } diff --git a/third_party/fmt b/third_party/fmt index 9e8b86fd..80f8d344 160000 --- a/third_party/fmt +++ b/third_party/fmt @@ -1 +1 @@ -Subproject commit 9e8b86fd2d9806672cc73133d21780dd182bfd24 +Subproject commit 80f8d34427d40ec5e7ce3b10ededc46bd4bd5759