Skip to content

Commit f9ae353

Browse files
fedor-mironrekby
authored andcommitted
Block datetime2 (ydb-platform#6472)
1 parent 5e7a2a8 commit f9ae353

File tree

41 files changed

+1930
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1930
-307
lines changed

ydb/library/yql/public/udf/arrow/block_builder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ class IScalarBuilder {
5555
public:
5656
virtual ~IScalarBuilder() = default;
5757
virtual arrow::Datum Build(TBlockItem value) const = 0;
58+
virtual arrow::Datum Build(NUdf::TUnboxedValuePod value) const = 0;
5859
};
5960

6061
inline std::shared_ptr<arrow::DataType> GetArrowType(const ITypeInfoHelper& typeInfoHelper, const TType* type) {

ydb/library/yql/public/udf/arrow/block_item.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ class TBlockItem {
6464
Raw.Halfs[1] = high;
6565
}
6666

67+
inline static TBlockItem Embedded(const TStringRef& value) {
68+
UDF_VERIFY(value.Size() <= sizeof(TRawEmbeddedValue::Buffer));
69+
70+
TBlockItem v;
71+
v.Raw.Embedded.Size = value.Size();
72+
v.Raw.Embedded.Meta = static_cast<ui8>(EMarkers::Embedded);
73+
if (v.Raw.Embedded.Size) {
74+
std::memcpy(v.Raw.Embedded.Buffer, value.Data(), v.Raw.Embedded.Size);
75+
}
76+
77+
return v;
78+
}
79+
6780
inline ui64 Low() const {
6881
return Raw.Halfs[0];
6982
}

ydb/library/yql/public/udf/udf_helpers.h

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include "udf_type_builder.h"
88
#include "udf_type_inspection.h"
99
#include "udf_version.h"
10+
#include "udf_type_printer.h"
1011

1112
#include <util/generic/yexception.h>
1213
#include <util/generic/string.h>
@@ -230,7 +231,7 @@ namespace NUdf {
230231
namespace NYql {
231232
namespace NUdf {
232233

233-
template<bool CheckOptional, const char* TFuncName, template<class> class TFunc, typename... TUserTypes>
234+
template<bool CheckOptional, bool CheckBlock, const char* TFuncName, template<class> class TFunc, typename... TUserTypes>
234235
class TUserDataTypeFuncFactory : public ::NYql::NUdf::TBoxedValue {
235236
public:
236237
typedef bool TTypeAwareMarker;
@@ -241,8 +242,29 @@ class TUserDataTypeFuncFactory : public ::NYql::NUdf::TBoxedValue {
241242
return name;
242243
}
243244

245+
static const TType* ExtractArgFromUserType(::NYql::NUdf::TType const* userType, ::NYql::NUdf::IFunctionTypeInfoBuilder& builder) {
246+
if constexpr (CheckBlock) {
247+
#if UDF_ABI_COMPATIBILITY_VERSION_CURRENT >= UDF_ABI_COMPATIBILITY_VERSION(2, 26)
248+
TBlockTypeInspector block(*builder.TypeInfoHelper(), userType);
249+
if (block) {
250+
userType = block.GetItemType();
251+
}
252+
#endif
253+
}
254+
255+
if constexpr (CheckOptional) {
256+
TOptionalTypeInspector optionalTypeInspector(*builder.TypeInfoHelper(), userType);
257+
if (optionalTypeInspector) {
258+
userType = optionalTypeInspector.GetItemType();
259+
}
260+
}
261+
return userType;
262+
}
263+
264+
244265
template<typename TUserType>
245266
static bool DeclareSignatureImpl(
267+
const ::NYql::NUdf::TStringRef& name,
246268
TDataTypeId typeId,
247269
::NYql::NUdf::TType* userType,
248270
::NYql::NUdf::IFunctionTypeInfoBuilder& builder,
@@ -251,21 +273,22 @@ class TUserDataTypeFuncFactory : public ::NYql::NUdf::TBoxedValue {
251273
if (TDataType<TUserType>::Id != typeId) {
252274
return false;
253275
}
254-
TFunc<TUserType>::DeclareSignature(userType, builder, typesOnly);
276+
TFunc<TUserType>::DeclareSignature(name, userType, builder, typesOnly);
255277
return true;
256278
}
257279

258280
template<typename TUserType, typename THead, typename... TTail>
259281
static bool DeclareSignatureImpl(
282+
const ::NYql::NUdf::TStringRef& name,
260283
TDataTypeId typeId,
261284
::NYql::NUdf::TType* userType,
262285
::NYql::NUdf::IFunctionTypeInfoBuilder& builder,
263286
bool typesOnly)
264287
{
265-
if (DeclareSignatureImpl<TUserType>(typeId, userType, builder, typesOnly)) {
288+
if (DeclareSignatureImpl<TUserType>(name, typeId, userType, builder, typesOnly)) {
266289
return true;
267290
}
268-
return DeclareSignatureImpl<THead, TTail...>(typeId, userType, builder, typesOnly);
291+
return DeclareSignatureImpl<THead, TTail...>(name, typeId, userType, builder, typesOnly);
269292
}
270293

271294
static bool DeclareSignature(
@@ -297,24 +320,20 @@ class TUserDataTypeFuncFactory : public ::NYql::NUdf::TBoxedValue {
297320
return true;
298321
}
299322

300-
auto argType = argsTypeInspector.GetElementType(0);
301-
if (CheckOptional) {
302-
TOptionalTypeInspector optionalTypeInspector(*typeHelper, argType);
303-
if (optionalTypeInspector) {
304-
argType = optionalTypeInspector.GetItemType();
305-
}
306-
}
307-
323+
auto argType = ExtractArgFromUserType(argsTypeInspector.GetElementType(0), builder);
308324
TDataTypeInspector dataTypeInspector(*typeHelper, argType);
309325
if (!dataTypeInspector) {
310-
builder.SetError("User type must be a data type");
326+
TStringStream ss;
327+
NUdf::TTypePrinter p(*typeHelper, argType);
328+
p.Out(ss);
329+
builder.SetError("User type must be a data type. Got: " + ss.Str());
311330
return true;
312331
}
313332

314333
builder.UserType(userType);
315334

316335
auto typeId = dataTypeInspector.GetTypeId();
317-
if (!DeclareSignatureImpl<TUserTypes...>(typeId, userType, builder, typesOnly)) {
336+
if (!DeclareSignatureImpl<TUserTypes...>(name, typeId, userType, builder, typesOnly)) {
318337
TStringBuilder sb;
319338
sb << "User type " << NYql::NUdf::GetDataTypeInfo(NYql::NUdf::GetDataSlot(typeId)).Name << " is not supported";
320339
builder.SetError(sb);

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,9 +2676,9 @@
26762676
],
26772677
"test.test[tpch-q4-default.txt-Debug]": [
26782678
{
2679-
"checksum": "fa97974f3e4f836f43084b7b51457555",
2680-
"size": 6558,
2681-
"uri": "https://{canondata_backend}/1936273/640ea425b9d5a6140c315077f2a83bba387482d8/resource.tar.gz#test.test_tpch-q4-default.txt-Debug_/opt.yql_patched"
2679+
"checksum": "586ed902d93adfc763c04941b2d441bc",
2680+
"size": 6571,
2681+
"uri": "https://{canondata_backend}/1889210/a4abb800446905e7d80fe38237bce315efaf5daf/resource.tar.gz#test.test_tpch-q4-default.txt-Debug_/opt.yql_patched"
26822682
}
26832683
],
26842684
"test.test[tpch-q4-default.txt-Plan]": [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3196,9 +3196,9 @@
31963196
],
31973197
"test.test[tpch-q9-default.txt-Debug]": [
31983198
{
3199-
"checksum": "3f9b976ba4e5ecb8f6acd1fd83dc3209",
3200-
"size": 15152,
3201-
"uri": "https://{canondata_backend}/1773845/4aaca50c52fbfe0fc1a237a3c226e5e498d0a750/resource.tar.gz#test.test_tpch-q9-default.txt-Debug_/opt.yql_patched"
3199+
"checksum": "f7716c3ea29895e9415bbcaed60d7c72",
3200+
"size": 15168,
3201+
"uri": "https://{canondata_backend}/1937429/78ec1f4830087224762acf32450614354d7be3d3/resource.tar.gz#test.test_tpch-q9-default.txt-Debug_/opt.yql_patched"
32023202
}
32033203
],
32043204
"test.test[tpch-q9-default.txt-Plan]": [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,9 +2665,9 @@
26652665
],
26662666
"test.test[tpch-q7-default.txt-Debug]": [
26672667
{
2668-
"checksum": "0b9b1561895054f3b536f360bc8a6267",
2669-
"size": 13861,
2670-
"uri": "https://{canondata_backend}/1942100/deb1f289b9c40e713d0d9f614e8c3a720d26b7b2/resource.tar.gz#test.test_tpch-q7-default.txt-Debug_/opt.yql_patched"
2668+
"checksum": "5b106452b548a9a4f4f02e8ab9e9f09a",
2669+
"size": 13877,
2670+
"uri": "https://{canondata_backend}/1942415/2c150f45c52c46e02dfa026eba628abd4ad9dfb4/resource.tar.gz#test.test_tpch-q7-default.txt-Debug_/opt.yql_patched"
26712671
}
26722672
],
26732673
"test.test[tpch-q7-default.txt-Plan]": [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,9 +1122,9 @@
11221122
],
11231123
"test.test[expr-tzdate_result-default.txt-Debug]": [
11241124
{
1125-
"checksum": "a1fcbf9bcc953298a3f8647f2135a799",
1126-
"size": 1722,
1127-
"uri": "https://{canondata_backend}/1775319/581989ddfd844cd7fb811fb9f47c5b23d36a9346/resource.tar.gz#test.test_expr-tzdate_result-default.txt-Debug_/opt.yql_patched"
1125+
"checksum": "bec143e52a14ad138121bea4b97ca0c8",
1126+
"size": 1735,
1127+
"uri": "https://{canondata_backend}/937458/cc57ea281d0b003d397eca8623f6324d4f1e6ded/resource.tar.gz#test.test_expr-tzdate_result-default.txt-Debug_/opt.yql_patched"
11281128
}
11291129
],
11301130
"test.test[expr-tzdate_result-default.txt-Plan]": [

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,9 @@
816816
],
817817
"test.test[expr-common_type_for_resource_and_data--Debug]": [
818818
{
819-
"checksum": "ae28d0bdc3d0a59f3e99d005f955d630",
820-
"size": 3492,
821-
"uri": "https://{canondata_backend}/1689644/6139df48f06d115a1d5f163e031f1e5df6703b0a/resource.tar.gz#test.test_expr-common_type_for_resource_and_data--Debug_/opt.yql_patched"
819+
"checksum": "1b8cf5b11c77c61cd000810efce6a38c",
820+
"size": 3539,
821+
"uri": "https://{canondata_backend}/1903280/1302f1777838aa638bf5151db4710571d26da566/resource.tar.gz#test.test_expr-common_type_for_resource_and_data--Debug_/opt.yql_patched"
822822
}
823823
],
824824
"test.test[expr-common_type_for_resource_and_data--Plan]": [
@@ -2867,9 +2867,9 @@
28672867
],
28682868
"test.test[tpch-q8-default.txt-Debug]": [
28692869
{
2870-
"checksum": "6a72885bec76f87355344ab5fb5431d9",
2871-
"size": 19359,
2872-
"uri": "https://{canondata_backend}/1936273/b293975a7642b91c5614f8db12d1bd08a0069400/resource.tar.gz#test.test_tpch-q8-default.txt-Debug_/opt.yql_patched"
2870+
"checksum": "37f656e7e4d787e6b3796b3c0b2f133b",
2871+
"size": 19375,
2872+
"uri": "https://{canondata_backend}/1916746/32827f362cb6c38e96ef3cab50123012d246aeb2/resource.tar.gz#test.test_tpch-q8-default.txt-Debug_/opt.yql_patched"
28732873
}
28742874
],
28752875
"test.test[tpch-q8-default.txt-Plan]": [

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,9 +1047,9 @@
10471047
],
10481048
"test.test[expr-current_tz-default.txt-Debug]": [
10491049
{
1050-
"checksum": "853bd1a6551bf7536d82724783e1a544",
1051-
"size": 1564,
1052-
"uri": "https://{canondata_backend}/1814674/3d7a051907f912bc7d3b372a45188178d665b7e0/resource.tar.gz#test.test_expr-current_tz-default.txt-Debug_/opt.yql_patched"
1050+
"checksum": "7edb02f79083005521d530f6d9a1a633",
1051+
"size": 1577,
1052+
"uri": "https://{canondata_backend}/1773845/29384e5593c1d8c2c9ee9307be07d1d1504ae89a/resource.tar.gz#test.test_expr-current_tz-default.txt-Debug_/opt.yql_patched"
10531053
}
10541054
],
10551055
"test.test[expr-current_tz-default.txt-Plan]": [

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2773,9 +2773,9 @@
27732773
],
27742774
"test.test[tpch-q4-default.txt-Debug]": [
27752775
{
2776-
"checksum": "33c1896a2d354cc13ecaa0b73421a590",
2777-
"size": 8923,
2778-
"uri": "https://{canondata_backend}/1814674/3093cfcf161964e2f455dca1526460f8a4e7c86f/resource.tar.gz#test.test_tpch-q4-default.txt-Debug_/opt.yql_patched"
2776+
"checksum": "7292362d355a15380a74d5b99ab38a2d",
2777+
"size": 8936,
2778+
"uri": "https://{canondata_backend}/1942100/19f57226e1981b417dcd7e8effae6c4c1fbb32d6/resource.tar.gz#test.test_tpch-q4-default.txt-Debug_/opt.yql_patched"
27792779
}
27802780
],
27812781
"test.test[tpch-q4-default.txt-Plan]": [
@@ -2787,9 +2787,9 @@
27872787
],
27882788
"test.test[tpch-q7-default.txt-Debug]": [
27892789
{
2790-
"checksum": "184514dc0f1a53d2d2376ea0c748452d",
2791-
"size": 11224,
2792-
"uri": "https://{canondata_backend}/1814674/3093cfcf161964e2f455dca1526460f8a4e7c86f/resource.tar.gz#test.test_tpch-q7-default.txt-Debug_/opt.yql_patched"
2790+
"checksum": "63a087536ce3cf1bc72dc226f7dde9a1",
2791+
"size": 11240,
2792+
"uri": "https://{canondata_backend}/212715/21559565f64527becae9026391f72c061d482bd8/resource.tar.gz#test.test_tpch-q7-default.txt-Debug_/opt.yql_patched"
27932793
}
27942794
],
27952795
"test.test[tpch-q7-default.txt-Plan]": [

0 commit comments

Comments
 (0)