github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/sql/opt/norm/rules/project_set.opt (about)

     1  # =============================================================================
     2  # project_set.opt contains normalization rules for the ProjectSet operator.
     3  # =============================================================================
     4  
     5  # ConvertZipArraysToValues applies the unnest, json_array_elements and
     6  # jsonb_array_elements zip functions to array inputs, converting them into a
     7  # Values operator within an InnerJoinApply. This allows Values and decorrelation
     8  # rules to fire. It is especially useful in cases where the contents are passed
     9  # as a PREPARE parameter, such as:
    10  #
    11  #   SELECT * FROM xy WHERE y IN unnest($1)
    12  # or:
    13  #   SELECT json_array_elements($1)
    14  #
    15  # The replace pattern is equivalent to the match pattern because the
    16  # InnerJoinApply outputs every value in the array for every row in the input,
    17  # and outputs nulls to pad shorter arrays. It also supports correlation between
    18  # the array arguments and the input expression.
    19  [ConvertZipArraysToValues, Normalize]
    20  (ProjectSet $input:* $zip:* & (CanConstructValuesFromZips $zip))
    21  =>
    22  (InnerJoinApply
    23      $input
    24      (ConstructValuesFromZips $zip)
    25      []
    26      (EmptyJoinPrivate)
    27  )