Skip to content

Commit 54486de

Browse files
committed
YQL-19845 CurrentLanguageVersion func
commit_hash:2af511a18740c931b471dc1f2ff36a8b4ce573a8
1 parent c6e7bdc commit 54486de

File tree

9 files changed

+55
-12
lines changed

9 files changed

+55
-12
lines changed

yql/essentials/core/type_ann/type_ann_core.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11088,6 +11088,26 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
1108811088
return IGraphTransformer::TStatus::Repeat;
1108911089
}
1109011090

11091+
IGraphTransformer::TStatus CurrentLanguageVersionWrapper(const TExprNode::TPtr& input, TExprNode::TPtr& output, TExtContext& ctx) {
11092+
if (!EnsureArgsCount(*input, 0, ctx.Expr)) {
11093+
return IGraphTransformer::TStatus::Error;
11094+
}
11095+
11096+
TLangVersionBuffer buffer;
11097+
TStringBuf str;
11098+
if (!FormatLangVersion(ctx.Types.LangVer, buffer, str)) {
11099+
str = "";
11100+
}
11101+
11102+
output = ctx.Expr.Builder(input->Pos())
11103+
.Callable("String")
11104+
.Atom(0, str)
11105+
.Seal()
11106+
.Build();
11107+
11108+
return IGraphTransformer::TStatus::Repeat;
11109+
}
11110+
1109111111
IGraphTransformer::TStatus SecureParamWrapper(const TExprNode::TPtr& input, TExprNode::TPtr&, TExtContext& ctx) {
1109211112
if (!EnsureArgsCount(*input, 1, ctx.Expr)) {
1109311113
return IGraphTransformer::TStatus::Error;
@@ -13145,6 +13165,7 @@ template <NKikimr::NUdf::EDataSlot DataSlot>
1314513165
ExtFunctions["CurrentOperationId"] = &CurrentOperationIdWrapper;
1314613166
ExtFunctions["CurrentOperationSharedId"] = &CurrentOperationSharedIdWrapper;
1314713167
ExtFunctions["CurrentAuthenticatedUser"] = &CurrentAuthenticatedUserWrapper;
13168+
ExtFunctions["CurrentLanguageVersion"] = &CurrentLanguageVersionWrapper;
1314813169
ExtFunctions["SecureParam"] = &SecureParamWrapper;
1314913170
ExtFunctions["UnsafeTimestampCast"] = &UnsafeTimestampCastWrapper;
1315013171
ExtFunctions["JsonValue"] = &JsonValueWrapper;

yql/essentials/data/language/sql_functions.json

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

yql/essentials/docs/en/builtins/basic.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,15 @@ SELECT RemoveTimezone(TzDatetime("2018-02-01T12:00:00,Europe/Moscow"));
369369
SELECT Version();
370370
```
371371

372+
## CurrentLanguageVersion {#current-language-version}
373+
374+
`CurrentLanguageVersion()` returns a string describing the current version of the language selected for the current request if it is defined, or an empty string.
375+
376+
#### Examples
377+
378+
```yql
379+
SELECT CurrentLanguageVersion();
380+
```
372381

373382

374383
## MAX_OF, MIN_OF, GREATEST, and LEAST {#max-min}

yql/essentials/docs/ru/builtins/basic.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,16 @@ SELECT RemoveTimezone(TzDatetime("2018-02-01T12:00:00,Europe/Moscow"));
501501
SELECT Version();
502502
```
503503

504+
## CurrentLanguageVersion {#current-language-version}
505+
506+
`CurrentLanguageVersion()` возвращает строку, описывающую текущую версию языка, выбранного для текущего запроса, если она определена, либо пустую строку.
507+
508+
#### Примеры
509+
510+
```yql
511+
SELECT CurrentLanguageVersion();
512+
```
513+
504514

505515
## MAX_OF, MIN_OF, GREATEST и LEAST {#max-min}
506516

yql/essentials/sql/v1/builtin.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3076,6 +3076,7 @@ struct TBuiltinFuncData {
30763076
{"currentoperationid", {"CurrentOperationId", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("CurrentOperationId", 0, 0)}},
30773077
{"currentoperationsharedid", {"CurrentOperationSharedId", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("CurrentOperationSharedId", 0, 0)}},
30783078
{"currentauthenticateduser", {"CurrentAuthenticatedUser", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("CurrentAuthenticatedUser", 0, 0)}},
3079+
{"currentlanguageversion", {"CurrentLanguageVersion", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("CurrentLanguageVersion", 0, 0)}},
30793080
{"addtimezone", {"AddTimezone", "Normal", BuildSimpleBuiltinFactoryCallback<TYqlAddTimezone>()}},
30803081
{"removetimezone", {"RemoveTimezone", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("RemoveTimezone", 1, 1)}},
30813082
{"pickle", {"Pickle", "Normal", BuildNamedArgcBuiltinFactoryCallback<TCallNodeImpl>("Pickle", 1, 1)}},

yql/essentials/tests/sql/minirun/part4/canondata/result.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -519,16 +519,16 @@
519519
],
520520
"test.test[expr-current_op-default.txt-Debug]": [
521521
{
522-
"checksum": "c514376080191974c8258a19978c0f48",
523-
"size": 303,
524-
"uri": "https://{canondata_backend}/1130705/84c150c95d2c1a5ae3333b68759e20e3c07850e9/resource.tar.gz#test.test_expr-current_op-default.txt-Debug_/opt.yql"
522+
"checksum": "835c25f8a1eced82f952a3a85cbb30c6",
523+
"size": 348,
524+
"uri": "https://{canondata_backend}/995452/bb7267c9db276bff2bd83cbbbb46f6214f4b395c/resource.tar.gz#test.test_expr-current_op-default.txt-Debug_/opt.yql"
525525
}
526526
],
527527
"test.test[expr-current_op-default.txt-Results]": [
528528
{
529-
"checksum": "a071d5d303a7a4cafcddef6062ecacc0",
530-
"size": 1281,
531-
"uri": "https://{canondata_backend}/1130705/84c150c95d2c1a5ae3333b68759e20e3c07850e9/resource.tar.gz#test.test_expr-current_op-default.txt-Results_/results.txt"
529+
"checksum": "92bbb10ab985515a637126fa968e3263",
530+
"size": 1581,
531+
"uri": "https://{canondata_backend}/995452/bb7267c9db276bff2bd83cbbbb46f6214f4b395c/resource.tar.gz#test.test_expr-current_op-default.txt-Results_/results.txt"
532532
}
533533
],
534534
"test.test[expr-distinct_from-default.txt-Debug]": [

yql/essentials/tests/sql/sql2yql/canondata/result.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2542,9 +2542,9 @@
25422542
],
25432543
"test_sql2yql.test[expr-current_op]": [
25442544
{
2545-
"checksum": "dad23f292f63f624470a93ca339916d1",
2546-
"size": 1342,
2547-
"uri": "https://{canondata_backend}/937458/0263002581044055229fb35127ddc0a0a0025953/resource.tar.gz#test_sql2yql.test_expr-current_op_/sql.yql"
2545+
"checksum": "a1dc136c7cc38f00c8b50715c89b9656",
2546+
"size": 1509,
2547+
"uri": "https://{canondata_backend}/1871182/089a8d1b6980b7434eb00135a8e369216a14ff2a/resource.tar.gz#test_sql2yql.test_expr-current_op_/sql.yql"
25482548
}
25492549
],
25502550
"test_sql2yql.test[expr-current_tz]": [
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
SELECT
22
CurrentOperationId(),
33
CurrentOperationSharedId(),
4-
CurrentAuthenticatedUser()
4+
CurrentAuthenticatedUser(),
5+
CurrentLanguageVersion()
56
;
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
select CurrentOperationId(),CurrentOperationSharedId(),CurrentAuthenticatedUser();
1+
select CurrentOperationId(),CurrentOperationSharedId(),CurrentAuthenticatedUser(),CurrentLanguageVersion();
2+

0 commit comments

Comments
 (0)