aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgalaxycrab <UgnineSirdis@ydb.tech>2023-11-13 14:57:23 +0300
committergalaxycrab <UgnineSirdis@ydb.tech>2023-11-13 15:24:30 +0300
commit3b418aaf377d71e99c6f83ace0d9dd92b0c0793b (patch)
tree4a057b96680c4784a19484a9b3e1a9cd42e61d0c
parent3f4c9ea886135d5a9ed2a64695eda625027b9f69 (diff)
downloadydb-3b418aaf377d71e99c6f83ace0d9dd92b0c0793b.tar.gz
Allow implicit cast to int64 in pushdown
-rw-r--r--ydb/library/yql/providers/common/pushdown/collection.cpp24
-rw-r--r--ydb/library/yql/providers/common/pushdown/settings.h1
-rw-r--r--ydb/library/yql/providers/generic/provider/ut/pushdown/pushdown_ut.cpp32
-rw-r--r--ydb/library/yql/providers/generic/provider/yql_generic_physical_opt.cpp2
4 files changed, 45 insertions, 14 deletions
diff --git a/ydb/library/yql/providers/common/pushdown/collection.cpp b/ydb/library/yql/providers/common/pushdown/collection.cpp
index f6a8c30193..a9590f6c03 100644
--- a/ydb/library/yql/providers/common/pushdown/collection.cpp
+++ b/ydb/library/yql/providers/common/pushdown/collection.cpp
@@ -222,7 +222,8 @@ bool IsComparableTypes(const TExprBase& leftNode, const TExprBase& rightNode, bo
// SSA program cast those values to Int32
if (rightTypeId == NYql::NProto::Int8 ||
rightTypeId == NYql::NProto::Int16 ||
- rightTypeId == NYql::NProto::Int32)
+ rightTypeId == NYql::NProto::Int32 ||
+ (settings.IsEnabled(TSettings::EFeatureFlag::ImplicitConversionToInt64) && rightTypeId == NYql::NProto::Int64))
{
return ECompareOptions::Comparable;
}
@@ -237,7 +238,8 @@ bool IsComparableTypes(const TExprBase& leftNode, const TExprBase& rightNode, bo
// SSA program cast those values to Uint32
if (rightTypeId == NYql::NProto::Uint8 ||
rightTypeId == NYql::NProto::Uint16 ||
- rightTypeId == NYql::NProto::Uint32)
+ rightTypeId == NYql::NProto::Uint32 ||
+ (settings.IsEnabled(TSettings::EFeatureFlag::ImplicitConversionToInt64) && rightTypeId == NYql::NProto::Uint64))
{
return ECompareOptions::Comparable;
}
@@ -254,9 +256,25 @@ bool IsComparableTypes(const TExprBase& leftNode, const TExprBase& rightNode, bo
return ECompareOptions::Comparable;
}
break;
- case NYql::NProto::Bool:
case NYql::NProto::Int64:
+ if (settings.IsEnabled(TSettings::EFeatureFlag::ImplicitConversionToInt64) && (
+ rightTypeId == NYql::NProto::Int8 ||
+ rightTypeId == NYql::NProto::Int16 ||
+ rightTypeId == NYql::NProto::Int32))
+ {
+ return ECompareOptions::Comparable;
+ }
+ break;
case NYql::NProto::Uint64:
+ if (settings.IsEnabled(TSettings::EFeatureFlag::ImplicitConversionToInt64) && (
+ rightTypeId == NYql::NProto::Uint8 ||
+ rightTypeId == NYql::NProto::Uint16 ||
+ rightTypeId == NYql::NProto::Uint32))
+ {
+ return ECompareOptions::Comparable;
+ }
+ break;
+ case NYql::NProto::Bool:
case NYql::NProto::Float:
case NYql::NProto::Double:
case NYql::NProto::Decimal:
diff --git a/ydb/library/yql/providers/common/pushdown/settings.h b/ydb/library/yql/providers/common/pushdown/settings.h
index 136202fb7b..920b6722dd 100644
--- a/ydb/library/yql/providers/common/pushdown/settings.h
+++ b/ydb/library/yql/providers/common/pushdown/settings.h
@@ -21,6 +21,7 @@ struct TSettings {
UuidType = 1 << 11,
DecimalType = 1 << 12,
DyNumberType = 1 << 13,
+ ImplicitConversionToInt64 = 1 << 14, // Allow implicit conversions to 64-bits integers from other types of integers
};
explicit TSettings(NLog::EComponent logComponent)
diff --git a/ydb/library/yql/providers/generic/provider/ut/pushdown/pushdown_ut.cpp b/ydb/library/yql/providers/generic/provider/ut/pushdown/pushdown_ut.cpp
index 407048cc6c..907a22af45 100644
--- a/ydb/library/yql/providers/generic/provider/ut/pushdown/pushdown_ut.cpp
+++ b/ydb/library/yql/providers/generic/provider/ut/pushdown/pushdown_ut.cpp
@@ -365,12 +365,12 @@ Y_UNIT_TEST_SUITE_F(PushdownTest, TPushdownFixture) {
)proto");
}
- Y_UNIT_TEST(NotEqual) {
+ Y_UNIT_TEST(NotEqualInt32Int64) {
AssertFilter(
// Note that R"ast()ast" is empty string!
R"ast(
(Coalesce
- (!= (Member $row '"col_optional_uint64") (Uint64 '42))
+ (!= (Member $row '"col_optional_uint64") (Member $row '"col_uint32"))
(Bool '"true")
)
)ast",
@@ -381,14 +381,26 @@ Y_UNIT_TEST_SUITE_F(PushdownTest, TPushdownFixture) {
column: "col_optional_uint64"
}
right_value {
- typed_value {
- type {
- type_id: UINT64
- }
- value {
- uint64_value: 42
- }
- }
+ column: "col_uint32"
+ }
+ }
+ )proto");
+ }
+
+ Y_UNIT_TEST(CmpInt16AndInt32) {
+ AssertFilter(
+ // Note that R"ast()ast" is empty string!
+ R"ast(
+ (<= (Member $row '"col_int32") (Member $row '"col_int16"))
+ )ast",
+ R"proto(
+ comparison {
+ operation: LE
+ left_value {
+ column: "col_int32"
+ }
+ right_value {
+ column: "col_int16"
}
}
)proto");
diff --git a/ydb/library/yql/providers/generic/provider/yql_generic_physical_opt.cpp b/ydb/library/yql/providers/generic/provider/yql_generic_physical_opt.cpp
index 5d16fb6ee1..d55c02b88c 100644
--- a/ydb/library/yql/providers/generic/provider/yql_generic_physical_opt.cpp
+++ b/ydb/library/yql/providers/generic/provider/yql_generic_physical_opt.cpp
@@ -25,7 +25,7 @@ namespace NYql {
: NPushdown::TSettings(NLog::EComponent::ProviderGeneric)
{
using EFlag = NPushdown::TSettings::EFeatureFlag;
- Enable(EFlag::ExpressionAsPredicate | EFlag::ArithmeticalExpressions);
+ Enable(EFlag::ExpressionAsPredicate | EFlag::ArithmeticalExpressions | EFlag::ImplicitConversionToInt64);
}
};