| 53 | bool can_loosen_type() const { return can_loosen_type_; } |
| 54 | |
| 55 | void LoosenType(const Status& conversion_error) { |
| 56 | ARROW_DCHECK(can_loosen_type_); |
| 57 | |
| 58 | switch (kind_) { |
| 59 | case InferKind::Null: |
| 60 | return SetKind(InferKind::Integer); |
| 61 | case InferKind::Integer: |
| 62 | return SetKind(InferKind::Boolean); |
| 63 | case InferKind::Boolean: |
| 64 | return SetKind(InferKind::Date); |
| 65 | case InferKind::Date: |
| 66 | return SetKind(InferKind::Time); |
| 67 | case InferKind::Time: |
| 68 | return SetKind(InferKind::Timestamp); |
| 69 | case InferKind::Timestamp: |
| 70 | return SetKind(InferKind::TimestampNS); |
| 71 | case InferKind::TimestampNS: |
| 72 | return SetKind(InferKind::TimestampWithZone); |
| 73 | case InferKind::TimestampWithZone: |
| 74 | return SetKind(InferKind::TimestampWithZoneNS); |
| 75 | case InferKind::TimestampWithZoneNS: |
| 76 | return SetKind(InferKind::Real); |
| 77 | case InferKind::Real: |
| 78 | if (options_.auto_dict_encode) { |
| 79 | return SetKind(InferKind::TextDict); |
| 80 | } else { |
| 81 | return SetKind(InferKind::Text); |
| 82 | } |
| 83 | case InferKind::TextDict: |
| 84 | if (conversion_error.IsIndexError()) { |
| 85 | // Cardinality too large, fall back to non-dict encoding |
| 86 | return SetKind(InferKind::Text); |
| 87 | } else { |
| 88 | // Assuming UTF8 validation failure |
| 89 | return SetKind(InferKind::BinaryDict); |
| 90 | } |
| 91 | break; |
| 92 | case InferKind::BinaryDict: |
| 93 | // Assuming cardinality too large |
| 94 | return SetKind(InferKind::Binary); |
| 95 | case InferKind::Text: |
| 96 | // Assuming UTF8 validation failure |
| 97 | return SetKind(InferKind::Binary); |
| 98 | default: |
| 99 | ARROW_LOG(FATAL) << "Shouldn't come here"; |
| 100 | } |
| 101 | } |
| 102 | |
| 103 | Result<std::shared_ptr<Converter>> MakeConverter(MemoryPool* pool) { |
| 104 | auto make_converter = |
no test coverage detected