Vadim Averin 6 месяцев назад
Родитель
Сommit
f11c0b2095

+ 2 - 1
ydb/library/yql/providers/common/codec/yql_codec_type_flags.h

@@ -13,6 +13,7 @@ enum ENativeTypeCompatFlags: ui64 {
     NTCF_JSON       = 1ull << 5 /* "json" */,
     NTCF_DECIMAL    = 1ull << 6 /* "decimal" */,
     NTCF_BIGDATE    = 1ull << 7 /* "bigdate" */,
+    NTCF_UUID       = 1ull << 8 /* "uuid" */,
 
     NTCF_NO_YT_SUPPORT  = 1ull << 40 /* "_no_yt_support" */,
 
@@ -20,7 +21,7 @@ enum ENativeTypeCompatFlags: ui64 {
     NTCF_LEGACY = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID /* "legacy" */,
 
     // All supported types by all YT production clusters
-    NTCF_PRODUCTION = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID | NTCF_FLOAT | NTCF_JSON | NTCF_DECIMAL /* "production" */,
+    NTCF_PRODUCTION = NTCF_COMPLEX | NTCF_DATE | NTCF_NULL | NTCF_VOID | NTCF_FLOAT | NTCF_JSON | NTCF_DECIMAL | NTCF_UUID /* "production" */,
 
     // add all new types here, supported by YT
     NTCF_ALL = NTCF_PRODUCTION | NTCF_BIGDATE /* "all" */,

+ 1 - 0
ydb/library/yql/providers/yt/lib/row_spec/yql_row_spec.cpp

@@ -55,6 +55,7 @@ ui64 GetNativeYtTypeFlagsImpl(const TTypeAnnotationNode* itemType) {
             case EDataSlot::Decimal:
                 return NTCF_DECIMAL;
             case EDataSlot::Uuid:
+                return NTCF_UUID;
             case EDataSlot::TzDate:
             case EDataSlot::TzDatetime:
             case EDataSlot::TzTimestamp:

+ 10 - 2
ydb/library/yql/providers/yt/lib/schema/schema.cpp

@@ -24,6 +24,10 @@ static TString ConvertYtDataType(const TString& ytType, ui64& nativeYtTypeFlags)
     if (ytType == "string") {
         yqlType = "String";
     }
+    else if (ytType == "uuid") {
+        nativeYtTypeFlags |= NTCF_UUID;
+        yqlType = "Uuid";
+    }
     else if (ytType == "utf8") {
         yqlType = "Utf8";
     }
@@ -675,8 +679,10 @@ std::pair<NYT::EValueType, bool> RowSpecYqlTypeToYtType(const NYT::TNode& rowSpe
 
     const auto& yqlType = (*type)[1].AsString();
     NYT::EValueType ytType;
-    if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("Uuid") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
+    if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
         ytType = NYT::VT_STRING;
+    } else if (yqlType == TStringBuf("Uuid")) {
+        ytType = (nativeYtTypeFlags & NTCF_UUID) ? NYT::VT_UUID : NYT::VT_STRING;
     } else if (yqlType == TStringBuf("Json")) {
         ytType = (nativeYtTypeFlags & NTCF_JSON) ? NYT::VT_JSON : NYT::VT_STRING;
     } else if (yqlType == TStringBuf("Decimal")) {
@@ -740,8 +746,10 @@ NYT::TNode RowSpecYqlTypeToYtNativeType(const NYT::TNode& rowSpecType, ui64 nati
     if ((*type)[0] == TStringBuf("DataType")) {
         const auto& yqlType = (*type)[1].AsString();
         TString ytType;
-        if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("Uuid") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
+        if (yqlType == TStringBuf("String") || yqlType == TStringBuf("Longint") || yqlType == TStringBuf("JsonDocument") || yqlType == TStringBuf("DyNumber")) {
             ytType = "string";
+        } else if (yqlType == TStringBuf("Uuid")) {
+            ytType = "uuid";
         } else if (yqlType == TStringBuf("Json")) {
             ytType = (nativeYtTypeFlags & NTCF_JSON) ? "json" : "string";
         } else if (yqlType == TStringBuf("Utf8")) {

+ 25 - 0
ydb/library/yql/tests/sql/dq_file/part5/canondata/result.json

@@ -2904,6 +2904,31 @@
         }
     ],
     "test.test[type_v3-mergejoin_with_sort--Results]": [],
+    "test.test[type_v3-uuid--Analyze]": [
+        {
+            "checksum": "57ec1751927f62c86af6545626b5b162",
+            "size": 5209,
+            "uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Analyze_/plan.txt"
+        },
+        {
+            "uri": "file://test.test_type_v3-uuid--Analyze_/extracted"
+        }
+    ],
+    "test.test[type_v3-uuid--Debug]": [
+        {
+            "checksum": "5bf1d30a1a045f61fea2a36a6cbd4726",
+            "size": 2508,
+            "uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql_patched"
+        }
+    ],
+    "test.test[type_v3-uuid--Plan]": [
+        {
+            "checksum": "b8a2167dc273d0ea5afaf243ddd2cb14",
+            "size": 6356,
+            "uri": "https://{canondata_backend}/1899731/3bbf0846401e09b064add80d60e61e7654f87412/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
+        }
+    ],
+    "test.test[type_v3-uuid--Results]": [],
     "test.test[udf-generic_udf--Analyze]": [
         {
             "checksum": "b4dd508a329723c74293d80f0278c705",

+ 3 - 0
ydb/library/yql/tests/sql/dq_file/part5/canondata/test.test_type_v3-uuid--Analyze_/extracted

@@ -0,0 +1,3 @@
+<tmp_path>/program.sql:<main>: Info: Optimization
+
+    <tmp_path>/program.sql:<main>: Info: DQ cannot execute the query. Cause: table without statistics

+ 14 - 0
ydb/library/yql/tests/sql/hybrid_file/part9/canondata/result.json

@@ -2855,6 +2855,20 @@
             "uri": "https://{canondata_backend}/1809005/2a59475dc877549ac4197a291aacd77d92f24ab4/resource.tar.gz#test.test_type_v3-mixed_with_columns--Plan_/plan.txt"
         }
     ],
+    "test.test[type_v3-uuid--Debug]": [
+        {
+            "checksum": "190a7bb29d5a1eb0abc5960e803e23e5",
+            "size": 2375,
+            "uri": "https://{canondata_backend}/1937001/4aaa35652a4aadbbe10797f226b61d7445c2e45e/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql_patched"
+        }
+    ],
+    "test.test[type_v3-uuid--Plan]": [
+        {
+            "checksum": "47a31ba78105dfd75ac1f4a7a81f4307",
+            "size": 5533,
+            "uri": "https://{canondata_backend}/1937001/4aaa35652a4aadbbe10797f226b61d7445c2e45e/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
+        }
+    ],
     "test.test[udf-automap_null--Debug]": [
         {
             "checksum": "ee477b97d6b2f27a6d6679bc3643c5c1",

+ 14 - 0
ydb/library/yql/tests/sql/sql2yql/canondata/result.json

@@ -17996,6 +17996,13 @@
             "uri": "https://{canondata_backend}/1936947/659b615f15086142a8960946dabd06b519d43335/resource.tar.gz#test_sql2yql.test_type_v3-type_subset_/sql.yql"
         }
     ],
+    "test_sql2yql.test[type_v3-uuid]": [
+        {
+            "checksum": "8e0d4cb4d37e1f75aaf2c3062e778089",
+            "size": 4895,
+            "uri": "https://{canondata_backend}/1925821/b8008446b33ca345e686cde20ac11f69555d8599/resource.tar.gz#test_sql2yql.test_type_v3-uuid_/sql.yql"
+        }
+    ],
     "test_sql2yql.test[udf-automap_null]": [
         {
             "checksum": "4ff981ba396926defeeb6d78dc64839e",
@@ -34460,6 +34467,13 @@
             "uri": "https://{canondata_backend}/1880306/64654158d6bfb1289c66c626a8162239289559d0/resource.tar.gz#test_sql_format.test_type_v3-type_subset_/formatted.sql"
         }
     ],
+    "test_sql_format.test[type_v3-uuid]": [
+        {
+            "checksum": "3bf34c2cde3d4f9365a787888a60ac51",
+            "size": 590,
+            "uri": "https://{canondata_backend}/1925821/b8008446b33ca345e686cde20ac11f69555d8599/resource.tar.gz#test_sql_format.test_type_v3-uuid_/formatted.sql"
+        }
+    ],
     "test_sql_format.test[udf-automap_null]": [
         {
             "checksum": "46ccf8053e07c003f12860f5ae5681d0",

+ 1 - 0
ydb/library/yql/tests/sql/suites/type_v3/uuid.cfg

@@ -0,0 +1 @@
+in Output output.txt

+ 23 - 0
ydb/library/yql/tests/sql/suites/type_v3/uuid.sql

@@ -0,0 +1,23 @@
+/* syntax version 1 */
+/* postgres can not */
+use plato;
+
+pragma yt.UseNativeYtTypes="1";
+pragma yt.NativeYtTypeCompatibility="uuid";
+
+insert into Output
+select * from (
+    select Uuid("00000000-0000-0000-0000-100000000000")
+    union all
+    select Uuid("00000000-0000-0000-0000-200000000000")
+    union all
+    select Uuid("00000000-0000-0000-0000-400000000000")
+    union all
+    select Uuid("FFFFFFFF-FFFF-FFFF-FFFF-FFFFFFFFFFFF")
+    union all
+    select Uuid("3200ec12-4ded-4f6c-a981-4b0ff18bbdd5")
+);
+
+commit;
+
+select * from Output;

+ 21 - 0
ydb/library/yql/tests/sql/yt_native_file/part5/canondata/result.json

@@ -2904,6 +2904,27 @@
         }
     ],
     "test.test[type_v3-split--Results]": [],
+    "test.test[type_v3-uuid--Debug]": [
+        {
+            "checksum": "3e1ebb321a404fd38a6734ae091f90d2",
+            "size": 2124,
+            "uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Debug_/opt.yql"
+        }
+    ],
+    "test.test[type_v3-uuid--Plan]": [
+        {
+            "checksum": "b37c6fba2aec158714e95f824154b16d",
+            "size": 5205,
+            "uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Plan_/plan.txt"
+        }
+    ],
+    "test.test[type_v3-uuid--Results]": [
+        {
+            "checksum": "28dd8ec5e2899f9f429beb13020e44e0",
+            "size": 1237,
+            "uri": "https://{canondata_backend}/1937001/a2424dc39602625703679b183965b3d2da1e8070/resource.tar.gz#test.test_type_v3-uuid--Results_/results.txt"
+        }
+    ],
     "test.test[udf-generic_udf--Debug]": [
         {
             "checksum": "bce0c4df3ca7e46551d69872344b06ef",