Skip to content
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

Allow UPDATE ON, UPSERT with partial set of input... #894

Merged

Conversation

dcherednik
Copy link
Member

columns in case of unique index.

Example:
table: pk, fk1, fk2. Uniq index: fk1, fk2.

To perform UPSERT INTO table (pk, fk1) we
need to read missed value fk2 from main table to
create lookup uniq index key.

Right now we have two lookups in to main table

  • first one has been described above
  • second we need to make to remove old value from index. It will be fixed in a next step.

columns in case of unique index.

Example:
  table: pk, fk1, fk2. Uniq index: fk1, fk2.

To perform UPSERT INTO table (pk, fk1) we
need to read missed value fk2 from main table to
create lookup uniq index key.

Right now we have two lookups in to main table
- first one has been described above
- second we need to make to remove old value
from index. It will be fixed in a next step.
Copy link

github-actions bot commented Jan 9, 2024

Note

This is an automated comment that will be appended during run.

🔴 linux-x86_64-relwithdebinfo: some tests FAILED for commit a882c95.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
57866 48647 0 83 9134 2

🔴 linux-x86_64-release-asan: some tests FAILED for commit a882c95.

Test history

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
14086 13922 0 78 78 8

@@ -77,7 +77,6 @@ TMaybe<TCondenseInputResult> CondenseInput(const TExprBase& input, TExprContext&
TVector<TCoArgument> stageArguments;

if (IsDqPureExpr(input)) {
YQL_ENSURE(input.Ref().GetTypeAnn()->GetKind() == ETypeAnnotationKind::List, "" << input.Ref().Dump());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что там если не List?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Там про использовании CondenseInput из сложных оптимайзеров, еще type анотация не прошла. Оно просто тут сегфолтится

.Done();

TExprNode::TPtr keys;

if (fixLookupKeys) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Добавь плз комментарий, что значит fixLookupKeys, но очевидно.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ага. Продублирую тут
// we need to left only table key columns to perform lookup
// unfortunately we can't do it inside lookup stage

usedIndexes.insert(indexDesc->Name);
break;
if (inputColumns.contains(indexKeyCol)) {
if (!usedIndexes.contains(indexDesc->Name) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can omit !usedIndexes.contains(indexDesc->Name) check, the code will work the same

Build<TCoNameValueTuple>(ctx, pos)
.Name().Build(x)
.Value<TCoNothing>()
.OptionalType(NCommon::BuildTypeExpr(pos, *columnType, ctx))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this does not work for Pg types, we'll need to somehow construct a pg null here (it corresponds to an empty TUnboxedValuePod with correct type)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh... And make sure we just return correct error in case of not null... Next pr?

@dcherednik dcherednik enabled auto-merge (squash) January 11, 2024 10:56
@dcherednik dcherednik merged commit 4366d88 into ydb-platform:main Jan 11, 2024
2 of 4 checks passed
This was referenced Jan 15, 2024
@niksaveliev niksaveliev mentioned this pull request Jan 29, 2024
@vitstn vitstn mentioned this pull request Jan 29, 2024
@starlinskiy starlinskiy mentioned this pull request Feb 12, 2024
@vitstn vitstn mentioned this pull request Feb 16, 2024
@dcherednik dcherednik deleted the fix_upsert_update_for_uniq_index branch March 22, 2024 10:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants