| 348 | } |
| 349 | |
| 350 | TypeHolder CommonBinary(const TypeHolder* begin, size_t count) { |
| 351 | bool all_utf8 = true, all_offset32 = true, all_fixed_width = true; |
| 352 | |
| 353 | const TypeHolder* end = begin + count; |
| 354 | for (auto it = begin; it != end; ++it) { |
| 355 | auto id = it->type->id(); |
| 356 | // a common varbinary type is only possible if all types are binary like |
| 357 | switch (id) { |
| 358 | case Type::STRING: |
| 359 | all_fixed_width = false; |
| 360 | continue; |
| 361 | case Type::BINARY: |
| 362 | all_fixed_width = false; |
| 363 | all_utf8 = false; |
| 364 | continue; |
| 365 | case Type::FIXED_SIZE_BINARY: |
| 366 | all_utf8 = false; |
| 367 | continue; |
| 368 | case Type::LARGE_STRING: |
| 369 | all_offset32 = false; |
| 370 | all_fixed_width = false; |
| 371 | continue; |
| 372 | case Type::LARGE_BINARY: |
| 373 | all_offset32 = false; |
| 374 | all_fixed_width = false; |
| 375 | all_utf8 = false; |
| 376 | continue; |
| 377 | default: |
| 378 | return TypeHolder(nullptr); |
| 379 | } |
| 380 | } |
| 381 | |
| 382 | if (all_fixed_width) { |
| 383 | // At least for the purposes of comparison, no need to cast. |
| 384 | return TypeHolder(nullptr); |
| 385 | } |
| 386 | |
| 387 | if (all_utf8) { |
| 388 | if (all_offset32) return utf8(); |
| 389 | return large_utf8(); |
| 390 | } |
| 391 | |
| 392 | if (all_offset32) return binary(); |
| 393 | return large_binary(); |
| 394 | } |
| 395 | |
| 396 | bool CastableToDecimal(const DataType& type) { |
| 397 | return is_numeric(type.id()) || is_decimal(type.id()); |
no test coverage detected