| 254 | } |
| 255 | |
| 256 | bool CanCast(const DataType& from_type, const DataType& to_type) { |
| 257 | internal::EnsureInitCastTable(); |
| 258 | auto it = internal::g_cast_table.find(static_cast<int>(to_type.id())); |
| 259 | if (it == internal::g_cast_table.end()) { |
| 260 | return false; |
| 261 | } |
| 262 | |
| 263 | const internal::CastFunction* function = it->second.get(); |
| 264 | DCHECK_EQ(function->out_type_id(), to_type.id()); |
| 265 | |
| 266 | for (auto from_id : function->in_type_ids()) { |
| 267 | // XXX should probably check the output type as well |
| 268 | if (from_type.id() == from_id) return true; |
| 269 | } |
| 270 | |
| 271 | return false; |
| 272 | } |
| 273 | |
| 274 | } // namespace compute |
| 275 | } // namespace arrow |