calcite-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jark Wu (JIRA)" <>
Subject [jira] [Created] (CALCITE-1472) Support CROSS/OUTER APPLY syntax
Date Thu, 27 Oct 2016 07:28:58 GMT
Jark Wu created CALCITE-1472:

             Summary: Support CROSS/OUTER APPLY syntax
                 Key: CALCITE-1472
             Project: Calcite
          Issue Type: New Feature
            Reporter: Jark Wu
            Assignee: Julian Hyde

The CROSS/OUTER APPLY is very similar to CROSS JOIN and OUTER JOIN.  The difference is that
the APPLY operator is used to invoke a table-valued function. This is not a standard SQL syntax
, but introduced from MS SQL Server [1]. 

The APPLY operator can be expressed by Calciteā€™s LATERAL TABLE . That means the 

SELECT MyTable.*, t.s FROM MyTable CROSS APPLY split(MyTable.a)) AS t(s)

corresponds to :

SELECT MyTable.*, t.s FROM MyTable, LATERAL TABLE(split(MyTable.a)) AS t(s)


SELECT MyTable.*, t.s FROM MyTable OUTER APPLY split(MyTable.a)) AS t(s)

corresponds to:

SELECT MyTable.*, t.s FROM MyTable LEFT JOIN LATERAL TABLE(split(MyTable.a)) AS t(s)  ON TRUE

The ON TRUE part is necessary for LEFT JOIN, but it's trivial for users. That's why I'm introducing
"CROSS/OUTER APPLY" which will simplify the SQL a lot.

As the APPLY can be expressed by LATERAL, so the only thing we need to touch is the Parser
(see [2] and search FLINK to find the modification).  


This message was sent by Atlassian JIRA

View raw message