Skip to content

Consolidate map lookup code between get_field and map_extract #25083

Description

@neilconway

Is your feature request related to a problem or challenge?

DataFusion has two SQL constructs to lookup a key k in a map m, m[k] (planned as get_field) and map_extract(m, k)

Their APIs are slightly different (get_field returns the value or NULL, map_extract returns a singleton list or an empty list), but the core work is the same. There are three copies of the underlying key lookup code with different bugs and performance characteristics:

  1. map_extract (after fix, perf: Use Arrow comparator for key comparison in map_extract #24999): one arrow-ord comparator over the whole batch, per-row lookup keys, early exit per row, output sized to the number of matches.
  2. get_field::process_map_array: a vectorized eq kernel between the scalar key and every map key, then a scan of the resulting bitmap. We take this path incorrectly for maps with list-typed keys, resulting in a panic (map[k] panics when key type is list and key is absent #25082)
  3. get_field::process_map_with_nested_key: a comparator that compares each entry against the lookup key.

Since the eq kernel doesn't handle nested lists/maps, we probably want two code paths, but either way we can simplify and unify the code over the current state.

Describe the solution you'd like

No response

Describe alternatives you've considered

No response

Additional context

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions