Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ydb/core/kqp/session_actor/kqp_query_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -432,14 +432,14 @@ class TKqpQueryState : public TNonCopyable {
return true;
}

TKqpPhyTxHolder::TConstPtr GetCurrentPhyTx(bool isBatchQuery = false) {
TKqpPhyTxHolder::TConstPtr GetCurrentPhyTx(bool isBatchQuery, NMiniKQL::TTypeEnvironment& txTypeEnv) {
const auto& phyQuery = PreparedQuery->GetPhysicalQuery();
auto tx = PreparedQuery->GetPhyTxOrEmpty(CurrentTx);

if (TxCtx->CanDeferEffects() && !isBatchQuery) {
// Olap sinks require separate tnx with commit.
while (tx && tx->GetHasEffects() && !TxCtx->HasOlapTable) {
QueryData->CreateKqpValueMap(tx);
QueryData->PrepareParameters(tx, PreparedQuery, txTypeEnv);
bool success = TxCtx->AddDeferredEffect(tx, QueryData);
YQL_ENSURE(success);
if (CurrentTx + 1 < phyQuery.TransactionsSize()) {
Expand Down
2 changes: 1 addition & 1 deletion ydb/core/kqp/session_actor/kqp_session_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1169,7 +1169,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {

TKqpPhyTxHolder::TConstPtr tx;
try {
tx = QueryState->GetCurrentPhyTx(isBatchQuery);
tx = QueryState->GetCurrentPhyTx(isBatchQuery, QueryState->TxCtx->TxAlloc->TypeEnv);
} catch (const yexception& ex) {
ythrow TRequestFail(Ydb::StatusIds::BAD_REQUEST) << ex.what();
}
Expand Down
39 changes: 39 additions & 0 deletions ydb/core/kqp/ut/query/kqp_params_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,45 @@ Y_UNIT_TEST_SUITE(KqpParams) {
UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::BAD_REQUEST, result.GetIssues().ToString());
}

Y_UNIT_TEST_TWIN(MissingOptionalParameter, UseSink) {
NKikimrConfig::TAppConfig appConfig;
appConfig.MutableTableServiceConfig()->SetEnableOltpSink(UseSink);
auto settings = TKikimrSettings()
.SetAppConfig(appConfig)
.SetWithSampleTables(true);
TKikimrRunner kikimr(settings);
auto db = kikimr.GetTableClient();
auto session = db.CreateSession().GetValueSync().GetSession();

{
auto params = db.GetParamsBuilder()
.AddParam("$_amount")
.Uint64(42)
.Build()
.Build();
auto result = session.ExecuteDataQuery(Q_(R"(
--!syntax_v1

DECLARE $_amount AS Uint64;
DECLARE $_comment AS String?;

UPSERT INTO `/Root/Test` (Group, Name, Amount, Comment) VALUES
(1u, "test", $_amount, $_comment);
)"), TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx(), params).ExtractValueSync();

UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString());
}

{
auto result = session.ExecuteDataQuery(Q_(R"(
SELECT * FROM `/Root/Test` WHERE Group = 1 AND Name = "test";
)"), TTxControl::BeginTx(TTxSettings::SerializableRW()).CommitTx()).ExtractValueSync();
UNIT_ASSERT(result.IsSuccess());

CompareYson(R"([[[42u];#;[1u];["test"]]])", FormatResultSetYson(result.GetResultSet(0)));
}
}

Y_UNIT_TEST(BadParameterType) {
TKikimrRunner kikimr;
auto db = kikimr.GetTableClient();
Expand Down
Loading