Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
shnikd committed Jan 24, 2024
1 parent f97111f commit 526bd01
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
40 changes: 24 additions & 16 deletions ydb/core/kqp/provider/yql_kikimr_provider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,13 @@ struct TKikimrData {
const TKikimrTableDescription* TKikimrTablesData::EnsureTableExists(const TString& cluster,
const TString& table, TPositionHandle pos, TExprContext& ctx) const
{
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

auto tablePath = table;
if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
if (TempTablesState) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
}
}

auto desc = Tables.FindPtr(std::make_pair(cluster, tablePath));
Expand All @@ -141,11 +143,13 @@ const TKikimrTableDescription* TKikimrTablesData::EnsureTableExists(const TStrin
}

TKikimrTableDescription& TKikimrTablesData::GetOrAddTable(const TString& cluster, const TString& database, const TString& table, ETableType tableType) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

auto tablePath = table;
if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
if (TempTablesState) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
}
}

if (!Tables.FindPtr(std::make_pair(cluster, tablePath))) {
Expand All @@ -165,11 +169,13 @@ TKikimrTableDescription& TKikimrTablesData::GetOrAddTable(const TString& cluster
}

TKikimrTableDescription& TKikimrTablesData::GetTable(const TString& cluster, const TString& table) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

auto tablePath = table;
if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
if (TempTablesState) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
}
}

auto desc = Tables.FindPtr(std::make_pair(cluster, tablePath));
Expand All @@ -181,11 +187,13 @@ TKikimrTableDescription& TKikimrTablesData::GetTable(const TString& cluster, con
const TKikimrTableDescription& TKikimrTablesData::ExistingTable(const TStringBuf& cluster,
const TStringBuf& table) const
{
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

auto tablePath = table;
if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
if (TempTablesState) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, true);

if (tempTableInfoIt != TempTablesState->TempTables.end()) {
tablePath = tempTableInfoIt->first;
}
}

auto desc = Tables.FindPtr(std::make_pair(TString(cluster), TString(tablePath)));
Expand Down
8 changes: 5 additions & 3 deletions ydb/core/kqp/provider/yql_kikimr_provider.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,10 +319,12 @@ class TKikimrTransactionContextBase : public TThrRefBase {
auto newOp = TYdbOperation(op.GetOperation());
TPosition pos(op.GetPosition().GetColumn(), op.GetPosition().GetRow());

auto tempTableInfoIt = TempTablesState->FindInfo(table, false);
if (TempTablesState) {
auto tempTableInfoIt = TempTablesState->FindInfo(table, false);

if (tempTableInfoIt != TempTablesState->TempTables.end()) {
table = tempTableInfoIt->first + TempTablesState->SessionId;
if (tempTableInfoIt != TempTablesState->TempTables.end()) {
table = tempTableInfoIt->first + TempTablesState->SessionId;
}
}

const auto info = tableInfoMap.FindPtr(table);
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 @@ -1180,7 +1180,7 @@ class TKqpSessionActor : public TActorBootstrapped<TKqpSessionActor> {
return {{true, {JoinPath({path.first, path.second}), {path.second, path.first, userToken}}}};
}

auto it = TempTablesState.FindInfo(JoinPath({path.first, path.second}));
auto it = TempTablesState.FindInfo(JoinPath({path.first, path.second}), true);
if (it == TempTablesState.TempTables.end()) {
return std::nullopt;
}
Expand Down

0 comments on commit 526bd01

Please sign in to comment.