Skip to content

Commit f11c0b2

Browse files
author
Vadim Averin
authored
Support type_v3 UUIDs (#8179)
1 parent 29df886 commit f11c0b2

File tree

10 files changed

+114
-3
lines changed

10 files changed

+114
-3
lines changed

ydb/library/yql/providers/common/codec/yql_codec_type_flags.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@ enum ENativeTypeCompatFlags: ui64 {
1313
NTCF_JSON = 1ull << 5 /* "json" */,
1414
NTCF_DECIMAL = 1ull << 6 /* "decimal" */,
1515
NTCF_BIGDATE = 1ull << 7 /* "bigdate" */,
16+
NTCF_UUID = 1ull << 8 /* "uuid" */,
1617

1718
NTCF_NO_YT_SUPPORT = 1ull << 40 /* "_no_yt_support" */,
1819

1920
NTCF_NONE = 0ull /* "none" */,
2021
NTCF_LEGACY = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID /* "legacy" */,
2122

2223
// All supported types by all YT production clusters
23-
NTCF_PRODUCTION = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID | NTCF_FLOAT | NTCF_JSON | NTCF_DECIMAL /* "production" */,
24+
NTCF_PRODUCTION = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID | NTCF_FLOAT | NTCF_JSON | NTCF_DECIMAL | NTCF_UUID /* "production" */,
2425

2526
// add all new types here, supported by YT
2627
NTCF_ALL = NTCF_PRODUCTION | NTCF_BIGDATE /* "all" */,

ydb/library/yql/providers/yt/lib/row_spec/yql_row_spec.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ ui64 GetNativeYtTypeFlagsImpl(const TTypeAnnotationNode* itemType) {
5555
case EDataSlot::Decimal:
5656
return NTCF_DECIMAL;
5757
case EDataSlot::Uuid:
58+
return NTCF_UUID;
5859
case EDataSlot::TzDate:
5960
case EDataSlot::TzDatetime:
6061
case EDataSlot::TzTimestamp:

ydb/library/yql/providers/yt/lib/schema/schema.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ static TString ConvertYtDataType(const TString& ytType, ui64& nativeYtTypeFlags)
2424
if (ytType == "string") {
2525
yqlType = "String";
2626
}
27+
else if (ytType == "uuid") {
28+
nativeYtTypeFlags |= NTCF_UUID;
29+
yqlType = "Uuid";
30+
}
2731
else if (ytType == "utf8") {
2832
yqlType = "Utf8";
2933
}
@@ -675,8 +679,10 @@ std::pair<NYT::EValueType, bool> RowSpecYqlTypeToYtType(const NYT::TNode& rowSpe
675679

676680
const auto& yqlType = (*type)[1].AsString();
677681
NYT::EValueType ytType;
678-
if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("Uuid") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
682+
if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
679683
ytType = NYT::VT_STRING;
684+
} else if (yqlType == TStringBuf("Uuid")) {
685+
ytType = (nativeYtTypeFlags & NTCF_UUID) ? NYT::VT_UUID : NYT::VT_STRING;
680686
} else if (yqlType == TStringBuf("Json")) {
681687
ytType = (nativeYtTypeFlags & NTCF_JSON) ? NYT::VT_JSON : NYT::VT_STRING;
682688
} else if (yqlType == TStringBuf("Decimal")) {
@@ -740,8 +746,10 @@ NYT::TNode RowSpecYqlTypeToYtNativeType(const NYT::TNode& rowSpecType, ui64 nati
740746
if ((*type)[0] == TStringBuf("DataType")) {
741747
const auto& yqlType = (*type)[1].AsString();
742748
TString ytType;
743-
if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("Uuid") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
749+
if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
744750
ytType = "string";
751+
} else if (yqlType == TStringBuf("Uuid")) {
752+
ytType = "uuid";
745753
} else if (yqlType == TStringBuf("Json")) {
746754
ytType = (nativeYtTypeFlags & NTCF_JSON) ? "json" : "string";
747755
} else if (yqlType == TStringBuf("Utf8")) {

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,31 @@
29042904
}
29052905
],
29062906
"test.test[type_v3-mergejoin_with_sort--Results]": [],
2907+
"test.test[type_v3-uuid--Analyze]": [
2908+
{
2909+
"checksum": "57ec1751927f62c86af6545626b5b162",
2910+
"size": 5209,
2911+
"uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Analyze_/plan.txt"
2912+
},
2913+
{
2914+
"uri": "file://test.test_type_v3-uuid--Analyze_/extracted"
2915+
}
2916+
],
2917+
"test.test[type_v3-uuid--Debug]": [
2918+
{
2919+
"checksum": "5bf1d30a1a045f61fea2a36a6cbd4726",
2920+
"size": 2508,
2921+
"uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql_patched"
2922+
}
2923+
],
2924+
"test.test[type_v3-uuid--Plan]": [
2925+
{
2926+
"checksum": "b8a2167dc273d0ea5afaf243ddd2cb14",
2927+
"size": 6356,
2928+
"uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
2929+
}
2930+
],
2931+
"test.test[type_v3-uuid--Results]": [],
29072932
"test.test[udf-generic_udf--Analyze]": [
29082933
{
29092934
"checksum": "b4dd508a329723c74293d80f0278c705",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<tmp_path>/program.sql:<main>: Info: Optimization
2+
3+
<tmp_path>/program.sql:<main>: Info: DQ cannot execute the query. Cause: table without statistics

ydb/library/yql/tests/sql/hybrid_file/part9/canondata/result.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2855,6 +2855,20 @@
28552855
"uri": "https://{canondata_backend}/1809005/2a59475dc877549ac4197a291aacd77d92f24ab4/resource.tar.gz#test.test_type_v3-mixed_with_columns--Plan_/plan.txt"
28562856
}
28572857
],
2858+
"test.test[type_v3-uuid--Debug]": [
2859+
{
2860+
"checksum": "190a7bb29d5a1eb0abc5960e803e23e5",
2861+
"size": 2375,
2862+
"uri": "https://{canondata_backend}/1937001/4aaa35652a4aadbbe10797f226b61d7445c2e45e/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql_patched"
2863+
}
2864+
],
2865+
"test.test[type_v3-uuid--Plan]": [
2866+
{
2867+
"checksum": "47a31ba78105dfd75ac1f4a7a81f4307",
2868+
"size": 5533,
2869+
"uri": "https://{canondata_backend}/1937001/4aaa35652a4aadbbe10797f226b61d7445c2e45e/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
2870+
}
2871+
],
28582872
"test.test[udf-automap_null--Debug]": [
28592873
{
28602874
"checksum": "ee477b97d6b2f27a6d6679bc3643c5c1",

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17996,6 +17996,13 @@
1799617996
"uri": "https://{canondata_backend}/1936947/659b615f15086142a8960946dabd06b519d43335/resource.tar.gz#test_sql2yql.test_type_v3-type_subset_/sql.yql"
1799717997
}
1799817998
],
17999+
"test_sql2yql.test[type_v3-uuid]": [
18000+
{
18001+
"checksum": "8e0d4cb4d37e1f75aaf2c3062e778089",
18002+
"size": 4895,
18003+
"uri": "https://{canondata_backend}/1925821/b8008446b33ca345e686cde20ac11f69555d8599/resource.tar.gz#test_sql2yql.test_type_v3-uuid_/sql.yql"
18004+
}
18005+
],
1799918006
"test_sql2yql.test[udf-automap_null]": [
1800018007
{
1800118008
"checksum": "4ff981ba396926defeeb6d78dc64839e",
@@ -34460,6 +34467,13 @@
3446034467
"uri": "https://{canondata_backend}/1880306/64654158d6bfb1289c66c626a8162239289559d0/resource.tar.gz#test_sql_format.test_type_v3-type_subset_/formatted.sql"
3446134468
}
3446234469
],
34470+
"test_sql_format.test[type_v3-uuid]": [
34471+
{
34472+
"checksum": "3bf34c2cde3d4f9365a787888a60ac51",
34473+
"size": 590,
34474+
"uri": "https://{canondata_backend}/1925821/b8008446b33ca345e686cde20ac11f69555d8599/resource.tar.gz#test_sql_format.test_type_v3-uuid_/formatted.sql"
34475+
}
34476+
],
3446334477
"test_sql_format.test[udf-automap_null]": [
3446434478
{
3446534479
"checksum": "46ccf8053e07c003f12860f5ae5681d0",
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
in Output output.txt
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* syntax version 1 */
2+
/* postgres can not */
3+
use plato;
4+
5+
pragma yt.UseNativeYtTypes="1";
6+
pragma yt.NativeYtTypeCompatibility="uuid";
7+
8+
insert into Output
9+
select * from (
10+
select Uuid("00000000-0000-0000-0000-100000000000")
11+
union all
12+
select Uuid("00000000-0000-0000-0000-200000000000")
13+
union all
14+
select Uuid("00000000-0000-0000-0000-400000000000")
15+
union all
16+
select Uuid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF")
17+
union all
18+
select Uuid("3200ec12-4ded-4f6c-a981-4b0ff18bbdd5")
19+
);
20+
21+
commit;
22+
23+
select * from Output;

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2904,6 +2904,27 @@
29042904
}
29052905
],
29062906
"test.test[type_v3-split--Results]": [],
2907+
"test.test[type_v3-uuid--Debug]": [
2908+
{
2909+
"checksum": "3e1ebb321a404fd38a6734ae091f90d2",
2910+
"size": 2124,
2911+
"uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql"
2912+
}
2913+
],
2914+
"test.test[type_v3-uuid--Plan]": [
2915+
{
2916+
"checksum": "b37c6fba2aec158714e95f824154b16d",
2917+
"size": 5205,
2918+
"uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
2919+
}
2920+
],
2921+
"test.test[type_v3-uuid--Results]": [
2922+
{
2923+
"checksum": "28dd8ec5e2899f9f429beb13020e44e0",
2924+
"size": 1237,
2925+
"uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Results_/results.txt"
2926+
}
2927+
],
29072928
"test.test[udf-generic_udf--Debug]": [
29082929
{
29092930
"checksum": "bce0c4df3ca7e46551d69872344b06ef",

0 commit comments

Comments
 (0)