-
Notifications
You must be signed in to change notification settings - Fork 691
Capture TablePathPrefix (and other parts of the parser context) in CREATE VIEW #8991
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
Changes from 2 commits
69cb817
414cd61
d2af383
74f90e8
cfbc221
bc60562
a102202
54a8e01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -408,6 +408,46 @@ Y_UNIT_TEST_SUITE(TSelectFromViewTest) { | |
CompareResults(etalonResults, selectFromViewResults); | ||
} | ||
|
||
Y_UNIT_TEST(OneTableUsingRelativeName) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like to write an extensive test suite for views after this PR, so I add only a basic test of the new feature. |
||
TKikimrRunner kikimr; | ||
|
||
auto& runtime = *kikimr.GetTestServer().GetRuntime(); | ||
runtime.SetLogPriority(NKikimrServices::FLAT_TX_SCHEMESHARD, NLog::PRI_DEBUG); | ||
|
||
EnableViewsFeatureFlag(kikimr); | ||
auto session = kikimr.GetTableClient().CreateSession().GetValueSync().GetSession(); | ||
|
||
constexpr const char* viewName = "TheView"; | ||
constexpr const char* testTable = "Test"; | ||
const auto innerQuery = std::format(R"( | ||
SELECT * FROM {} | ||
)", | ||
testTable | ||
); | ||
|
||
const TString creationQuery = std::format(R"( | ||
CREATE VIEW {} WITH (security_invoker = true) AS {}; | ||
)", | ||
viewName, | ||
innerQuery | ||
); | ||
ExecuteDataDefinitionQuery(session, creationQuery); | ||
|
||
const auto etalonResults = ExecuteDataModificationQuery(session, std::format(R"( | ||
SELECT * FROM ({}); | ||
)", | ||
innerQuery | ||
) | ||
); | ||
const auto selectFromViewResults = ExecuteDataModificationQuery(session, std::format(R"( | ||
SELECT * FROM {}; | ||
)", | ||
viewName | ||
) | ||
); | ||
CompareResults(etalonResults, selectFromViewResults); | ||
} | ||
|
||
Y_UNIT_TEST(DisabledFeatureFlag) { | ||
TKikimrRunner kikimr(TKikimrSettings().SetWithSampleTables(false)); | ||
auto session = kikimr.GetTableClient().CreateSession().GetValueSync().GetSession(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
syntax = "proto3"; | ||
|
||
package NYql.NProto; | ||
|
||
option java_package = "com.yandex.yql.proto"; | ||
|
||
message TTranslationSettings { | ||
optional string PathPrefix = 1; | ||
optional uint32 SyntaxVersion = 2; | ||
optional bool AnsiLexer = 3; | ||
optional bool Antlr4Parser = 4; | ||
optional bool PgParser = 5; | ||
repeated string Pragmas = 6; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
PROTO_LIBRARY() | ||
|
||
SRCS( | ||
translation_settings.proto | ||
) | ||
|
||
EXCLUDE_TAGS(GO_PROTO) | ||
|
||
END() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
#pragma once | ||
|
||
#include <ydb/library/yql/core/pg_settings/guc_settings.h> | ||
#include <ydb/library/yql/sql/settings/protos/translation_settings.pb.h> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. не надо ссылаться на protobuf-ы в основной либе сделайте отдельную library, в которой будет save/load в protobuf классы и вообще этот protobuf и library унесите в ydb There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Не знаю, как унести в YDB, учитывая, что эта библиотека нужна в В отдельную библиотеку выделил, но она по-прежнему лежит в YQL юрисдикции: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Унёс всё в YDB. Мотивация следующая:
Важно отметить, что теперь, когда мы сериализуем контекст в KQP, этот процесс становится по смыслу равен сохранению применённых дефолтных настроек парсера в теле view. Query replay для тех же целей запоминает query type, с которым был выполнен запрос. Мы могли бы делать так же (query type было бы вполне достаточно), но поскольку view - это объект из мира парсера, то мы выбрали формат более подходящий для объекта из парсера. |
||
|
||
#include <util/generic/hash.h> | ||
#include <util/generic/hash_set.h> | ||
|
@@ -125,6 +126,9 @@ namespace NSQLTranslation { | |
|
||
TMaybe<TString> ApplicationName; | ||
bool PgSortNulls = false; | ||
|
||
NYql::NProto::TTranslationSettings Serialize() const; | ||
void UpdateWith(const NYql::NProto::TTranslationSettings& serializedSettings); | ||
}; | ||
|
||
bool ParseTranslationSettings(const TString& query, NSQLTranslation::TTranslationSettings& settings, NYql::TIssues& issues); | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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 change is needed for the intent determination transformer to be able to handle the following query:
The same (i.e. nothing) is done in HandleCreateObject 12 lines above.