| 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. |
| 366 | TEST(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 | |
| 391 | TEST(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()), |
no test coverage detected