| 859 | }; |
| 860 | |
| 861 | Result<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 | |
| 886 | struct ResolveMapLookup { |
| 887 | KernelContext* ctx; |