aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorvvvv <vvvv@ydb.tech>2023-06-30 21:41:23 +0300
committervvvv <vvvv@ydb.tech>2023-06-30 21:41:23 +0300
commit8c9046c9959fcd5d518e89492b3d88d93017a16e (patch)
tree870f57e401143fd046a89009a42c79654e57313a
parent93f97a1444777f80e3056d0566a4d1054f597b73 (diff)
downloadydb-8c9046c9959fcd5d518e89492b3d88d93017a16e.tar.gz
Allow to pass Utf8 as dict key using object representation, and name for variant over struct in parameters
-rw-r--r--ydb/library/yql/providers/common/codec/yql_codec.cpp22
1 files changed, 19 insertions, 3 deletions
diff --git a/ydb/library/yql/providers/common/codec/yql_codec.cpp b/ydb/library/yql/providers/common/codec/yql_codec.cpp
index 8523974efb2..e0e5682b7fe 100644
--- a/ydb/library/yql/providers/common/codec/yql_codec.cpp
+++ b/ydb/library/yql/providers/common/codec/yql_codec.cpp
@@ -758,7 +758,22 @@ NUdf::TUnboxedValue ReadYsonValue(TType* type,
CHECK_EXPECTED(cmd, Uint64Marker);
index = buf.ReadVarUI64();
} else {
- index = ReadNextSerializedNumber<ui64>(cmd, buf);
+ if (cmd == BeginListSymbol) {
+ cmd = buf.Read();
+ YQL_ENSURE(underlyingType->IsStruct(), "Expected struct as underlying type");
+ auto name = ReadNextString(cmd, buf);
+ auto foundIndex = static_cast<TStructType*>(underlyingType)->FindMemberIndex(name);
+ YQL_ENSURE(foundIndex, "Unexpected member: " << name);
+ index = *foundIndex;
+ cmd = buf.Read();
+ if (cmd == ListItemSeparatorSymbol) {
+ cmd = buf.Read();
+ }
+
+ CHECK_EXPECTED(cmd, EndListSymbol);
+ } else {
+ index = ReadNextSerializedNumber<ui64>(cmd, buf);
+ }
}
YQL_ENSURE(index < varType->GetAlternativesCount(), "Bad variant alternative: " << index << ", only " <<
@@ -1117,8 +1132,9 @@ NUdf::TUnboxedValue ReadYsonValue(TType* type,
bool unusedIsOptional;
auto unpackedType = UnpackOptional(keyType, unusedIsOptional);
YQL_ENSURE(unpackedType->IsData() &&
- static_cast<TDataType*>(unpackedType)->GetSchemeType() == NUdf::TDataType<char*>::Id,
- "Expected String type as dictionary key type");
+ (static_cast<TDataType*>(unpackedType)->GetSchemeType() == NUdf::TDataType<char*>::Id ||
+ static_cast<TDataType*>(unpackedType)->GetSchemeType() == NUdf::TDataType<NUdf::TUtf8>::Id),
+ "Expected String or Utf8 type as dictionary key type");
auto filler = [&](TValuesDictHashMap& map) {
cmd = buf.Read();