Skip to content

Commit b2acf53

Browse files
committed
YQL-19747 pragmas freq
commit_hash:2684f6f3d0afde345619dce25336a68f77cc9853
1 parent 6003adf commit b2acf53

File tree

5 files changed

+109
-1
lines changed

5 files changed

+109
-1
lines changed

yql/essentials/data/language/rules_corr_basic.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

yql/essentials/udfs/language/yql/test/canondata/result.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
"uri": "file://test.test_ExtractInFuncs_/results.txt"
1515
}
1616
],
17+
"test.test[ExtractPragmas]": [
18+
{
19+
"uri": "file://test.test_ExtractPragmas_/results.txt"
20+
}
21+
],
1722
"test.test[ExtractTypes]": [
1823
{
1924
"uri": "file://test.test_ExtractTypes_/results.txt"
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
[
2+
{
3+
"Write" = [
4+
{
5+
"Type" = [
6+
"ListType";
7+
[
8+
"StructType";
9+
[
10+
[
11+
"q";
12+
[
13+
"DataType";
14+
"String"
15+
]
16+
];
17+
[
18+
"column1";
19+
[
20+
"OptionalType";
21+
[
22+
"ListType";
23+
[
24+
"TupleType";
25+
[
26+
[
27+
"DataType";
28+
"String"
29+
];
30+
[
31+
"DataType";
32+
"String"
33+
];
34+
[
35+
"DataType";
36+
"Uint64"
37+
]
38+
]
39+
]
40+
]
41+
]
42+
]
43+
]
44+
]
45+
];
46+
"Data" = [
47+
[
48+
"pragma dq.Foo";
49+
[
50+
[
51+
[
52+
"PRAGMA";
53+
"dq.Foo";
54+
"1"
55+
]
56+
]
57+
]
58+
];
59+
[
60+
"pragma warningmsg('foo')";
61+
[
62+
[
63+
[
64+
"PRAGMA";
65+
"warningmsg";
66+
"1"
67+
]
68+
]
69+
]
70+
];
71+
[
72+
"pragma yt.Bar";
73+
[
74+
[
75+
[
76+
"PRAGMA";
77+
"yt.Bar";
78+
"1"
79+
]
80+
]
81+
]
82+
]
83+
]
84+
}
85+
]
86+
}
87+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT
2+
q,ListSort(ListFilter(YqlLang::RuleFreq(q),($x)->($x.0 in ("PRAGMA"))))
3+
FROM (VALUES
4+
("pragma warningmsg('foo')"),
5+
("pragma dq.Foo"),
6+
("pragma yt.Bar")
7+
) AS a(q)
8+
order by q

yql/essentials/udfs/language/yql/yql_language_udf.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ class TRuleFreqVisitor {
4545
VisitUnaryCasualSubexpr(dynamic_cast<const TRule_in_unary_casual_subexpr&>(msg));
4646
} else if (descr == TRule_type_name_simple::GetDescriptor()) {
4747
VisitSimpleType(dynamic_cast<const TRule_type_name_simple&>(msg));
48+
} else if (descr == TRule_pragma_stmt::GetDescriptor()) {
49+
VisitPragmaStmt(dynamic_cast<const TRule_pragma_stmt&>(msg));
4850
}
4951

5052
TStringBuf fullName = descr->full_name();
@@ -85,6 +87,12 @@ class TRuleFreqVisitor {
8587
}
8688
}
8789

90+
void VisitPragmaStmt(const TRule_pragma_stmt& msg) {
91+
const TString prefix = OptIdPrefixAsStr(msg.GetRule_opt_id_prefix_or_type2(), Translation);
92+
const TString pragma(Id(msg.GetRule_an_id3(), Translation));
93+
Freqs[std::make_pair("PRAGMA", prefix.empty() ? pragma : (prefix + "." + pragma))] += 1;
94+
}
95+
8896
template<typename TUnaryCasualExprRule>
8997
void VisitUnaryCasualSubexpr(const TUnaryCasualExprRule& msg) {
9098
const auto& block = msg.GetBlock1();

0 commit comments

Comments
 (0)