Skip to content

Commit

Permalink
Write to replay log before ensuring the query is prepared + minor sty…
Browse files Browse the repository at this point in the history
…le fixes
  • Loading branch information
jepett0 committed Feb 15, 2024
1 parent 23edc19 commit ae3f2a4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
5 changes: 2 additions & 3 deletions ydb/core/kqp/compile_service/kqp_compile_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,15 +413,14 @@ class TKqpCompileActor : public TActorBootstrapped<TKqpCompileActor> {
KqpCompileResult = TKqpCompileResult::Make(Uid, status, kqpResult.Issues(), maxReadType, std::move(QueryId));

if (status == Ydb::StatusIds::SUCCESS) {
YQL_ENSURE(kqpResult.PreparingQuery);

auto collectedSchemeData = Gateway->GetCollectedSchemeData();
AddMessageToReplayLog(kqpResult.QueryPlan, collectedSchemeData);
EraseIf(collectedSchemeData, [](const NKikimrKqp::TKqpTableMetadataProto& metadata) {
return !metadata.HasKind() || static_cast<EKikimrTableKind>(metadata.GetKind()) != EKikimrTableKind::View;
});

FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, std::move(collectedSchemeData));
YQL_ENSURE(kqpResult.PreparingQuery);
FillCompileResult(std::move(kqpResult.PreparingQuery), queryType, collectedSchemeData);

auto now = TInstant::Now();
auto duration = now - StartTime;
Expand Down
1 change: 1 addition & 0 deletions ydb/core/kqp/session_actor/kqp_query_state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ std::unique_ptr<TEvTxProxySchemeCache::TEvNavigateKeySet> TKqpQueryState::BuildN
return std::make_unique<TEvTxProxySchemeCache::TEvNavigateKeySet>(navigate.Release());
}


bool TKqpQueryState::SaveAndCheckCompileResult(TEvKqp::TEvCompileResponse* ev) {
CompileResult = ev->CompileResult;
YQL_ENSURE(CompileResult);
Expand Down
13 changes: 6 additions & 7 deletions ydb/core/kqp/ut/view/view_ut.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <ydb/public/sdk/cpp/client/ydb_proto/accessor.h>

#include <ydb/core/kqp/ut/common/kqp_ut_common.h>
#include <ydb/library/yql/sql/sql.h>
#include <ydb/library/yql/utils/log/log.h>
#include <ydb/public/sdk/cpp/client/ydb_proto/accessor.h>

#include <util/folder/filelist.h>

Expand Down Expand Up @@ -96,8 +95,8 @@ int GetInteger(const TValue& value) {
return TValueParser(value).GetInt32();
}

TMaybe<bool> GetFromCache(const TQueryStats& stats) {
const auto& proto = NYdb::TProtoAccessor::GetProto(stats);
TMaybe<bool> GetFromCacheStat(const TQueryStats& stats) {
const auto& proto = TProtoAccessor::GetProto(stats);
if (!proto.Hascompilation()) {
return Nothing();
}
Expand All @@ -106,9 +105,9 @@ TMaybe<bool> GetFromCache(const TQueryStats& stats) {

void AssertFromCache(const TMaybe<TQueryStats>& stats, bool expectedValue) {
UNIT_ASSERT(stats.Defined());
const auto fromCache = GetFromCache(*stats);
UNIT_ASSERT_C(fromCache.Defined(), stats->ToString());
UNIT_ASSERT_VALUES_EQUAL_C(*fromCache, expectedValue, stats->ToString());
const auto isFromCache = GetFromCacheStat(*stats);
UNIT_ASSERT_C(isFromCache.Defined(), stats->ToString());
UNIT_ASSERT_VALUES_EQUAL_C(*isFromCache, expectedValue, stats->ToString());
}

void CompareResults(const TDataQueryResult& first, const TDataQueryResult& second) {
Expand Down

0 comments on commit ae3f2a4

Please sign in to comment.