Skip to content

Conversation

@gridnevvvit
Copy link
Member

@gridnevvvit gridnevvvit commented Nov 7, 2025

Changelog entry

Changelog category

  • Not for changelog (changelog entry is not required)

Description for reviewers

fix issue #27021

Copilot AI review requested due to automatic review settings November 7, 2025 19:19
@gridnevvvit gridnevvvit requested a review from a team as a code owner November 7, 2025 19:19
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

🟢 2025-11-07 19:23:15 UTC The validation of the Pull Request description is successful.

@github-actions
Copy link

github-actions bot commented Nov 7, 2025

2025-11-07 19:22:39 UTC Pre-commit check linux-x86_64-relwithdebinfo for 2d10c18 has started.
2025-11-07 19:22:57 UTC Artifacts will be uploaded here
2025-11-07 19:25:23 UTC ya make is running...
🟡 2025-11-07 20:53:11 UTC Some tests failed, follow the links below. Going to retry failed tests...

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
38769 35955 0 1 2791 22

2025-11-07 20:53:34 UTC ya make is running... (failed tests rerun, try 2)
🟢 2025-11-07 21:05:58 UTC Tests successful.

Ya make output | Test bloat | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
43 (only retried tests) 28 0 0 0 15

🟢 2025-11-07 21:06:09 UTC Build successful.
🟢 2025-11-07 21:06:29 UTC ydbd size 2.3 GiB changed* by +2.8 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 371d924 merge: 2d10c18 diff diff %
ydbd size 2 431 882 792 Bytes 2 431 885 672 Bytes +2.8 KiB +0.000%
ydbd stripped size 516 543 408 Bytes 516 543 792 Bytes +384 Bytes +0.000%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes issue #27021 where RETURNING clauses fail when used with UPSERT/DELETE operations on tables with only NOT NULL fields when the data comes from query parameters of type List (via AS_TABLE).

  • Adds handling for TCoParameter nodes in the returning optimization logic to prevent incorrect wrapping
  • Introduces comprehensive test coverage for UPSERT and DELETE with RETURNING using parameterized List data
  • Tests both NOT NULL-only and nullable column scenarios to ensure the fix works correctly

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
ydb/core/kqp/opt/physical/effects/kqp_opt_phy_returning.cpp Adds TCoParameter check to prevent wrapping already-precomputed parameter inputs in TDqPrecompute nodes for both UPSERT and DELETE operations with RETURNING
ydb/core/kqp/ut/opt/kqp_returning_ut.cpp Adds helper function ExecuteReturningQueryWithParams and two comprehensive test cases validating the fix for UPSERT/DELETE with RETURNING using AS_TABLE with List parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


auto deleteParams = deleteParamsBuilder.Build();

// This should succeed, but currently fails with infinite loop error
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

This comment is misleading. Since this PR adds a fix for the issue (by handling TCoParameter in the optimization code), the test should now succeed. Consider updating the comment to reflect that this test validates the fix works correctly, e.g., "This should succeed with the fix for issue #27021".

Suggested change
// This should succeed, but currently fails with infinite loop error
// This should succeed with the fix for issue #27021

Copilot uses AI. Check for mistakes.
Comment on lines +804 to +817
if (QueryService) {
auto qdb = kikimr.GetQueryClient();
auto qSession = qdb.GetSession().GetValueSync().GetSession();
auto settings = NYdb::NQuery::TExecuteQuerySettings()
.Syntax(NYdb::NQuery::ESyntax::YqlV1);
auto insertResult = qSession.ExecuteQuery(
insertQuery, NYdb::NQuery::TTxControl::BeginTx().CommitTx(), insertParams, settings).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(insertResult.GetStatus(), EStatus::SUCCESS, insertResult.GetIssues().ToString());
} else {
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();
auto insertResult = session.ExecuteDataQuery(insertQuery, TTxControl::BeginTx().CommitTx(), insertParams).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(insertResult.GetStatus(), EStatus::SUCCESS, insertResult.GetIssues().ToString());
}
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

This code block is duplicated in both test functions (lines 804-817 and 926-939). Consider extracting this logic into a helper function similar to ExecuteReturningQueryWithParams to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +926 to +939
if (QueryService) {
auto qdb = kikimr.GetQueryClient();
auto qSession = qdb.GetSession().GetValueSync().GetSession();
auto settings = NYdb::NQuery::TExecuteQuerySettings()
.Syntax(NYdb::NQuery::ESyntax::YqlV1);
auto insertResult = qSession.ExecuteQuery(
insertQuery, NYdb::NQuery::TTxControl::BeginTx().CommitTx(), insertParams, settings).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(insertResult.GetStatus(), EStatus::SUCCESS, insertResult.GetIssues().ToString());
} else {
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();
auto insertResult = session.ExecuteDataQuery(insertQuery, TTxControl::BeginTx().CommitTx(), insertParams).ExtractValueSync();
UNIT_ASSERT_VALUES_EQUAL_C(insertResult.GetStatus(), EStatus::SUCCESS, insertResult.GetIssues().ToString());
}
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

This code block duplicates the logic from lines 804-817. Consider extracting this logic into a helper function similar to ExecuteReturningQueryWithParams to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.

auto params = paramsBuilder.Build();

// This should succeed, but currently fails with infinite loop error
Copy link

Copilot AI Nov 7, 2025

Choose a reason for hiding this comment

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

This comment is misleading. Since this PR adds a fix for the issue (by handling TCoParameter in the optimization code), the test should now succeed. Consider updating the comment to reflect that this test validates the fix works correctly, e.g., "This should succeed with the fix for issue #27021".

Suggested change
// This should succeed, but currently fails with infinite loop error
// This should succeed with the fix for issue #27021

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Nov 7, 2025

2025-11-07 19:23:03 UTC Pre-commit check linux-x86_64-release-asan for 2d10c18 has started.
2025-11-07 19:23:22 UTC Artifacts will be uploaded here
2025-11-07 19:25:41 UTC ya make is running...
🟡 2025-11-07 21:31:28 UTC Some tests failed, follow the links below. This fail is not in blocking policy yet

Ya make output | Test bloat

TESTS PASSED ERRORS FAILED SKIPPED MUTED?
15460 14747 0 416 263 34

🟢 2025-11-07 21:31:41 UTC Build successful.
🟢 2025-11-07 21:32:10 UTC ydbd size 3.8 GiB changed* by +10.7 KiB, which is < 100.0 KiB vs main: OK

ydbd size dash main: 371d924 merge: 2d10c18 diff diff %
ydbd size 4 073 133 088 Bytes 4 073 144 048 Bytes +10.7 KiB +0.000%
ydbd stripped size 1 511 887 336 Bytes 1 511 890 344 Bytes +2.9 KiB +0.000%

*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation

@gridnevvvit gridnevvvit merged commit dff4634 into ydb-platform:main Nov 7, 2025
22 checks passed
gridnevvvit added a commit to gridnevvvit/ydb that referenced this pull request Nov 11, 2025
gridnevvvit added a commit to gridnevvvit/ydb that referenced this pull request Nov 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants