diff --git a/velox/substrait/SubstraitToVeloxPlan.cpp b/velox/substrait/SubstraitToVeloxPlan.cpp index a7e68b1c6a2e..04bbb416eda2 100644 --- a/velox/substrait/SubstraitToVeloxPlan.cpp +++ b/velox/substrait/SubstraitToVeloxPlan.cpp @@ -1189,15 +1189,15 @@ void SubstraitVeloxPlanConverter::createNotEqualFilter( variant notVariant, bool nullAllowed, std::vector>& colFilters) { - using T = typename RangeTraits::NativeType; + using NativeType = typename RangeTraits::NativeType; using RangeType = typename RangeTraits::RangeType; // Value > lower std::unique_ptr lowerFilter = std::make_unique( - notVariant.value(), /*lower*/ + notVariant.value(), /*lower*/ false, /*lowerUnbounded*/ true, /*lowerExclusive*/ - getMax(), /*upper*/ + getMax(), /*upper*/ true, /*upperUnbounded*/ false, /*upperExclusive*/ nullAllowed); /*nullAllowed*/ @@ -1205,10 +1205,10 @@ void SubstraitVeloxPlanConverter::createNotEqualFilter( // Value < upper std::unique_ptr upperFilter = std::make_unique( - getLowest(), /*lower*/ + getLowest(), /*lower*/ true, /*lowerUnbounded*/ false, /*lowerExclusive*/ - notVariant.value(), /*upper*/ + notVariant.value(), /*upper*/ false, /*upperUnbounded*/ true, /*upperExclusive*/ nullAllowed); /*nullAllowed*/ @@ -1254,6 +1254,24 @@ void SubstraitVeloxPlanConverter::setInFilter( common::createBigintValues(values, nullAllowed); } +template <> +void SubstraitVeloxPlanConverter::setInFilter( + const std::vector& variants, + bool nullAllowed, + const std::string& inputName, + connector::hive::SubfieldFilters& filters) { + // Use bigint values for int type. + std::vector values; + values.reserve(variants.size()); + for (const auto& variant : variants) { + // Use the matched type to get value from variant. + int64_t value = variant.value(); + values.emplace_back(value); + } + filters[common::Subfield(inputName)] = + common::createBigintValues(values, nullAllowed); +} + template <> void SubstraitVeloxPlanConverter::setInFilter( const std::vector& variants, @@ -1449,7 +1467,7 @@ connector::hive::SubfieldFilters SubstraitVeloxPlanConverter::mapToFilters( auto inputType = inputTypeList[colIdx]; switch (inputType->kind()) { case TypeKind::INTEGER: - constructSubfieldFilters( + constructSubfieldFilters( colIdx, inputNameList[colIdx], colInfoMap[colIdx], filters); break; case TypeKind::BIGINT: diff --git a/velox/substrait/TypeUtils.h b/velox/substrait/TypeUtils.h index ab66848ba092..5e865bf3a20c 100644 --- a/velox/substrait/TypeUtils.h +++ b/velox/substrait/TypeUtils.h @@ -36,7 +36,7 @@ template <> struct RangeTraits { using RangeType = common::BigintRange; using MultiRangeType = common::BigintMultiRange; - using NativeType = int64_t; + using NativeType = int32_t; }; template <>