Skip to content

Commit 1ccfde8

Browse files
authored
Integrate pushdown fixes (#20743)
2 parents cd8bd1f + 0170634 commit 1ccfde8

File tree

6 files changed

+34
-5
lines changed

6 files changed

+34
-5
lines changed

.github/config/muted_ya.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ ydb/core/keyvalue/ut_trace TKeyValueTracingTest.ReadSmall
1818
ydb/core/keyvalue/ut_trace TKeyValueTracingTest.WriteHuge
1919
ydb/core/keyvalue/ut_trace TKeyValueTracingTest.WriteSmall
2020
ydb/core/kqp/ut/cost KqpCost.OlapWriteRow
21-
ydb/core/kqp/ut/olap KqpDecimalColumnShard.TestAggregation
22-
ydb/core/kqp/ut/olap KqpDecimalColumnShard.TestFilterCompare
2321
ydb/core/kqp/ut/olap KqpOlapAggregations.BlockGenericWithDistinct
2422
ydb/core/kqp/ut/olap KqpOlapSysView.StatsSysViewBytesColumnActualization
2523
ydb/core/kqp/ut/olap KqpOlapSysView.StatsSysViewBytesDictActualization

ydb/core/kqp/opt/physical/kqp_opt_phy_olap_agg.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ bool CanBePushedDown(const TExprBase& trait, TExprContext& ctx)
6767
}
6868
auto aggApply = trait.Cast<TCoAggApply>();
6969
auto aggName = aggApply.Name();
70+
const auto& aggType = aggApply.Extractor().Ptr()->GetTypeAnn();
71+
if (const auto& nakedType = RemoveOptionality(*aggType); nakedType.GetKind() == ETypeAnnotationKind::Data) {
72+
if (GetDataTypeInfo(nakedType.Cast<TDataExprType>()->GetSlot()).Features & NUdf::EDataTypeFeatures::DecimalType)
73+
return false;
74+
}
7075
if (SupportedAggFuncs.find(aggName.StringValue()) != SupportedAggFuncs.end()) {
7176
return true;
7277
}

ydb/core/kqp/opt/physical/kqp_opt_phy_olap_filter.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,6 +312,24 @@ TMaybeNode<TExprBase> SafeCastPredicatePushdown(const TCoFlatMap& inputFlatmap,
312312
return ComparisonPushdown(parameters, predicate, ctx, pos);
313313
}
314314

315+
namespace {
316+
317+
//Workarownd for #19125
318+
NYql::NNodes::TCoUtf8 RemoveJsonPathUnnecessaryQuote(const NYql::NNodes::TCoUtf8& node, TExprContext& ctx) {
319+
const std::string_view& path = node.Literal().StringValue();
320+
if (UTF8Detect(path) == ASCII && path.starts_with("$.\"") && path.substr(3).ends_with("\"")) {
321+
const auto& nakedPath = path.substr(3, path.length()-4);
322+
for (auto c: nakedPath) {
323+
if (!isalpha(c) && !isdigit(c) && c != '_') {
324+
return node;
325+
}
326+
}
327+
return Build<TCoUtf8>(ctx, node.Pos()).Literal().Build(TString("$.") + nakedPath).Done();
328+
}
329+
return node;
330+
}
331+
332+
} //namespace
315333

316334
std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExprNode& argument, TExprContext& ctx, TPositionHandle pos, bool allowApply)
317335
{
@@ -346,7 +364,7 @@ std::vector<TExprBase> ConvertComparisonNode(const TExprBase& nodeIn, const TExp
346364

347365
auto builder = Build<TKqpOlapJsonValue>(ctx, pos)
348366
.Column(maybeColMember.Cast().Name())
349-
.Path(maybePathUtf8.Cast());
367+
.Path(RemoveJsonPathUnnecessaryQuote(maybePathUtf8.Cast(), ctx));
350368
if (maybeReturningType) {
351369
builder.ReturningType(maybeReturningType.Cast());
352370
} else {

ydb/core/kqp/opt/physical/predicate_collector.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ bool IsGoodTypeForArithmeticPushdown(const TTypeAnnotationNode& type, bool allow
111111

112112
bool IsGoodTypeForComparsionPushdown(const TTypeAnnotationNode& type, bool allowOlapApply) {
113113
const auto features = NUdf::GetDataTypeInfo(RemoveOptionality(type).Cast<TDataExprType>()->GetSlot()).Features;
114+
if (features & NUdf::EDataTypeFeatures::DecimalType) {
115+
return false;
116+
}
114117
return (NUdf::EDataTypeFeatures::CanCompare & features)
115118
&& (((NUdf::EDataTypeFeatures::NumericType | NUdf::EDataTypeFeatures::StringType) & features) ||
116119
(allowOlapApply && ((NUdf::EDataTypeFeatures::ExtDateType |
@@ -232,7 +235,7 @@ bool IsGoodTypesForPushdownCompare(const TTypeAnnotationNode& typeOne, const TTy
232235
const auto& rawOne = RemoveOptionality(typeOne);
233236
const auto& rawTwo = RemoveOptionality(typeTwo);
234237
if (IsSameAnnotation(rawOne, rawTwo))
235-
return true;
238+
return IsGoodTypeForComparsionPushdown(rawOne, options.AllowOlapApply);
236239

237240
const auto kindOne = rawOne.GetKind();
238241
const auto kindTwo = rawTwo.GetKind();

ydb/core/kqp/ut/olap/decimal_ut.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ Y_UNIT_TEST_SUITE(KqpDecimalColumnShard) {
173173
"[[[\"3.14\"];1;[4]];[[\"8.16\"];2;[3]];[[\"8.492\"];3;[2]];[[\"12.46\"];4;[1]]]");
174174

175175
tester.CheckQuery("SELECT * FROM `/Root/Table1` WHERE dec >= cast(\"8.492\" as decimal(22,9)) order by id",
176-
"[[[\"8.16\"];2;[3]];[[\"8.492\"];3;[2]];[[\"12.46\"];4;[1]]]");
176+
"[[[\"8.492\"];3;[2]];[[\"12.46\"];4;[1]]]");
177177
};
178178

179179
check(tester22);

ydb/core/kqp/ut/olap/json_ut.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,11 @@ Y_UNIT_TEST_SUITE(KqpOlapJson) {
654654
EXPECTED: [[4u;["{\"a\":\"a4\",\"b.c.d\":\"b4\"}"]];[14u;["{\"a\":\"a4\",\"b.c.d\":\"1b4\"}"]]]
655655
IDX_ND_SKIP_APPROVE: 0, 3, 2
656656
------
657+
READ: SELECT * FROM `/Root/ColumnTable` WHERE JSON_VALUE(Col2, "$.\"a\"") = "a4" ORDER BY Col1;
658+
EXPECTED: [[4u;["{\"a\":\"a4\",\"b.c.d\":\"b4\"}"]];[14u;["{\"a\":\"a4\",\"b.c.d\":\"1b4\"}"]]]
659+
IDX_ND_SKIP_APPROVE: 0, 3, 2
660+
------
661+
657662
READ: SELECT * FROM `/Root/ColumnTable` WHERE JSON_VALUE(Col2, "$.\"b.c.d111\"") = "1b5" ORDER BY Col1;
658663
EXPECTED: []
659664
IDX_ND_SKIP_APPROVE: 0, 5, 0

0 commit comments

Comments
 (0)