diff --git a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp index 1bff719f4174f..2c6bb3f4e78af 100644 --- a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp +++ b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxExpr.cpp @@ -117,8 +117,6 @@ velox::variant VeloxExprConverter::getConstantValue( case TypeKind::TIMESTAMP: return valueVector->as>()->valueAt( 0); - case TypeKind::DATE: - return valueVector->as>()->valueAt(0); case TypeKind::BOOLEAN: return valueVector->as>()->valueAt(0); case TypeKind::DOUBLE: diff --git a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp index 620ade7b874f8..6e1de55dc0fa1 100644 --- a/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp +++ b/presto-native-execution/presto_cpp/main/types/PrestoToVeloxQueryPlan.cpp @@ -240,7 +240,7 @@ int64_t dateToInt64( const VeloxExprConverter& exprConverter, const TypePtr& type) { auto value = exprConverter.getConstantValue(type, *block); - return value.value().days(); + return value.value(); } double toDouble( @@ -600,6 +600,9 @@ std::unique_ptr toFilter( const protocol::Range& range, bool nullAllowed, const VeloxExprConverter& exprConverter) { + if (type->isDate()) { + return dateRangeToFilter(range, nullAllowed, exprConverter, type); + } switch (type->kind()) { case TypeKind::TINYINT: case TypeKind::SMALLINT: @@ -616,8 +619,6 @@ std::unique_ptr toFilter( return boolRangeToFilter(range, nullAllowed, exprConverter, type); case TypeKind::REAL: return floatRangeToFilter(range, nullAllowed, exprConverter, type); - case TypeKind::DATE: - return dateRangeToFilter(range, nullAllowed, exprConverter, type); default: VELOX_UNSUPPORTED("Unsupported range type: {}", type->toString()); } @@ -653,6 +654,17 @@ std::unique_ptr toFilter( return toFilter(type, ranges[0], nullAllowed, exprConverter); } + if (type->isDate()) { + std::vector> dateFilters; + dateFilters.reserve(ranges.size()); + for (const auto& range : ranges) { + dateFilters.emplace_back( + dateRangeToFilter(range, nullAllowed, exprConverter, type)); + } + return std::make_unique( + std::move(dateFilters), nullAllowed); + } + if (type->kind() == TypeKind::BIGINT || type->kind() == TypeKind::INTEGER || type->kind() == TypeKind::SMALLINT || type->kind() == TypeKind::TINYINT) { @@ -665,17 +677,6 @@ std::unique_ptr toFilter( return combineIntegerRanges(bigintFilters, nullAllowed); } - if (type->kind() == TypeKind::DATE) { - std::vector> dateFilters; - dateFilters.reserve(ranges.size()); - for (const auto& range : ranges) { - dateFilters.emplace_back( - dateRangeToFilter(range, nullAllowed, exprConverter, type)); - } - return std::make_unique( - std::move(dateFilters), nullAllowed); - } - if (type->kind() == TypeKind::VARCHAR) { std::vector> bytesFilters; bytesFilters.reserve(ranges.size()); diff --git a/presto-native-execution/presto_cpp/main/types/TypeSignatureTypeConverter.cpp b/presto-native-execution/presto_cpp/main/types/TypeSignatureTypeConverter.cpp index 553ebea3c13b3..62712cfd65d14 100644 --- a/presto-native-execution/presto_cpp/main/types/TypeSignatureTypeConverter.cpp +++ b/presto-native-execution/presto_cpp/main/types/TypeSignatureTypeConverter.cpp @@ -164,6 +164,10 @@ TypePtr typeFromString(const std::string& typeName) { return INTERVAL_YEAR_MONTH(); } + if (upper == DATE()->toString()) { + return DATE(); + } + return createScalarType(mapNameToTypeKind(upper)); } diff --git a/presto-native-execution/presto_cpp/main/types/tests/RowExpressionTest.cpp b/presto-native-execution/presto_cpp/main/types/tests/RowExpressionTest.cpp index c1ae560d934ba..269b5345e19fe 100644 --- a/presto-native-execution/presto_cpp/main/types/tests/RowExpressionTest.cpp +++ b/presto-native-execution/presto_cpp/main/types/tests/RowExpressionTest.cpp @@ -41,7 +41,7 @@ class RowExpressionTest : public ::testing::Test { converter_->toVeloxExpr(p)); ASSERT_EQ(cexpr->type()->toString(), type); - ASSERT_EQ(cexpr->value().toJson(), value); + ASSERT_EQ(cexpr->value().toJson(cexpr->type()), value); } std::shared_ptr pool_; diff --git a/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp b/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp index fb5f25c97862e..1dfdbfb796ea9 100644 --- a/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp +++ b/presto-native-execution/presto_cpp/presto_protocol/Base64Util.cpp @@ -124,7 +124,6 @@ velox::VectorPtr readScalarBlock( case velox::TypeKind::DOUBLE: case velox::TypeKind::REAL: case velox::TypeKind::VARCHAR: - case velox::TypeKind::DATE: case velox::TypeKind::HUGEINT: return std::make_shared>( pool, diff --git a/presto-native-execution/velox b/presto-native-execution/velox index 3da90b9807c54..e480f5c03a6c4 160000 --- a/presto-native-execution/velox +++ b/presto-native-execution/velox @@ -1 +1 @@ -Subproject commit 3da90b9807c546e7bff2bcb6386464baa2c44e61 +Subproject commit e480f5c03a6c47897ef4488bd56918a89719f908