MCPcopy Create free account
hub / github.com/apache/arrow / ASSERT_OK_AND_ASSIGN

Function ASSERT_OK_AND_ASSIGN

cpp/src/arrow/engine/substrait/serde_test.cc:357–771  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

355 ASSERT_OK_AND_ASSIGN(auto substrait_type, SerializeType(*source_type, &ext_set, {}));
356
357 ASSERT_OK_AND_ASSIGN(auto actual_return,
358 DeserializeType(*substrait_type, ext_set, {}));
359
360 EXPECT_EQ(*actual_return, *return_type);
361 }
362}
363
364// Substrait does not store the time zone as part of the type. That information is stored
365// on the function instead. As a result, that information is lost on a round-trip.
366TEST(Substrait, TimestampTypes) {
367 ExtensionSet ext_set;
368
369 for (auto time_unit :
370 {TimeUnit::NANO, TimeUnit::MICRO, TimeUnit::MILLI, TimeUnit::SECOND}) {
371 for (auto time_zone : {"UTC", "America/New_York"}) {
372 auto input_type = timestamp(time_unit, time_zone);
373 ASSERT_OK_AND_ASSIGN(auto substrait_type, SerializeType(*input_type, &ext_set, {}));
374
375 auto expected_return = timestamp(time_unit, TimestampTzTimezoneString());
376 ASSERT_OK_AND_ASSIGN(auto actual_return,
377 DeserializeType(*substrait_type, ext_set, {}));
378
379 EXPECT_EQ(*actual_return, *expected_return);
380 }
381 auto input_type = timestamp(time_unit);
382 ASSERT_OK_AND_ASSIGN(auto substrait_type, SerializeType(*input_type, &ext_set, {}));
383
384 ASSERT_OK_AND_ASSIGN(auto actual_return,
385 DeserializeType(*substrait_type, ext_set, {}));
386
387 EXPECT_EQ(*actual_return, *input_type);
388 }
389}
390
391TEST(Substrait, NamedStruct) {
392 ExtensionSet ext_set;
393
394 ASSERT_OK_AND_ASSIGN(auto buf,
395 internal::SubstraitFromJSON("NamedStruct", R"({
396 "struct": {
397 "types": [
398 {"i64": {}},
399 {"list": {"type": {"string":{}} }},
400 {"struct": {
401 "types": [
402 {"fp32": {"nullability": "NULLABILITY_REQUIRED"}},
403 {"string": {}}
404 ]
405 }},
406 {"list": {"type": {"string":{}} }},
407 ]
408 },
409 "names": ["a", "b", "c", "d", "e", "f"]
410 })",
411 /*ignore_unknown_fields=*/false));
412 ASSERT_OK_AND_ASSIGN(auto schema, DeserializeSchema(*buf, ext_set));
413 Schema expected_schema({
414 field("a", int64()),

Callers 7

CheckRoundTripResultFunction · 0.70
TESTFunction · 0.70
serde_test.ccFile · 0.70
CheckValidTestCasesFunction · 0.70
CheckErrorTestCasesFunction · 0.70
CheckWholeAggregateCaseFunction · 0.70

Calls 15

SerializeTypeFunction · 0.85
DeserializeTypeFunction · 0.85
listFunction · 0.85
struct_Function · 0.85
SubstraitFromJSONFunction · 0.85
DeserializeSchemaFunction · 0.85
RaisesFunction · 0.85
key_value_metadataFunction · 0.85
DeserializePlansFunction · 0.85
TableFromJSONFunction · 0.85
CheckRoundTripResultFunction · 0.85

Tested by

no test coverage detected