MCPcopy Create free account
hub / github.com/apache/arrow / CanCast

Function CanCast

cpp/src/arrow/compute/cast.cc:256–272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254}
255
256bool 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

Callers 5

InitMethod · 0.85
PromoteTableToSchemaFunction · 0.85
GetResultMethod · 0.85
TESTFunction · 0.85
UnpackDictionaryFunction · 0.85

Calls 6

EnsureInitCastTableFunction · 0.85
out_type_idMethod · 0.80
findMethod · 0.45
idMethod · 0.45
endMethod · 0.45
getMethod · 0.45

Tested by 1

TESTFunction · 0.68