aboutsummaryrefslogtreecommitdiffstats
path: root/yt/cpp
diff options
context:
space:
mode:
authorwhatsername <whatsername@yandex-team.com>2024-03-21 12:38:52 +0300
committerwhatsername <whatsername@yandex-team.com>2024-03-21 12:49:42 +0300
commitf2d8ab4111c1f5dba066eb9df8a2ecd86cd8c192 (patch)
tree73ac9be80fb07e711b489a5ee6bcf2fcdda0f667 /yt/cpp
parent345654a416ff6d02ba04db39de7e1965b47aa844 (diff)
downloadydb-f2d8ab4111c1f5dba066eb9df8a2ecd86cd8c192.tar.gz
YT-18458: Introduce wide types into mapreduce interface
7ae047ef618cc44d7dd3e817dc27f2336d9e38c3
Diffstat (limited to 'yt/cpp')
-rw-r--r--yt/cpp/mapreduce/client/skiff.cpp6
-rw-r--r--yt/cpp/mapreduce/interface/common.cpp27
-rw-r--r--yt/cpp/mapreduce/interface/common.h9
-rw-r--r--yt/cpp/mapreduce/interface/common_ut.cpp10
-rw-r--r--yt/cpp/mapreduce/interface/serialize.cpp5
5 files changed, 57 insertions, 0 deletions
diff --git a/yt/cpp/mapreduce/client/skiff.cpp b/yt/cpp/mapreduce/client/skiff.cpp
index 1eb2e80d79..f6e52f44e8 100644
--- a/yt/cpp/mapreduce/client/skiff.cpp
+++ b/yt/cpp/mapreduce/client/skiff.cpp
@@ -94,6 +94,12 @@ NSkiff::EWireType ValueTypeToSkiffType(EValueType valueType)
case VT_INTERVAL:
return EWireType::Int64;
+
+ case VT_DATE32:
+ case VT_DATETIME64:
+ case VT_TIMESTAMP64:
+ case VT_INTERVAL64:
+ return EWireType::Int64;
};
ythrow yexception() << "Cannot convert EValueType '" << valueType << "' to NSkiff::EWireType";
}
diff --git a/yt/cpp/mapreduce/interface/common.cpp b/yt/cpp/mapreduce/interface/common.cpp
index 28f98713f6..0a46c0b583 100644
--- a/yt/cpp/mapreduce/interface/common.cpp
+++ b/yt/cpp/mapreduce/interface/common.cpp
@@ -192,6 +192,15 @@ static NTi::TTypePtr OldTypeToTypeV3(EValueType type)
return NTi::Float();
case VT_JSON:
return NTi::Json();
+
+ case VT_DATE32:
+ return NTi::Date32();
+ case VT_DATETIME64:
+ return NTi::Datetime64();
+ case VT_TIMESTAMP64:
+ return NTi::Timestamp64();
+ case VT_INTERVAL64:
+ return NTi::Interval64();
}
}
@@ -254,6 +263,15 @@ static std::pair<EValueType, bool> Simplify(const NTi::TTypePtr& type)
case ETypeName::Yson:
return {VT_ANY, true};
+ case ETypeName::Date32:
+ return {VT_DATE32, true};
+ case ETypeName::Datetime64:
+ return {VT_DATETIME64, true};
+ case ETypeName::Timestamp64:
+ return {VT_TIMESTAMP64, true};
+ case ETypeName::Interval64:
+ return {VT_INTERVAL64, true};
+
case ETypeName::Void:
return {VT_VOID, false};
case ETypeName::Null:
@@ -633,6 +651,15 @@ TString ToString(EValueType type)
case VT_JSON:
return "json";
+
+ case VT_DATE32:
+ return "date32";
+ case VT_DATETIME64:
+ return "datetime64";
+ case VT_TIMESTAMP64:
+ return "timestamp64";
+ case VT_INTERVAL64:
+ return "interval64";
}
ythrow yexception() << "Invalid value type " << static_cast<int>(type);
}
diff --git a/yt/cpp/mapreduce/interface/common.h b/yt/cpp/mapreduce/interface/common.h
index ead8284b57..8b3edf48c4 100644
--- a/yt/cpp/mapreduce/interface/common.h
+++ b/yt/cpp/mapreduce/interface/common.h
@@ -403,6 +403,15 @@ enum EValueType : int
VT_FLOAT,
/// Json, sequence of bytes that is valid json.
VT_JSON,
+
+ // Date32, number of days shifted from Unix epoch, which is 0 (signed)
+ VT_DATE32,
+ // Datetime64, number of seconds shifted from Unix epoch, which is 0 (signed)
+ VT_DATETIME64,
+ // Timestamp64, number of milliseconds shifted from Unix epoch, which is 0 (signed)
+ VT_TIMESTAMP64,
+ // Interval64, difference between two timestamps64 (signed)
+ VT_INTERVAL64,
};
///
diff --git a/yt/cpp/mapreduce/interface/common_ut.cpp b/yt/cpp/mapreduce/interface/common_ut.cpp
index f9f0664039..05d7495ca2 100644
--- a/yt/cpp/mapreduce/interface/common_ut.cpp
+++ b/yt/cpp/mapreduce/interface/common_ut.cpp
@@ -228,6 +228,16 @@ Y_UNIT_TEST_SUITE(Common)
UNIT_ASSERT_VALUES_EQUAL(column.Type(), VT_DATE);
}
{
+ auto column = TColumnSchema().Type(NTi::Interval64());
+ UNIT_ASSERT_VALUES_EQUAL(column.Required(), true);
+ UNIT_ASSERT_VALUES_EQUAL(column.Type(), VT_INTERVAL64);
+ }
+ {
+ auto column = TColumnSchema().Type(NTi::Optional(NTi::Date32()));
+ UNIT_ASSERT_VALUES_EQUAL(column.Required(), false);
+ UNIT_ASSERT_VALUES_EQUAL(column.Type(), VT_DATE32);
+ }
+ {
auto column = TColumnSchema().Type(NTi::Null());
UNIT_ASSERT_VALUES_EQUAL(column.Required(), false);
UNIT_ASSERT_VALUES_EQUAL(column.Type(), VT_NULL);
diff --git a/yt/cpp/mapreduce/interface/serialize.cpp b/yt/cpp/mapreduce/interface/serialize.cpp
index 18cfaaa9b7..9be114b45e 100644
--- a/yt/cpp/mapreduce/interface/serialize.cpp
+++ b/yt/cpp/mapreduce/interface/serialize.cpp
@@ -129,6 +129,11 @@ void Deserialize(EValueType& valueType, const TNode& node)
{"interval", VT_INTERVAL},
{"float", VT_FLOAT},
{"json", VT_JSON},
+
+ {"date32", VT_DATE32},
+ {"datetime64", VT_DATETIME64},
+ {"timestamp64", VT_TIMESTAMP64},
+ {"interval64", VT_INTERVAL64},
};
auto it = str2ValueType.find(nodeStr);