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

Function ResolveMapLookupType

cpp/src/arrow/compute/kernels/scalar_nested.cc:861–884  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

859};
860
861Result<TypeHolder> ResolveMapLookupType(KernelContext* ctx,
862 const std::vector<TypeHolder>& types) {
863 const auto& options = OptionsWrapper<MapLookupOptions>::Get(ctx);
864 const auto& type = checked_cast<const MapType&>(*types.front().type);
865 std::shared_ptr<DataType> item_type = type.item_type();
866 std::shared_ptr<DataType> key_type = type.key_type();
867
868 if (!options.query_key) {
869 return Status::Invalid("map_lookup: query_key can't be empty.");
870 } else if (!options.query_key->is_valid) {
871 return Status::Invalid("map_lookup: query_key can't be null.");
872 } else if (!options.query_key->type->Equals(key_type)) {
873 return Status::TypeError(
874 "map_lookup: query_key type and Map key_type don't match. Expected "
875 "type: ",
876 *key_type, ", but got type: ", *options.query_key->type);
877 }
878
879 if (options.occurrence == MapLookupOptions::Occurrence::ALL) {
880 return list(item_type);
881 } else { /* occurrence == FIRST || LAST */
882 return item_type;
883 }
884}
885
886struct ResolveMapLookup {
887 KernelContext* ctx;

Callers

nothing calls this directly

Calls 5

listFunction · 0.85
GetFunction · 0.50
InvalidFunction · 0.50
TypeErrorFunction · 0.50
EqualsMethod · 0.45

Tested by

no test coverage detected