Skip to content

Commit 8cc0e51

Browse files
authored
[yt provider] Anonymous tables use single group by default (#5849)
1 parent d8d22ec commit 8cc0e51

File tree

18 files changed

+212
-1
lines changed

18 files changed

+212
-1
lines changed

ydb/library/yql/providers/yt/provider/yql_yt_datasink.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,15 @@ class TYtDataSink : public TDataProviderBase {
271271
ctx.NewAtom(res->Child(TYtWriteTable::idx_Settings)->Pos(), normalized, TNodeFlags::MultilineContent),
272272
ctx)
273273
);
274+
} else if (NYql::HasSetting(*res->Child(TYtWriteTable::idx_Table)->Child(TYtTable::idx_Settings), EYtSettingType::Anonymous)) {
275+
if (const auto mode = State_->Configuration->ColumnGroupMode.Get().GetOrElse(EColumnGroupMode::Disable); mode != EColumnGroupMode::Disable) {
276+
res = ctx.ChangeChild(*res, TYtWriteTable::idx_Settings,
277+
NYql::AddSetting(*res->Child(TYtWriteTable::idx_Settings),
278+
EYtSettingType::ColumnGroups,
279+
ctx.NewAtom(res->Child(TYtWriteTable::idx_Settings)->Pos(), NYql::GetSingleColumnGroupSpec(), TNodeFlags::MultilineContent),
280+
ctx)
281+
);
282+
}
274283
}
275284
auto mutationId = ++NextMutationId_;
276285
res = ctx.ChangeChild(*res, TYtWriteTable::idx_Settings,

ydb/library/yql/providers/yt/provider/yql_yt_op_settings.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,11 @@ TString NormalizeColumnGroupSpec(const TStringBuf spec) {
955955
}
956956
}
957957

958+
const TString& GetSingleColumnGroupSpec() {
959+
static TString GROUP = NYT::NodeToCanonicalYsonString(NYT::TNode::CreateMap()("default", NYT::TNode::CreateEntity()), NYson::EYsonFormat::Text);
960+
return GROUP;
961+
}
962+
958963
TExprNode::TPtr GetSetting(const TExprNode& settings, EYtSettingType type) {
959964
for (auto& setting : settings.Children()) {
960965
if (setting->ChildrenSize() != 0 && FromString<EYtSettingType>(setting->Child(0)->Content()) == type) {

ydb/library/yql/providers/yt/provider/yql_yt_op_settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@ TExprNode::TPtr ToAtomList(const TContainer& columns, TPositionHandle pos, TExpr
142142

143143
bool ValidateColumnGroups(const TExprNode& setting, const TStructExprType& rowType, TExprContext& ctx);
144144
TString NormalizeColumnGroupSpec(const TStringBuf spec);
145+
const TString& GetSingleColumnGroupSpec();
145146

146147
TExprNode::TPtr ToColumnPairList(const TVector<std::pair<TString, bool>>& columns, TPositionHandle pos, TExprContext& ctx);
147148

ydb/library/yql/providers/yt/provider/yql_yt_physical_finalizing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2681,7 +2681,7 @@ class TYtPhysicalFinalizingTransformer : public TSyncTransformerBase {
26812681
}
26822682
if (EColumnGroupMode::Single == mode) {
26832683
if (fullUsage[i]) {
2684-
groupSpecs[i] = NYT::NodeToCanonicalYsonString(NYT::TNode::CreateMap()("default", NYT::TNode::CreateEntity()), NYson::EYsonFormat::Text);
2684+
groupSpecs[i] = NYql::GetSingleColumnGroupSpec();
26852685
}
26862686
} else {
26872687
if (fullUsage[i]) {

ydb/library/yql/tests/sql/sql2yql/canondata/result.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4325,6 +4325,20 @@
43254325
"uri": "https://{canondata_backend}/1937027/bbc35c51807ca32a384973d8a730422ad871c54c/resource.tar.gz#test_sql2yql.test_column_group-hint_/sql.yql"
43264326
}
43274327
],
4328+
"test_sql2yql.test[column_group-hint_anon]": [
4329+
{
4330+
"checksum": "dbb0cca1127bb0c111eaf0a628b2b9a1",
4331+
"size": 4108,
4332+
"uri": "https://{canondata_backend}/1942525/2065de9dd4b18a7276f6c5d85e09a5754c9a2fd8/resource.tar.gz#test_sql2yql.test_column_group-hint_anon_/sql.yql"
4333+
}
4334+
],
4335+
"test_sql2yql.test[column_group-hint_anon_groups]": [
4336+
{
4337+
"checksum": "1f44e91a47e42b8d5876da52098a98ce",
4338+
"size": 4144,
4339+
"uri": "https://{canondata_backend}/1942525/2065de9dd4b18a7276f6c5d85e09a5754c9a2fd8/resource.tar.gz#test_sql2yql.test_column_group-hint_anon_groups_/sql.yql"
4340+
}
4341+
],
43284342
"test_sql2yql.test[column_group-hint_append_fail]": [
43294343
{
43304344
"checksum": "18aacc13c7921e65e61411ea0a31136e",
@@ -23519,6 +23533,20 @@
2351923533
"uri": "https://{canondata_backend}/1937027/bbc35c51807ca32a384973d8a730422ad871c54c/resource.tar.gz#test_sql_format.test_column_group-hint_/formatted.sql"
2352023534
}
2352123535
],
23536+
"test_sql_format.test[column_group-hint_anon]": [
23537+
{
23538+
"checksum": "0a7f14733fa0206794e5c41780561323",
23539+
"size": 230,
23540+
"uri": "https://{canondata_backend}/1942525/2065de9dd4b18a7276f6c5d85e09a5754c9a2fd8/resource.tar.gz#test_sql_format.test_column_group-hint_anon_/formatted.sql"
23541+
}
23542+
],
23543+
"test_sql_format.test[column_group-hint_anon_groups]": [
23544+
{
23545+
"checksum": "554c312c9220887717b03eb9a4392cb3",
23546+
"size": 273,
23547+
"uri": "https://{canondata_backend}/1942525/2065de9dd4b18a7276f6c5d85e09a5754c9a2fd8/resource.tar.gz#test_sql_format.test_column_group-hint_anon_groups_/formatted.sql"
23548+
}
23549+
],
2352223550
"test_sql_format.test[column_group-hint_append_fail]": [
2352323551
{
2352423552
"checksum": "d8756aff7c76d47d50affb769ec2cd4c",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
in Input input.txt
2+
providers yt
3+
pragma yt.ColumnGroupMode="disable"
4+
pragma yt.OptimizeFor="scan"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
in Input input.txt
2+
providers yt
3+
pragma yt.ColumnGroupMode="perusage"
4+
pragma yt.OptimizeFor="scan"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
in Input input.txt
2+
providers yt
3+
pragma yt.ColumnGroupMode="single"
4+
pragma yt.OptimizeFor="scan"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
USE plato;
2+
3+
$i = select * from Input where a > "a";
4+
5+
select a,b,c,d from $i;
6+
select c,d,e,f from $i;
7+
8+
-- Forces single group for $i
9+
insert into @tmp select * from $i;
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
in Input input.txt
2+
providers yt
3+
pragma yt.ColumnGroupMode="disable"
4+
pragma yt.OptimizeFor="scan"

0 commit comments

Comments
 (0)