[
https://issues.apache.org/jira/browse/DERBY-4495?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Knut Anders Hatlen updated DERBY-4495:
--------------------------------------
Attachment: derby-4495-1a.diff
derby-4495-1a.stat
The NPE when combining join operators was caused by JoinNode's late
building of the RCL (it's not done in bindExpressions(), but in
deferredBindExpressions()). However, the column names are available if
you call getAllResultColumns(null) instead of getResultColumns(), so
the solution to that problem was straightforward.
I'm uploading a new patch (derby-4495-1a.diff) with that change, as
well as more comments and tests. All the regression tests ran cleanly,
so the patch is ready for review.
Here's a description of the changes in the patch:
JoinNode.java:
- Added a flag for natural join.
- In the bind phase, generate a USING clause containing all the common
columns in the natural join.
- In the code that transforms USING to ON (deferredBindExpressions),
remove the implicit assumption that USING clauses contain at least
one column name (the USING syntax requires at least one column, but
natural joins between tables with no common columns can make us
generate empty USING clauses internally, breaking that assumption)
sqlgrammar.jj:
- Factored out existing code to generate a new join node to avoid
having to duplicate that code for natural join.
- Added new rule naturalJoin and wired it into joinedTableExpression.
JoinTest.java:
- Added test cases for the new syntax. I've verified that the results
are the same as with PostgreSQL (with the exception of the
statements that use asterisked identifier chains - see discussion on
DERBY-4370). There's always room for more tests. Suggestions are
welcome.
> Add NATURAL JOIN syntax
> -----------------------
>
> Key: DERBY-4495
> URL: https://issues.apache.org/jira/browse/DERBY-4495
> Project: Derby
> Issue Type: Improvement
> Components: SQL
> Affects Versions: 10.6.0.0
> Reporter: Knut Anders Hatlen
> Assignee: Knut Anders Hatlen
> Priority: Minor
> Attachments: derby-4495-1a.diff, derby-4495-1a.stat,
> natural_preview.diff, natural_preview_v2.diff
>
>
> It would be nice if Derby supported the NATURAL JOIN syntax (feature F401-01
> in SQL:2003).
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.