aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordcherednik <dcherednik@ydb.tech>2023-02-04 11:54:22 +0300
committerdcherednik <dcherednik@ydb.tech>2023-02-04 11:54:22 +0300
commit44f483e5f9bd958243bbb4ee3d044c6e7bba3c87 (patch)
tree17f7073c409acb8ade31e3ac4f37e9a0c71127c2
parent5a626ee1b7159798bb105e085af58f9506610d55 (diff)
downloadydb-44f483e5f9bd958243bbb4ee3d044c6e7bba3c87.tar.gz
Public api representation for Optional<Variant<T>> type ut.
-rw-r--r--ydb/core/engine/mkql_proto_ut.cpp130
1 files changed, 122 insertions, 8 deletions
diff --git a/ydb/core/engine/mkql_proto_ut.cpp b/ydb/core/engine/mkql_proto_ut.cpp
index 5ac30073b5..4e6a76ee43 100644
--- a/ydb/core/engine/mkql_proto_ut.cpp
+++ b/ydb/core/engine/mkql_proto_ut.cpp
@@ -154,13 +154,13 @@ Y_UNIT_TEST_SUITE(TMiniKQLProtoTestYdb) {
}
)___";
TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) {
- std::vector<TType*> tupleElemenTypes;
- tupleElemenTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id));
- tupleElemenTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
auto pgmReturn = pgmBuilder.NewVariant(
pgmBuilder.NewDataLiteral<ui32>(66),
1,
- pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElemenTypes)));
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes)));
return pgmReturn;
},
expected);
@@ -374,13 +374,13 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) {
Y_UNIT_TEST(TestExportVariantYdb) {
TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) {
- std::vector<TType*> tupleElemenTypes;
- tupleElemenTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id));
- tupleElemenTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
auto pgmReturn = pgmBuilder.NewVariant(
pgmBuilder.NewDataLiteral<ui32>(66),
1,
- pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElemenTypes)));
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes)));
return pgmReturn;
},
"nested_value {\n"
@@ -389,6 +389,120 @@ Y_UNIT_TEST(TestExportVariantStructTypeYdb) {
"variant_index: 1\n");
}
+ Y_UNIT_TEST(TestExportMultipleOptionalVariantNotNullYdb) {
+ TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) {
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+
+ auto pgmReturn = pgmBuilder.NewOptional(
+ pgmBuilder.NewOptional(pgmBuilder.NewVariant(
+ pgmBuilder.NewDataLiteral<ui32>(66),
+ 1,
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes)))));
+ return pgmReturn;
+ },
+ "nested_value {\n"
+ " uint32_value: 66\n"
+ "}\n"
+ "variant_index: 1\n");
+ }
+
+ Y_UNIT_TEST(TestExportOptionalVariantOptionalNullYdb) {
+ TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) {
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewOptionalType(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id)));
+
+ auto pgmReturn = pgmBuilder.NewOptional(pgmBuilder.NewVariant(
+ pgmBuilder.NewEmptyOptionalDataLiteral(NUdf::TDataType<ui64>::Id),
+ 1,
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes))));
+ return pgmReturn;
+ },
+ "nested_value {\n"
+ " nested_value {\n"
+ " null_flag_value: NULL_VALUE\n"
+ " }\n"
+ " variant_index: 1\n"
+ "}\n");
+ }
+
+
+ Y_UNIT_TEST(TestExportMultipleOptionalVariantOptionalNullYdb) {
+ TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) {
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewOptionalType(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id)));
+
+ auto pgmReturn = pgmBuilder.NewOptional(
+ pgmBuilder.NewOptional(pgmBuilder.NewVariant(
+ pgmBuilder.NewEmptyOptionalDataLiteral(NUdf::TDataType<ui64>::Id),
+ 1,
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes)))));
+ return pgmReturn;
+ },
+ "nested_value {\n"
+ " nested_value {\n"
+ " nested_value {\n"
+ " null_flag_value: NULL_VALUE\n"
+ " }\n"
+ " variant_index: 1\n"
+ " }\n"
+ "}\n");
+ }
+
+ Y_UNIT_TEST(TestExportMultipleOptionalVariantOptionalNotNullYdb) {
+ TestExportValue<Ydb::Value>([](TProgramBuilder& pgmBuilder) {
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewOptionalType(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id)));
+
+ auto pgmReturn = pgmBuilder.NewOptional(
+ pgmBuilder.NewOptional(pgmBuilder.NewVariant(
+ pgmBuilder.NewOptional(pgmBuilder.NewDataLiteral<ui64>(66)),
+ 1,
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes)))));
+ return pgmReturn;
+ },
+ "nested_value {\n"
+ " uint64_value: 66\n"
+ "}\n"
+ "variant_index: 1\n");
+ }
+
+ Y_UNIT_TEST(TestExportOptionalVariantOptionalYdbType) {
+ TestExportType<Ydb::Type>([](TProgramBuilder& pgmBuilder) {
+ std::vector<TType*> tupleElementTypes;
+ tupleElementTypes.push_back(pgmBuilder.NewDataType(NUdf::TDataType<ui32>::Id));
+ tupleElementTypes.push_back(pgmBuilder.NewOptionalType(pgmBuilder.NewDataType(NUdf::TDataType<ui64>::Id)));
+
+ auto pgmReturn = pgmBuilder.NewOptional(pgmBuilder.NewVariant(
+ pgmBuilder.NewEmptyOptionalDataLiteral(NUdf::TDataType<ui64>::Id),
+ 1,
+ pgmBuilder.NewVariantType(pgmBuilder.NewTupleType(tupleElementTypes))));
+ return pgmReturn;
+ },
+ "optional_type {\n"
+ " item {\n"
+ " variant_type {\n"
+ " tuple_items {\n"
+ " elements {\n"
+ " type_id: UINT32\n"
+ " }\n"
+ " elements {\n"
+ " optional_type {\n"
+ " item {\n"
+ " type_id: UINT64\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ " }\n"
+ "}\n");
+ }
+
TString DoTestCellsFromTuple(const TConstArrayRef<NScheme::TTypeInfo>& types, TString paramsProto) {
NKikimrMiniKQL::TParams params;
bool parseOk = ::google::protobuf::TextFormat::ParseFromString(paramsProto, &params);