-
Notifications
You must be signed in to change notification settings - Fork 734
Fix returning if input is a parameter #28414
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
Conversation
|
🟢 |
|
⚪ ⚪ Ya make output | Test bloat | Test bloat
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
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.
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
TCoParameternodes 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 |
Copilot
AI
Nov 7, 2025
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.
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".
| // This should succeed, but currently fails with infinite loop error | |
| // This should succeed with the fix for issue #27021 |
| 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()); | ||
| } |
Copilot
AI
Nov 7, 2025
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.
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.
| 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()); | ||
| } |
Copilot
AI
Nov 7, 2025
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.
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.
|
|
||
| auto params = paramsBuilder.Build(); | ||
|
|
||
| // This should succeed, but currently fails with infinite loop error |
Copilot
AI
Nov 7, 2025
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.
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".
| // This should succeed, but currently fails with infinite loop error | |
| // This should succeed with the fix for issue #27021 |
|
⚪
🟢
*please be aware that the difference is based on comparing your commit and the last completed build from the post-commit, check comparation |
Changelog entry
Changelog category
Description for reviewers
fix issue #27021