Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 360896

Summary: Update SQL Query Model to add lateral table query
Product: [Tools] Data Tools Reporter: Brian Payton <bpayton>
Component: SQL Query ModelAssignee: Brian Payton <bpayton>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: P3    
Version: 1.9.1   
Target Milestone: 1.9.2   
Hardware: PC   
OS: Windows XP   
Whiteboard:

Description Brian Payton CLA 2011-10-13 18:37:06 EDT
Need to update the SQL Query Model to add support for the "lateral derived table" SQL element.  In ISO SQL terms, it's a form of table reference.  Namely:

<table reference> ::=
    <table factor>
  | <joined table>

<table factor> ::=
    <table primary> 

<table primary> ::=
    <table or query name> ...
  | <derived table> ...
  | <lateral derived table> ...
    ...

<lateral derived table> ::=
  LATERAL <table subquery>

Here's an example:

  SELECT d.dept_name, e.emp_name
    FROM 
      dept d, 
      LATERAL ( SELECT emp_id, emp_name
        FROM emp
        WHERE emp_dept = d.dept_id ) e

The difference the LATERAL keyword makes is that the subquery definition following the LATERAL keyword is allowed to refer to tables defined ahead of it in the same FROM clause.  A regular subquery can only refer to tables defined at a higher level in the query.

So in this example the subquery "e" can refer to the dept table "d" in its definition where otherwise that would be an invalid reference.
Comment 2 Brian Payton CLA 2011-10-17 01:39:10 EDT
Marking as fixed...
Comment 3 Brian Payton CLA 2011-11-23 13:25:05 EST
Hmm, let me try that again...