Skip to content
This repository has been archived by the owner on Jan 28, 2021. It is now read-only.

sql: implement EXPLODE and generators #720

Merged
merged 1 commit into from
Jun 3, 2019

Commits on Jun 3, 2019

  1. sql: implement EXPLODE and generators

    This pull request implements the EXPLODE expressions and generators,
    which are used together to provide generation of rows based on a
    column or expression that can yield multiple values.
    
    For this, there have been some quite core changes:
    - SQL method of sql.Type now returns the sqltypes.Value and an error.
      This avoids panics in this method. Since generators can yield errors
      it's better to just return an error and not just kill the server.
    - Array type can now internally handle either arrays or generators,
      making it transparent for the user. If it's used in an EXPLODE
      expression, the generator will be used. Otherwise, it will be
      converted automatically to an array and used without the user even
      knowing what happened behind the scenes. That way, we don't need
      yet another type to represent generators.
    
    Aside from that, there are some new additions:
    - New EXPLODE function, which is just a placeholder. EXPLODE type is the
      underlying type of its argument for resolution purposes. During analysis
      Explode nodes will be replaced by Generate functions and a Generate node.
    - New Generate function, which is the non-placeholder version of EXPLODE
      and the one that goes into the final execution tree. This one returns
      the same type as its argument and let's the Generate plan node be the
      one that returns the underlying type once the values are generated.
    - Generate node, which wraps a Project in which there is one and only one
      explode expression.
    - resolve_generators analysis rule, which will turn projects with an
      Explode expression into a Generate node with the project as a children,
      replacing the Explode expressions with Generate expressions.
    - validate_explode_usage validation rule, which will ensure explode is
      not used outside a Project node.
    
    Signed-off-by: Miguel Molina <miguel@erizocosmi.co>
    erizocosmico committed Jun 3, 2019
    Configuration menu
    Copy the full SHA
    728f747 View commit details
    Browse the repository at this point in the history