diff options
author | VPolka <39378135+VPolka@users.noreply.github.com> | 2024-02-15 00:41:22 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-02-15 00:41:22 +0100 |
commit | 2d28de34afcf82f5c3ff12525eac003cc6b922d3 (patch) | |
tree | 85cba48cd6b28d59b188e2b6c7e2559039b20bdb | |
parent | 91d6e34e5f9c137d632892a83d2b78651b5f7e82 (diff) | |
download | ydb-2d28de34afcf82f5c3ff12525eac003cc6b922d3.tar.gz |
Add getting ast for cache and pg const as params for recompiling (#1749)
-rw-r--r-- | ydb/core/kqp/compile_service/kqp_compile_actor.cpp | 2 | ||||
-rw-r--r-- | ydb/core/kqp/compile_service/kqp_compile_service.cpp | 5 | ||||
-rw-r--r-- | ydb/core/kqp/ut/pg/kqp_pg_ut.cpp | 32 |
3 files changed, 37 insertions, 2 deletions
diff --git a/ydb/core/kqp/compile_service/kqp_compile_actor.cpp b/ydb/core/kqp/compile_service/kqp_compile_actor.cpp index 29fa1de3bf..69e2487086 100644 --- a/ydb/core/kqp/compile_service/kqp_compile_actor.cpp +++ b/ydb/core/kqp/compile_service/kqp_compile_actor.cpp @@ -510,7 +510,7 @@ void ApplyServiceConfig(TKikimrConfiguration& kqpConfig, const TTableServiceConf kqpConfig.BindingsMode = RemapBindingsMode(serviceConfig.GetBindingsMode()); kqpConfig.PredicateExtract20 = serviceConfig.GetPredicateExtract20(); kqpConfig.IndexAutoChooserMode = serviceConfig.GetIndexAutoChooseMode(); - kqpConfig.EnablePgConstsToParams = serviceConfig.GetEnablePgConstsToParams(); + kqpConfig.EnablePgConstsToParams = serviceConfig.GetEnablePgConstsToParams() && serviceConfig.GetEnableAstCache(); kqpConfig.ExtractPredicateRangesLimit = serviceConfig.GetExtractPredicateRangesLimit(); if (const auto limit = serviceConfig.GetResourceManager().GetMkqlHeavyProgramMemoryLimit()) { diff --git a/ydb/core/kqp/compile_service/kqp_compile_service.cpp b/ydb/core/kqp/compile_service/kqp_compile_service.cpp index b0da00f2e8..f40d8348b6 100644 --- a/ydb/core/kqp/compile_service/kqp_compile_service.cpp +++ b/ydb/core/kqp/compile_service/kqp_compile_service.cpp @@ -687,6 +687,8 @@ private: } if (compileResult || request.Query) { + QueryCache.EraseByUid(request.Uid); + Counters->ReportCompileRequestCompile(dbCounters); NWilson::TSpan compileServiceSpan(TWilsonKqp::CompileService, ev->Get() ? std::move(ev->TraceId) : NWilson::TTraceId(), "CompileService"); @@ -696,7 +698,8 @@ private: ev->Cookie, std::move(ev->Get()->IntrestedInResult), ev->Get()->UserRequestContext, ev->Get() ? std::move(ev->Get()->Orbit) : NLWTrace::TOrbit(), - std::move(compileServiceSpan), std::move(ev->Get()->TempTablesState)); + std::move(compileServiceSpan), std::move(ev->Get()->TempTablesState), + TableServiceConfig.GetEnableAstCache() ? ECompileActorAction::PARSE : ECompileActorAction::COMPILE); if (!RequestsQueue.Enqueue(std::move(compileRequest))) { Counters->ReportCompileRequestRejected(dbCounters); diff --git a/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp b/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp index 1066a40bc5..5f01ec1ef5 100644 --- a/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp +++ b/ydb/core/kqp/ut/pg/kqp_pg_ut.cpp @@ -3840,6 +3840,38 @@ Y_UNIT_TEST_SUITE(KqpPg) { UNIT_ASSERT(result.GetIssues().ToString().Contains("invalid input syntax for type integer: \"a\"")); } } + + { + // Check recompile + { + auto result = db.ExecuteQuery(R"( + CREATE TABLE RecompileTable (id int primary key); + )", NYdb::NQuery::TTxControl::NoTx(), settings).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + + result = db.ExecuteQuery(R"( + INSERT INTO RecompileTable (id) VALUES (1); + )", NYdb::NQuery::TTxControl::BeginTx().CommitTx(), settings).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + + result = db.ExecuteQuery(R"( + DROP TABLE RecompileTable; + )", NYdb::NQuery::TTxControl::NoTx(), settings).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + + result = db.ExecuteQuery(R"( + CREATE TABLE RecompileTable (id int primary key); + )", NYdb::NQuery::TTxControl::NoTx(), settings).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + + result = db.ExecuteQuery(R"( + INSERT INTO RecompileTable (id) VALUES (1); + )", NYdb::NQuery::TTxControl::BeginTx().CommitTx(), settings).ExtractValueSync(); + UNIT_ASSERT_VALUES_EQUAL_C(result.GetStatus(), EStatus::SUCCESS, result.GetIssues().ToString()); + auto stats = NYdb::TProtoAccessor::GetProto(*result.GetStats()); + UNIT_ASSERT_VALUES_EQUAL(stats.compilation().from_cache(), false); + } + } } Y_UNIT_TEST(MkqlTerminate) { |