diff --git a/velox/expression/CMakeLists.txt b/velox/expression/CMakeLists.txt index 3166487983811..f66f2d2dd7b12 100644 --- a/velox/expression/CMakeLists.txt +++ b/velox/expression/CMakeLists.txt @@ -21,8 +21,8 @@ add_library( ReverseSignatureBinder.cpp) target_link_libraries( - velox_expression_functions velox_common_base velox_type_calculation - velox_type_signature velox_signature_parser) + velox_expression_functions velox_type_parser velox_common_base + velox_type_calculation velox_type_signature velox_signature_parser) add_library( velox_expression diff --git a/velox/expression/FunctionSignature.cpp b/velox/expression/FunctionSignature.cpp index f4cd3530cafd9..e0f605da74f1d 100644 --- a/velox/expression/FunctionSignature.cpp +++ b/velox/expression/FunctionSignature.cpp @@ -19,6 +19,7 @@ #include "velox/common/base/Exceptions.h" #include "velox/expression/FunctionSignature.h" #include "velox/type/Type.h" +#include "velox/type/parser/ParserUtil.h" namespace facebook::velox::exec { @@ -93,14 +94,6 @@ size_t findNextComma(const std::string& str, size_t start) { } namespace { -/// Returns true only if 'str' contains digits. -bool isPositiveInteger(const std::string& str) { - return !str.empty() && - std::find_if(str.begin(), str.end(), [](unsigned char c) { - return !std::isdigit(c); - }) == str.end(); -} - void validateBaseTypeAndCollectTypeParams( const std::unordered_map& variables, const TypeSignature& arg, diff --git a/velox/expression/SignatureBinder.cpp b/velox/expression/SignatureBinder.cpp index 4ea670d4d1951..9eaa01456eeab 100644 --- a/velox/expression/SignatureBinder.cpp +++ b/velox/expression/SignatureBinder.cpp @@ -19,6 +19,7 @@ #include "velox/expression/SignatureBinder.h" #include "velox/expression/type_calculation/TypeCalculation.h" #include "velox/type/Type.h" +#include "velox/type/parser/ParserUtil.h" namespace facebook::velox::exec { @@ -27,14 +28,6 @@ bool isAny(const TypeSignature& typeSignature) { return typeSignature.baseName() == "any"; } -/// Returns true only if 'str' contains digits. -bool isPositiveInteger(const std::string& str) { - return !str.empty() && - std::find_if(str.begin(), str.end(), [](unsigned char c) { - return !std::isdigit(c); - }) == str.end(); -} - std::string buildCalculation( const std::string& variable, const std::string& calculation) { diff --git a/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp b/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp index 1b32b5c946746..927c9ffca2a74 100644 --- a/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp +++ b/velox/expression/tests/utils/ArgumentTypeFuzzer.cpp @@ -22,6 +22,7 @@ #include "velox/expression/ReverseSignatureBinder.h" #include "velox/expression/SignatureBinder.h" #include "velox/type/Type.h" +#include "velox/type/parser/ParserUtil.h" #include "velox/vector/fuzzer/VectorFuzzer.h" namespace facebook::velox::test { @@ -45,15 +46,6 @@ bool isDecimalBaseName(const std::string& typeName) { return normalized == "decimal"; } - -/// Returns true only if 'str' contains digits. -bool isPositiveInteger(const std::string& str) { - return !str.empty() && - std::find_if(str.begin(), str.end(), [](unsigned char c) { - return !std::isdigit(c); - }) == str.end(); -} - } // namespace void ArgumentTypeFuzzer::determineUnboundedIntegerVariables( diff --git a/velox/type/fbhive/CMakeLists.txt b/velox/type/fbhive/CMakeLists.txt index 8db23f2f667fe..ea5009808a889 100644 --- a/velox/type/fbhive/CMakeLists.txt +++ b/velox/type/fbhive/CMakeLists.txt @@ -14,7 +14,7 @@ add_library(velox_type_fbhive HiveTypeParser.cpp HiveTypeSerializer.cpp) -target_link_libraries(velox_type_fbhive velox_type) +target_link_libraries(velox_type_fbhive velox_type velox_type_parser) if(${VELOX_BUILD_TESTING}) add_subdirectory(tests) diff --git a/velox/type/fbhive/HiveTypeParser.cpp b/velox/type/fbhive/HiveTypeParser.cpp index 331aacc854ba7..3d9ea55e51253 100644 --- a/velox/type/fbhive/HiveTypeParser.cpp +++ b/velox/type/fbhive/HiveTypeParser.cpp @@ -22,18 +22,12 @@ #include #include "velox/common/base/Exceptions.h" +#include "velox/type/parser/ParserUtil.h" using facebook::velox::Type; using facebook::velox::TypeKind; namespace { -/// Returns true only if 'str' contains digits. -bool isPositiveInteger(const std::string& str) { - return !str.empty() && - std::find_if(str.begin(), str.end(), [](unsigned char c) { - return !std::isdigit(c); - }) == str.end(); -} bool isSupportedSpecialChar(char c) { static std::unordered_set supported{'_', '$', '#'}; diff --git a/velox/type/parser/ParserUtil.cpp b/velox/type/parser/ParserUtil.cpp index b7fa36ec27b9b..567bf4319f8f1 100644 --- a/velox/type/parser/ParserUtil.cpp +++ b/velox/type/parser/ParserUtil.cpp @@ -52,4 +52,10 @@ std::pair> inferTypeWithSpaces( fieldName, typeFromString(allWords.substr(fieldName.size() + 1))); } +bool isPositiveInteger(const std::string& str) { + return !str.empty() && + std::find_if(str.begin(), str.end(), [](unsigned char c) { + return !std::isdigit(c); + }) == str.end(); +} } // namespace facebook::velox diff --git a/velox/type/parser/ParserUtil.h b/velox/type/parser/ParserUtil.h index 7906b8bbf29d6..4d2d097bf4a31 100644 --- a/velox/type/parser/ParserUtil.h +++ b/velox/type/parser/ParserUtil.h @@ -36,4 +36,7 @@ std::pair inferTypeWithSpaces( std::vector& words, bool cannotHaveFieldName = false); +/// Returns true only if 'str' contains digits. +bool isPositiveInteger(const std::string& str); + } // namespace facebook::velox