Skip to content

Avoid re-evaluating build keys in array_map_key_range #26806

Open

Description

@dwsmith1983

Is your feature request related to a problem or challenge?

array_map_key_range (datafusion/physical-plan/src/joins/hash_join/exec.rs) takes the build batches and, under NullEqualsNull, evaluates the join key expressions again to check for nulls. It also sums num_rows over the batches.

After #26793, build_in_memory concatenates first and has already evaluated the keys into left_values before it calls array_map_key_range, which now always gets that one concatenated batch. For a computed key that is an array map candidate under NullEqualsNull, the keys are evaluated twice, and the second copy covers the whole build side rather than one input batch at a time.

Describe the solution you'd like

Pass &left_values[0] (for the null count) and num_rows to array_map_key_range instead of &[RecordBatch]. This drops the duplicate evaluation and the row count loop, and makes the function's inputs match what it actually uses.

Describe alternatives you've considered

Leave it as is. It only matters for computed integer keys under NullEqualsNull, and the extra evaluation is transient.

Additional context

Came up in review of #26793 (follows #26792).

Willingness to contribute

I cannot contribute to this feature at this time

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions