aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authora-romanov <Anton.Romanov@ydb.tech>2023-07-06 11:01:57 +0300
committera-romanov <Anton.Romanov@ydb.tech>2023-07-06 11:01:57 +0300
commit0d96d627de2058ac0fe76e3d358b4e3617629f2c (patch)
treed81ec8894e1308e4eabc701df79ac562b6538d2d
parent5cc334cba05a34b5895d365f7e5d2d6b08e2cec0 (diff)
downloadydb-0d96d627de2058ac0fe76e3d358b4e3617629f2c.tar.gz
YQL-15555 Fix unique constraint for SafeCast/StrictCast.
-rw-r--r--ydb/library/yql/core/yql_expr_constraint.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/ydb/library/yql/core/yql_expr_constraint.cpp b/ydb/library/yql/core/yql_expr_constraint.cpp
index 5636b71b7f..a22e2b5490 100644
--- a/ydb/library/yql/core/yql_expr_constraint.cpp
+++ b/ydb/library/yql/core/yql_expr_constraint.cpp
@@ -568,19 +568,20 @@ private:
return false;
};
- const auto filterForUnique = Strict ? [outItemType](const TConstraintNode::TPathType& path) {
- return bool(TConstraintNode::GetSubTypeByPath(path, *outItemType));
- } : TConstraintNode::TPathFilter(filter);
+ const auto filterForUnique = [inItemType, outItemType](const TConstraintNode::TPathType& path) {
+ const auto castResult = CastResult<Strict>(TConstraintNode::GetSubTypeByPath(path, *inItemType), TConstraintNode::GetSubTypeByPath(path, *outItemType));
+ return NUdf::ECastOptions::Complete == castResult || NUdf::ECastOptions::MayFail == castResult;
+ };
- const auto filterForDistinct = Strict ? [inItemType, outItemType](const TConstraintNode::TPathType& path) {
+ const auto filterForDistinct = [inItemType, outItemType](const TConstraintNode::TPathType& path) {
return NUdf::ECastOptions::Complete == CastResult<Strict>(TConstraintNode::GetSubTypeByPath(path, *inItemType), TConstraintNode::GetSubTypeByPath(path, *outItemType));
- } : TConstraintNode::TPathFilter(filter);
+ };
FilterFromHead<TPassthroughConstraintNode>(input, filter, ctx);
FilterFromHead<TSortedConstraintNode>(input, filter, ctx);
FilterFromHead<TChoppedConstraintNode>(input, filter, ctx);
- FilterFromHead<TUniqueConstraintNode>(input, filter, ctx);
- FilterFromHead<TDistinctConstraintNode>(input, filter, ctx);
+ FilterFromHead<TUniqueConstraintNode>(input, filterForUnique, ctx);
+ FilterFromHead<TDistinctConstraintNode>(input, filterForDistinct, ctx);
FilterFromHead<TPartOfSortedConstraintNode>(input, filter, ctx);
FilterFromHead<TPartOfChoppedConstraintNode>(input, filter, ctx);
FilterFromHead<TPartOfUniqueConstraintNode>(input, filterForUnique, ctx);