Skip to content

Commit f47f575

Browse files
committed
init
1 parent bc5b8c1 commit f47f575

File tree

8 files changed

+75
-1
lines changed

8 files changed

+75
-1
lines changed

ydb/library/yql/providers/config/yql_config_provider.cpp

+34-1
Original file line numberDiff line numberDiff line change
@@ -260,14 +260,22 @@ namespace {
260260
for (size_t i = 3; i < node->ChildrenSize(); ++i) {
261261
if (node->Child(i)->IsCallable("EvaluateAtom")) {
262262
hasPendingEvaluations = true;
263-
return res;
263+
break;
264264
}
265265
if (!EnsureAtom(*node->Child(i), ctx)) {
266266
return {};
267267
}
268268
args.push_back(node->Child(i)->Content());
269269
}
270270

271+
if (hasPendingEvaluations) {
272+
if (!ValidateEvaluation(command, *node, ctx)) {
273+
return {};
274+
}
275+
276+
return res;
277+
}
278+
271279
if (!ApplyFlag(ctx.GetPosition(node->Child(2)->Pos()), command, args, ctx)) {
272280
return {};
273281
}
@@ -460,6 +468,28 @@ namespace {
460468
return true;
461469
}
462470

471+
bool ValidateEvaluation(const TStringBuf name, const TExprNode& node, TExprContext& ctx) {
472+
if (name == "AddFileByUrl" || name == "AddFolderByUrl") {
473+
if (node.ChildrenSize() < 4) {
474+
ctx.AddError(TIssue(ctx.GetPosition(node.Pos()), TStringBuilder() << "Expected at least 5 arguments, but got " << node.ChildrenSize()));
475+
return false;
476+
}
477+
478+
if (node.Child(3)->IsCallable("EvaluateAtom")) {
479+
return true;
480+
}
481+
482+
if (!PendingEvaluationFiles.insert(TString(node.Child(3)->Content())).second) {
483+
ctx.AddError(TIssue(ctx.GetPosition(node.Pos()), TStringBuilder() << "Detected evaluation cycle for file: " << node.Child(3)->Content()));
484+
return false;
485+
}
486+
487+
return true;
488+
} else {
489+
return true;
490+
}
491+
}
492+
463493
bool ApplyFlag(const TPosition& pos, const TStringBuf name, const TVector<TStringBuf>& args, TExprContext& ctx) {
464494
if (!IsSettingAllowed(pos, name, ctx)) {
465495
return false;
@@ -991,6 +1021,7 @@ namespace {
9911021
return false;
9921022
}
9931023

1024+
PendingEvaluationFiles.erase(TString(args[0]));
9941025
TStringBuf token = args.size() == 3 ? args[2] : TStringBuf();
9951026
if (token) {
9961027
if (auto cred = Types.Credentials->FindCredential(token)) {
@@ -1110,6 +1141,7 @@ namespace {
11101141
return false;
11111142
}
11121143

1144+
PendingEvaluationFiles.erase(TString(args[0]));
11131145
TStringBuf token = args.size() == 3 ? args[2] : TStringBuf();
11141146
if (token) {
11151147
if (auto cred = Types.Credentials->FindCredential(token)) {
@@ -1206,6 +1238,7 @@ namespace {
12061238
TString Username;
12071239
const TAllowSettingPolicy Policy;
12081240
TOperationStatistics Statistics;
1241+
THashSet<TString> PendingEvaluationFiles;
12091242
};
12101243
}
12111244

ydb/library/yql/tests/sql/dq_file/part8/canondata/result.json

+5
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
}
2222
],
2323
"test.test[action-evaluate_pure--Results]": [],
24+
"test.test[action-file_cycle--Results]": [
25+
{
26+
"uri": "file://test.test_action-file_cycle--Results_/extracted"
27+
}
28+
],
2429
"test.test[action-nested_eval-default.txt-Analyze]": [
2530
{
2631
"checksum": "b4dd508a329723c74293d80f0278c705",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<tmp_path>/program.sql:<main>: Error: Pre type annotation
2+
3+
<tmp_path>/program.sql:<main>:2:18: Error: Detected evaluation cycle for file: f
4+
pragma file("f", $p);
5+
^

ydb/library/yql/tests/sql/sql2yql/canondata/result.json

+14
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@
412412
"uri": "https://{canondata_backend}/1936947/659b615f15086142a8960946dabd06b519d43335/resource.tar.gz#test_sql2yql.test_action-export_action_/sql.yql"
413413
}
414414
],
415+
"test_sql2yql.test[action-file_cycle]": [
416+
{
417+
"checksum": "095c2c315ba26037554c056a02f5af05",
418+
"size": 343,
419+
"uri": "https://{canondata_backend}/1871002/4d084a25cea0c62bd09f3c9e9e7c2b56d112c5b1/resource.tar.gz#test_sql2yql.test_action-file_cycle_/sql.yql"
420+
}
421+
],
415422
"test_sql2yql.test[action-inline_action]": [
416423
{
417424
"checksum": "d019514b3fd1f8a7c0f9d37db4231b93",
@@ -17891,6 +17898,13 @@
1789117898
"uri": "https://{canondata_backend}/1871102/17992aa919577eec0f31ef167084ab70f41ccc80/resource.tar.gz#test_sql_format.test_action-export_action_/formatted.sql"
1789217899
}
1789317900
],
17901+
"test_sql_format.test[action-file_cycle]": [
17902+
{
17903+
"checksum": "5476df82092007027246993752e24f68",
17904+
"size": 45,
17905+
"uri": "https://{canondata_backend}/1871002/4d084a25cea0c62bd09f3c9e9e7c2b56d112c5b1/resource.tar.gz#test_sql_format.test_action-file_cycle_/formatted.sql"
17906+
}
17907+
],
1789417908
"test_sql_format.test[action-inline_action]": [
1789517909
{
1789617910
"checksum": "7da554999ea3520183678c730ae2fffb",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
xfail
2+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
$p=FileContent("f");
2+
pragma file("f", $p);
3+

ydb/library/yql/tests/sql/yt_native_file/part8/canondata/result.json

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@
2020
"uri": "https://{canondata_backend}/1900335/4871e48d29e4933514d3ed0c9c5d19de571eda1f/resource.tar.gz#test.test_action-evaluate_pure--Results_/results.txt"
2121
}
2222
],
23+
"test.test[action-file_cycle--Debug]": [],
24+
"test.test[action-file_cycle--Plan]": [],
25+
"test.test[action-file_cycle--Results]": [
26+
{
27+
"uri": "file://test.test_action-file_cycle--Results_/extracted"
28+
}
29+
],
2330
"test.test[action-nested_eval-default.txt-Debug]": [
2431
{
2532
"checksum": "79af7d3cdd20c4123718aae10c3202d7",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<tmp_path>/program.sql:<main>: Error: Pre type annotation
2+
3+
<tmp_path>/program.sql:<main>:2:18: Error: Detected evaluation cycle for file: f
4+
pragma file("f", $p);
5+
^

0 commit comments

Comments
 (0)