aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraneporada <aneporada@ydb.tech>2023-01-25 13:21:11 +0300
committeraneporada <aneporada@ydb.tech>2023-01-25 13:21:11 +0300
commiteb8f3a102f1e0d4bd1aaf4cca5a74a68455d8ab7 (patch)
tree4fad64bde492c82cf402a43cfb60bab8b36b9797
parent932e4cdf61843c075375eca1a80e395e0752df6a (diff)
downloadydb-eb8f3a102f1e0d4bd1aaf4cca5a74a68455d8ab7.tar.gz
Mark UDF strictness for json, json2, yson2
-rw-r--r--ydb/library/yql/minikql/dom/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/minikql/dom/CMakeLists.linux-aarch64.txt2
-rw-r--r--ydb/library/yql/minikql/dom/CMakeLists.linux.txt2
-rw-r--r--ydb/library/yql/udfs/common/json/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/udfs/common/json/CMakeLists.linux-aarch64.txt2
-rw-r--r--ydb/library/yql/udfs/common/json/CMakeLists.linux.txt2
-rw-r--r--ydb/library/yql/udfs/common/json/json_udf.cpp2
-rw-r--r--ydb/library/yql/udfs/common/json2/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/udfs/common/json2/CMakeLists.linux-aarch64.txt2
-rw-r--r--ydb/library/yql/udfs/common/json2/CMakeLists.linux.txt2
-rw-r--r--ydb/library/yql/udfs/common/json2/as_json_node.h2
-rw-r--r--ydb/library/yql/udfs/common/json2/sql_exists.h3
-rw-r--r--ydb/library/yql/udfs/common/json2/sql_query.h2
-rw-r--r--ydb/library/yql/udfs/common/json2/sql_value.h2
-rw-r--r--ydb/library/yql/udfs/common/yson2/CMakeLists.darwin.txt2
-rw-r--r--ydb/library/yql/udfs/common/yson2/CMakeLists.linux-aarch64.txt2
-rw-r--r--ydb/library/yql/udfs/common/yson2/CMakeLists.linux.txt2
-rw-r--r--ydb/library/yql/udfs/common/yson2/yson2_udf.cpp36
18 files changed, 43 insertions, 28 deletions
diff --git a/ydb/library/yql/minikql/dom/CMakeLists.darwin.txt b/ydb/library/yql/minikql/dom/CMakeLists.darwin.txt
index fb33f53eec..4d9af8a9e9 100644
--- a/ydb/library/yql/minikql/dom/CMakeLists.darwin.txt
+++ b/ydb/library/yql/minikql/dom/CMakeLists.darwin.txt
@@ -10,7 +10,7 @@
add_library(yql-minikql-dom)
target_compile_options(yql-minikql-dom PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yql-minikql-dom PUBLIC
diff --git a/ydb/library/yql/minikql/dom/CMakeLists.linux-aarch64.txt b/ydb/library/yql/minikql/dom/CMakeLists.linux-aarch64.txt
index 7fad754cfa..5d15504310 100644
--- a/ydb/library/yql/minikql/dom/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/minikql/dom/CMakeLists.linux-aarch64.txt
@@ -10,7 +10,7 @@
add_library(yql-minikql-dom)
target_compile_options(yql-minikql-dom PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yql-minikql-dom PUBLIC
diff --git a/ydb/library/yql/minikql/dom/CMakeLists.linux.txt b/ydb/library/yql/minikql/dom/CMakeLists.linux.txt
index 7fad754cfa..5d15504310 100644
--- a/ydb/library/yql/minikql/dom/CMakeLists.linux.txt
+++ b/ydb/library/yql/minikql/dom/CMakeLists.linux.txt
@@ -10,7 +10,7 @@
add_library(yql-minikql-dom)
target_compile_options(yql-minikql-dom PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yql-minikql-dom PUBLIC
diff --git a/ydb/library/yql/udfs/common/json/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/json/CMakeLists.darwin.txt
index ff69837d58..260a11f271 100644
--- a/ydb/library/yql/udfs/common/json/CMakeLists.darwin.txt
+++ b/ydb/library/yql/udfs/common/json/CMakeLists.darwin.txt
@@ -19,7 +19,7 @@ target_link_libraries(json_udf INTERFACE
add_global_library_for(json_udf.global json_udf)
target_compile_options(json_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json/CMakeLists.linux-aarch64.txt b/ydb/library/yql/udfs/common/json/CMakeLists.linux-aarch64.txt
index 4c0c37d600..84be2050d9 100644
--- a/ydb/library/yql/udfs/common/json/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/udfs/common/json/CMakeLists.linux-aarch64.txt
@@ -20,7 +20,7 @@ target_link_libraries(json_udf INTERFACE
add_global_library_for(json_udf.global json_udf)
target_compile_options(json_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json/CMakeLists.linux.txt b/ydb/library/yql/udfs/common/json/CMakeLists.linux.txt
index 4c0c37d600..84be2050d9 100644
--- a/ydb/library/yql/udfs/common/json/CMakeLists.linux.txt
+++ b/ydb/library/yql/udfs/common/json/CMakeLists.linux.txt
@@ -20,7 +20,7 @@ target_link_libraries(json_udf INTERFACE
add_global_library_for(json_udf.global json_udf)
target_compile_options(json_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json/json_udf.cpp b/ydb/library/yql/udfs/common/json/json_udf.cpp
index e994e589bd..49ffec496c 100644
--- a/ydb/library/yql/udfs/common/json/json_udf.cpp
+++ b/ydb/library/yql/udfs/common/json/json_udf.cpp
@@ -104,6 +104,8 @@ namespace {
if (!typesOnly) {
builder.Implementation(new TGetField);
}
+
+ builder.IsStrict();
return true;
} else {
return false;
diff --git a/ydb/library/yql/udfs/common/json2/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/json2/CMakeLists.darwin.txt
index 46e29176e6..a26132211d 100644
--- a/ydb/library/yql/udfs/common/json2/CMakeLists.darwin.txt
+++ b/ydb/library/yql/udfs/common/json2/CMakeLists.darwin.txt
@@ -21,7 +21,7 @@ target_link_libraries(json2_udf INTERFACE
add_global_library_for(json2_udf.global json2_udf)
target_compile_options(json2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json2/CMakeLists.linux-aarch64.txt b/ydb/library/yql/udfs/common/json2/CMakeLists.linux-aarch64.txt
index 6127f5aac1..808af57b77 100644
--- a/ydb/library/yql/udfs/common/json2/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/udfs/common/json2/CMakeLists.linux-aarch64.txt
@@ -22,7 +22,7 @@ target_link_libraries(json2_udf INTERFACE
add_global_library_for(json2_udf.global json2_udf)
target_compile_options(json2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json2/CMakeLists.linux.txt b/ydb/library/yql/udfs/common/json2/CMakeLists.linux.txt
index 6127f5aac1..808af57b77 100644
--- a/ydb/library/yql/udfs/common/json2/CMakeLists.linux.txt
+++ b/ydb/library/yql/udfs/common/json2/CMakeLists.linux.txt
@@ -22,7 +22,7 @@ target_link_libraries(json2_udf INTERFACE
add_global_library_for(json2_udf.global json2_udf)
target_compile_options(json2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(json2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/json2/as_json_node.h b/ydb/library/yql/udfs/common/json2/as_json_node.h
index 442e4a90ba..4e190f8eb7 100644
--- a/ydb/library/yql/udfs/common/json2/as_json_node.h
+++ b/ydb/library/yql/udfs/common/json2/as_json_node.h
@@ -43,6 +43,8 @@ namespace NJson2Udf {
if (!typesOnly) {
builder.Implementation(new TAsJsonNode<TSource>(builder.GetSourcePosition()));
}
+
+ builder.IsStrict();
return true;
}
diff --git a/ydb/library/yql/udfs/common/json2/sql_exists.h b/ydb/library/yql/udfs/common/json2/sql_exists.h
index 32d5b84897..78aac2ce57 100644
--- a/ydb/library/yql/udfs/common/json2/sql_exists.h
+++ b/ydb/library/yql/udfs/common/json2/sql_exists.h
@@ -67,6 +67,9 @@ namespace NJson2Udf {
if (!typesOnly) {
builder.Implementation(new TSqlExists(builder.GetSourcePosition()));
}
+ if constexpr (!ThrowException) {
+ builder.IsStrict();
+ }
return true;
}
diff --git a/ydb/library/yql/udfs/common/json2/sql_query.h b/ydb/library/yql/udfs/common/json2/sql_query.h
index 85ed288fec..5b2f6a8a79 100644
--- a/ydb/library/yql/udfs/common/json2/sql_query.h
+++ b/ydb/library/yql/udfs/common/json2/sql_query.h
@@ -60,6 +60,8 @@ namespace NJson2Udf {
5. Bool. True - throw on error, false - otherwise
6. Resource<JsonNode>?. Default value to return on error. Ignored if 4th argument is true
*/
+ // we can't mark TSqlQuery as strict due to runtime throw policy setting
+ // TODO: optimizer can mark SqlQuery as strict if 3th/5th arguments are literal booleans
builder.Args()
->Add(inputOptionalType)
.Add(jsonPathType)
diff --git a/ydb/library/yql/udfs/common/json2/sql_value.h b/ydb/library/yql/udfs/common/json2/sql_value.h
index 5960c0749e..319fd855e8 100644
--- a/ydb/library/yql/udfs/common/json2/sql_value.h
+++ b/ydb/library/yql/udfs/common/json2/sql_value.h
@@ -156,6 +156,8 @@ namespace NJson2Udf {
.Done()
.Returns(returnType);
+ builder.IsStrict();
+
if (!typesOnly) {
builder.Implementation(new TSqlValue(builder.GetSourcePosition()));
}
diff --git a/ydb/library/yql/udfs/common/yson2/CMakeLists.darwin.txt b/ydb/library/yql/udfs/common/yson2/CMakeLists.darwin.txt
index e4f115e005..2b0d613f77 100644
--- a/ydb/library/yql/udfs/common/yson2/CMakeLists.darwin.txt
+++ b/ydb/library/yql/udfs/common/yson2/CMakeLists.darwin.txt
@@ -21,7 +21,7 @@ target_link_libraries(yson2_udf INTERFACE
add_global_library_for(yson2_udf.global yson2_udf)
target_compile_options(yson2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yson2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/yson2/CMakeLists.linux-aarch64.txt b/ydb/library/yql/udfs/common/yson2/CMakeLists.linux-aarch64.txt
index 74fb6300eb..05c8a4a027 100644
--- a/ydb/library/yql/udfs/common/yson2/CMakeLists.linux-aarch64.txt
+++ b/ydb/library/yql/udfs/common/yson2/CMakeLists.linux-aarch64.txt
@@ -22,7 +22,7 @@ target_link_libraries(yson2_udf INTERFACE
add_global_library_for(yson2_udf.global yson2_udf)
target_compile_options(yson2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yson2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/yson2/CMakeLists.linux.txt b/ydb/library/yql/udfs/common/yson2/CMakeLists.linux.txt
index 74fb6300eb..05c8a4a027 100644
--- a/ydb/library/yql/udfs/common/yson2/CMakeLists.linux.txt
+++ b/ydb/library/yql/udfs/common/yson2/CMakeLists.linux.txt
@@ -22,7 +22,7 @@ target_link_libraries(yson2_udf INTERFACE
add_global_library_for(yson2_udf.global yson2_udf)
target_compile_options(yson2_udf.global PRIVATE
-DUDF_ABI_VERSION_MAJOR=2
- -DUDF_ABI_VERSION_MINOR=27
+ -DUDF_ABI_VERSION_MINOR=28
-DUDF_ABI_VERSION_PATCH=0
)
target_link_libraries(yson2_udf.global PUBLIC
diff --git a/ydb/library/yql/udfs/common/yson2/yson2_udf.cpp b/ydb/library/yql/udfs/common/yson2/yson2_udf.cpp
index 1278ec565c..36a90f5a70 100644
--- a/ydb/library/yql/udfs/common/yson2/yson2_udf.cpp
+++ b/ydb/library/yql/udfs/common/yson2/yson2_udf.cpp
@@ -88,6 +88,7 @@ public:
builder.Implementation(new TOptions);
}
+ builder.IsStrict();
return true;
} else {
return false;
@@ -526,7 +527,7 @@ SIMPLE_UDF_OPTIONS(TConvertToStringDict, TStringDictType(TOptional<TNodeResource
return (options.AutoConvert ? &ConvertToDictImpl<false, true, &ConvertToString<false, true, false>> : &ConvertToDictImpl<false, false, &ConvertToString<false, false, false>>)(args[0], valueBuilder, Pos_);
}
-SIMPLE_UDF(TAttributes, TDictType(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TAttributes, TDictType(TAutoMap<TNodeResource>)) {
const auto x = args[0];
if (IsNodeType<ENodeType::Attr>(x)) {
return x;
@@ -549,7 +550,7 @@ SIMPLE_UDF_OPTIONS(TGetLength, TOptional<ui64>(TAutoMap<TNodeResource>, TOptiona
return (options.AutoConvert ? &GetLengthImpl<false, true> : &GetLengthImpl<false, false>)(args[0], valueBuilder, Pos_);
}
-SIMPLE_UDF_OPTIONS(TLookup, TOptional<TNodeResource>(TAutoMap<TNodeResource>, char*, TOptional<TOptionsResource>), builder.OptionalArgs(1)) {
+SIMPLE_STRICT_UDF_OPTIONS(TLookup, TOptional<TNodeResource>(TAutoMap<TNodeResource>, char*, TOptional<TOptionsResource>), builder.OptionalArgs(1)) {
return LookupImpl(args[0], args[1], valueBuilder, Pos_);
}
@@ -655,15 +656,15 @@ SIMPLE_UDF_OPTIONS(TYPathDict, TOptional<TDictType>(TAutoMap<TNodeResource>, cha
return (options.AutoConvert ? &YPathImpl<&ConvertToDictImpl<false, true>> : &YPathImpl<&ConvertToDictImpl<false, false>>)(args[0], args[1], valueBuilder, Pos_);
}
-SIMPLE_UDF(TSerialize, TYson(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TSerialize, TYson(TAutoMap<TNodeResource>)) {
return valueBuilder->NewString(SerializeYsonDomToBinary(args[0]));
}
-SIMPLE_UDF(TSerializeText, TYson(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TSerializeText, TYson(TAutoMap<TNodeResource>)) {
return valueBuilder->NewString(SerializeYsonDomToText(args[0]));
}
-SIMPLE_UDF(TSerializePretty, TYson(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TSerializePretty, TYson(TAutoMap<TNodeResource>)) {
return valueBuilder->NewString(SerializeYsonDomToPrettyText(args[0]));
}
@@ -679,7 +680,7 @@ SIMPLE_UDF_OPTIONS(TSerializeJson, TOptional<TJson>(TAutoMap<TNodeResource>, TOp
return {};
}
-SIMPLE_UDF(TWithAttributes, TOptional<TNodeResource>(TAutoMap<TNodeResource>, TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TWithAttributes, TOptional<TNodeResource>(TAutoMap<TNodeResource>, TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
auto x = args[0];
auto y = args[1];
@@ -724,52 +725,52 @@ TUnboxedValuePod IsTypeImpl(TUnboxedValuePod y) {
return TUnboxedValuePod(IsNodeType<Type>(y));
}
-SIMPLE_UDF(TIsString, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsString, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::String>(*args);
}
-SIMPLE_UDF(TIsInt64, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsInt64, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Int64>(*args);
}
-SIMPLE_UDF(TIsUint64, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsUint64, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Uint64>(*args);
}
-SIMPLE_UDF(TIsBool, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsBool, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Bool>(*args);
}
-SIMPLE_UDF(TIsDouble, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsDouble, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Double>(*args);
}
-SIMPLE_UDF(TIsList, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsList, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::List>(*args);
}
-SIMPLE_UDF(TIsDict, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsDict, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Dict>(*args);
}
-SIMPLE_UDF(TIsEntity, bool(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TIsEntity, bool(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return IsTypeImpl<ENodeType::Entity>(*args);
}
-SIMPLE_UDF(TEquals, bool(TAutoMap<TNodeResource>, TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TEquals, bool(TAutoMap<TNodeResource>, TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return TUnboxedValuePod(EquateDoms(args[0], args[1]));
}
-SIMPLE_UDF(TGetHash, ui64(TAutoMap<TNodeResource>)) {
+SIMPLE_STRICT_UDF(TGetHash, ui64(TAutoMap<TNodeResource>)) {
Y_UNUSED(valueBuilder);
return TUnboxedValuePod(HashDom(args[0]));
}
@@ -914,6 +915,7 @@ public:
if (!typesOnly) {
builder.Implementation(new TFrom(builder.GetSourcePosition(), typeHelper, inputType));
}
+ builder.IsStrict();
return true;
} else {
return false;
@@ -1062,6 +1064,7 @@ public:
switch (typeId) {
case TDataType<TYJson>::Id:
builder.Args()->Add<TAutoMap<TYJson>>().Add(optionsType).Done().Returns(builder.Resource(NodeResourceName));
+ builder.IsStrict();
break;
case TDataType<TUtf8>::Id:
builder.Args()->Add<TAutoMap<TUtf8>>().Add(optionsType).Done().Returns(builder.Optional()->Item(builder.Resource(NodeResourceName)).Build());
@@ -1131,6 +1134,7 @@ const TStringRef& TParse<TJson, true>::Name() {
}
+// TODO: optimizer that marks UDFs as strict if Yson::Options(false as Strict) is given
SIMPLE_MODULE(TYson2Module,
TOptions,
TParse<TYson>,