[ 
https://issues.apache.org/jira/browse/DERBY-4355?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Knut Anders Hatlen updated DERBY-4355:
--------------------------------------

    Attachment: cross_v2.diff

Attaching cross_v2.diff with updates to make it apply after DERBY-4369. It also 
adds a test cases to JoinTest. I'm assuming that the underlying join machinery 
is tested by the existing tests, so the new test cases focus on checking that 
the syntax is accepted. They do check that the results are correct, but they 
don't do all sorts of combinations with different data types, nullability, 
indexes and so on.

One problem that I found, was that this query is not accepted (it's commented 
out in the test for now):

  select * from t1 a inner join t2 b cross join t2 c on 1=1

This results in an SQLSyntaxErrorException: A join specification is not allowed 
with the 'CROSS JOIN' clause.

It works if parentheses are added, like this:

  select * from t1 a inner join (t2 b cross join t2 c) on 1=1

However, I do believe that it should be accepted without parentheses too. The 
problem is that the patch adds CROSS JOIN in the parser's qualifiedJoin rule, 
where an ON clause right after any kind of join will be consumed. The parser 
therefore incorrectly believes that the ON clause is part of the cross join and 
raises an error. Splitting out a separate rule for cross join (which is also 
how it is defined in the SQL standard) will prevent the ON clause from being 
seen when parsing the the cross join, and it will be seen as part of the inner 
join instead. I will post an updated patch with this issue fixed.

> Implement CROSS JOIN
> --------------------
>
>                 Key: DERBY-4355
>                 URL: https://issues.apache.org/jira/browse/DERBY-4355
>             Project: Derby
>          Issue Type: Improvement
>          Components: SQL
>         Environment: any
>            Reporter: Bernt M. Johnsen
>            Assignee: Knut Anders Hatlen
>         Attachments: cross.diff, cross_v2.diff
>
>
> Implement the CROSS JOIN syntax
> SELECT * from t1 CROSS JOIN t2;
> as an alternative syntax to
> SELECT * FROM t1, t2; 
> This should be pretty straight forward and ease the migration of SQL code to 
> Derby.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to