| 529 | } |
| 530 | |
| 531 | std::shared_ptr<const LogicalType> LogicalType::FromThrift( |
| 532 | const format::LogicalType& type) { |
| 533 | if (type.__isset.STRING) { |
| 534 | return StringLogicalType::Make(); |
| 535 | } else if (type.__isset.MAP) { |
| 536 | return MapLogicalType::Make(); |
| 537 | } else if (type.__isset.LIST) { |
| 538 | return ListLogicalType::Make(); |
| 539 | } else if (type.__isset.ENUM) { |
| 540 | return EnumLogicalType::Make(); |
| 541 | } else if (type.__isset.DECIMAL) { |
| 542 | return DecimalLogicalType::Make(type.DECIMAL.precision, type.DECIMAL.scale); |
| 543 | } else if (type.__isset.DATE) { |
| 544 | return DateLogicalType::Make(); |
| 545 | } else if (type.__isset.TIME) { |
| 546 | LogicalType::TimeUnit::unit unit; |
| 547 | if (type.TIME.unit.__isset.MILLIS) { |
| 548 | unit = LogicalType::TimeUnit::MILLIS; |
| 549 | } else if (type.TIME.unit.__isset.MICROS) { |
| 550 | unit = LogicalType::TimeUnit::MICROS; |
| 551 | } else if (type.TIME.unit.__isset.NANOS) { |
| 552 | unit = LogicalType::TimeUnit::NANOS; |
| 553 | } else { |
| 554 | unit = LogicalType::TimeUnit::UNKNOWN; |
| 555 | } |
| 556 | return TimeLogicalType::Make(type.TIME.isAdjustedToUTC, unit); |
| 557 | } else if (type.__isset.TIMESTAMP) { |
| 558 | LogicalType::TimeUnit::unit unit; |
| 559 | if (type.TIMESTAMP.unit.__isset.MILLIS) { |
| 560 | unit = LogicalType::TimeUnit::MILLIS; |
| 561 | } else if (type.TIMESTAMP.unit.__isset.MICROS) { |
| 562 | unit = LogicalType::TimeUnit::MICROS; |
| 563 | } else if (type.TIMESTAMP.unit.__isset.NANOS) { |
| 564 | unit = LogicalType::TimeUnit::NANOS; |
| 565 | } else { |
| 566 | unit = LogicalType::TimeUnit::UNKNOWN; |
| 567 | } |
| 568 | return TimestampLogicalType::Make(type.TIMESTAMP.isAdjustedToUTC, unit); |
| 569 | // TODO(tpboudreau): activate the commented code after parquet.thrift |
| 570 | // recognizes IntervalType as a LogicalType |
| 571 | //} else if (type.__isset.INTERVAL) { |
| 572 | // return IntervalLogicalType::Make(); |
| 573 | } else if (type.__isset.INTEGER) { |
| 574 | return IntLogicalType::Make(static_cast<int>(type.INTEGER.bitWidth), |
| 575 | type.INTEGER.isSigned); |
| 576 | } else if (type.__isset.UNKNOWN) { |
| 577 | return NullLogicalType::Make(); |
| 578 | } else if (type.__isset.JSON) { |
| 579 | return JSONLogicalType::Make(); |
| 580 | } else if (type.__isset.BSON) { |
| 581 | return BSONLogicalType::Make(); |
| 582 | } else if (type.__isset.UUID) { |
| 583 | return UUIDLogicalType::Make(); |
| 584 | } else if (type.__isset.FLOAT16) { |
| 585 | return Float16LogicalType::Make(); |
| 586 | } else if (type.__isset.GEOMETRY) { |
| 587 | std::string crs; |
| 588 | if (type.GEOMETRY.__isset.crs) { |
nothing calls this directly
no test coverage detected