Skip to content

colexec: implement vectorized version of NotExpr #70713

Description

@yuzefovich

Currently, tree.NotExpr is not implemented natively in the vectorized engine, so we have to fallback to the older row-by-row engine to evaluate it. We should, instead, vectorize NotExpr.

I think the implementation will be quite similar to how tree.IsNullExpr is implemented, and I think we will want to implement two versions of NotExpr operator:

  • one for projections, which populates a coldata.Vec with values equal to evaluating NOT predicate on each row in another coldata.Vec (while paying attention to nulls in the input vector and the selection vector on the input batch)
  • one for selections, which updates the selection vector on the batch to include only rows for which NOT predicate evaluated to true.

Some code pointers:

  • the planning is done in colbuilder/execplan.go in planProjectionOperators and planSelectionOperators
  • tree.NotExpr lives in sem/tree/expr.go
  • the vectorized implementation of tree.IsNullExpr lives in colexec/is_null_ops.eg.go (which is automatically generated based on colexec/is_nulls_ops_tmpl.go and colexec/execgen/cmd/execgen/is_nulls_ops_gen.go).

Please let me know if more guidance is needed.

Jira issue: CRDB-10187

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-cleanupTech debt, refactors, loose ends, etc. Solution not expected to significantly change behavior.T-sql-queriesSQL Queries Teamgood first issue

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    Status
    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions