-
Notifications
You must be signed in to change notification settings - Fork 638
Allow UPDATE ON, UPSERT with partial set of input... #894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,7 +48,11 @@ TVector<TExprBase> CreateColumnsToSelectToUpdateIndex( | |
return columnsToSelect; | ||
} | ||
|
||
TDqPhyPrecompute PrecomputeDict(const TCondenseInputResult& condenseResult, TPositionHandle pos, TExprContext& ctx) { | ||
} // namespace | ||
|
||
TDqPhyPrecompute PrecomputeCondenseInputResult(const TCondenseInputResult& condenseResult, | ||
TPositionHandle pos, TExprContext& ctx) | ||
{ | ||
auto computeDictStage = Build<TDqStage>(ctx, pos) | ||
.Inputs() | ||
.Add(condenseResult.StageInputs) | ||
|
@@ -70,8 +74,6 @@ TDqPhyPrecompute PrecomputeDict(const TCondenseInputResult& condenseResult, TPos | |
.Done(); | ||
} | ||
|
||
} // namespace | ||
|
||
TVector<std::pair<TExprNode::TPtr, const TIndexDescription*>> BuildSecondaryIndexVector( | ||
const TKikimrTableDescription& table, | ||
TPositionHandle pos, | ||
|
@@ -127,26 +129,81 @@ TSecondaryIndexes BuildSecondaryIndexVector(const TKikimrTableDescription& table | |
} | ||
|
||
TMaybeNode<TDqPhyPrecompute> PrecomputeTableLookupDict(const TDqPhyPrecompute& lookupKeys, | ||
const TKikimrTableDescription& table, const THashSet<TString>& dataColumns, | ||
const THashSet<TString>& keyColumns, TPositionHandle pos, TExprContext& ctx) | ||
const TKikimrTableDescription& table, const TVector<TExprBase>& columnsList, | ||
TPositionHandle pos, TExprContext& ctx, bool fixLookupKeys) | ||
{ | ||
auto lookupColumns = CreateColumnsToSelectToUpdateIndex(table.Metadata->KeyColumnNames, dataColumns, | ||
keyColumns, pos, ctx); | ||
|
||
auto lookupColumnsList = Build<TCoAtomList>(ctx, pos) | ||
.Add(lookupColumns) | ||
.Add(columnsList) | ||
.Done(); | ||
|
||
TExprNode::TPtr keys; | ||
|
||
// we need to left only table key columns to perform lookup | ||
// unfortunately we can't do it inside lookup stage | ||
if (fixLookupKeys) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Добавь плз комментарий, что значит fixLookupKeys, но очевидно. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ага. Продублирую тут |
||
auto keyArg = TCoArgument(ctx.NewArgument(pos, "key")); | ||
auto keysList = TCoArgument(ctx.NewArgument(pos, "keys_list")); | ||
TVector<TExprBase> keyLookupTuples; | ||
keyLookupTuples.reserve(table.Metadata->KeyColumnNames.size()); | ||
|
||
for (const auto& key : table.Metadata->KeyColumnNames) { | ||
keyLookupTuples.emplace_back( | ||
Build<TCoNameValueTuple>(ctx, pos) | ||
.Name().Build(key) | ||
.Value<TCoMember>() | ||
.Struct(keyArg) | ||
.Name().Build(key) | ||
.Build() | ||
.Done()); | ||
} | ||
|
||
auto list = Build<TCoToStream>(ctx, pos) | ||
.Input<TCoJust>() | ||
.Input<TCoMap>() | ||
.Input(keysList) | ||
.Lambda() | ||
.Args({keyArg}) | ||
.Body<TCoAsStruct>() | ||
.Add(keyLookupTuples) | ||
.Build() | ||
.Build() | ||
.Build() | ||
.Build() | ||
.Done().Ptr(); | ||
|
||
keys = Build<TDqStage>(ctx, pos) | ||
.Inputs() | ||
.Add(lookupKeys) | ||
.Build() | ||
.Program() | ||
.Args({keysList}) | ||
.Body(list) | ||
.Build() | ||
.Settings().Build() | ||
.Done().Ptr(); | ||
|
||
keys = Build<TDqPhyPrecompute>(ctx, pos) | ||
.Connection<TDqCnValue>() | ||
.Output() | ||
.Stage(keys) | ||
.Index().Build("0") | ||
.Build() | ||
.Build() | ||
.Done().Ptr(); | ||
} else { | ||
keys = lookupKeys.Ptr(); | ||
} | ||
|
||
auto lookupStage = Build<TDqStage>(ctx, pos) | ||
.Inputs() | ||
.Add(lookupKeys) | ||
.Add(keys) | ||
.Build() | ||
.Program() | ||
.Args({"keys_list"}) | ||
.Args({"keys_stage_arg"}) | ||
.Body<TKqpLookupTable>() | ||
.Table(BuildTableMeta(table, pos, ctx)) | ||
.LookupKeys<TCoIterator>() | ||
.List("keys_list") | ||
.List("keys_stage_arg") | ||
.Build() | ||
.Columns(lookupColumnsList) | ||
.Build() | ||
|
@@ -167,7 +224,17 @@ TMaybeNode<TDqPhyPrecompute> PrecomputeTableLookupDict(const TDqPhyPrecompute& l | |
return {}; | ||
} | ||
|
||
return PrecomputeDict(*condenseLookupResult, lookupKeys.Pos(), ctx); | ||
return PrecomputeCondenseInputResult(*condenseLookupResult, lookupKeys.Pos(), ctx); | ||
} | ||
|
||
TMaybeNode<TDqPhyPrecompute> PrecomputeTableLookupDict(const TDqPhyPrecompute& lookupKeys, | ||
const TKikimrTableDescription& table, const THashSet<TString>& dataColumns, | ||
const THashSet<TString>& keyColumns, TPositionHandle pos, TExprContext& ctx) | ||
{ | ||
auto lookupColumns = CreateColumnsToSelectToUpdateIndex(table.Metadata->KeyColumnNames, dataColumns, | ||
keyColumns, pos, ctx); | ||
|
||
return PrecomputeTableLookupDict(lookupKeys, table, lookupColumns, pos, ctx, false); | ||
} | ||
|
||
TExprBase MakeRowsFromDict(const TDqPhyPrecompute& dict, const TVector<TString>& dictKeys, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А что там если не List?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Там про использовании CondenseInput из сложных оптимайзеров, еще type анотация не прошла. Оно просто тут сегфолтится