[
https://issues.apache.org/jira/browse/CALCITE-4486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17402703#comment-17402703
]
Julian Hyde commented on CALCITE-4486:
--------------------------------------
Nice work.
* Add a method {{SqlToRelConverterTest.Sql.throws_}} similar to that in
CalciteAssert, and use it In {{testUniqueWithExpand}}.
* In "select*from" in various tests, add space around "*".
* Add space after "," in various comments.
* In reference.md "Whether *sub-query* returns row is unique" is not
grammatical
* You could remove some or all of the tests in JdbcTest if they are covered by
those in misc.iq
* Move the tests in misc.iq to sub-query.iq - it's a more appropriate place
* Are there any tests where null values are involved? I believe that null is
treated like other values - i.e. \{null, 1} is unique, \{null, null, 1} is not
unique. But we should have tests.
* In the javadoc for {{rewriteUnique}}, move param and return down. The code
examples need to be enclosed in {{<pre>\{\@code ...}</pre>}}
* In {{rewriteUnique}}, use {{relBuilder.call}} rather than
{{relBuilder.getRexBuilder().makeCall}}. There are also methods such as
{{RelBuilder.isNotNull}}
* No need to follow {{relBuilder.build}} by {{relBuilder.push}}
* No need to create {{filterCondition}}. {{RelBuilder.filter}} accepts a list,
which it ANDs together.
* No need to add TRUE to {{notNullCondition}}
* {{isAlwaysUniqueSubquery}} should work in terms of Sort, Aggregate etc.
rather than LogicalSort, LogicalAggregate etc.
* Rename isAlwaysUniqueSubquery to isAlwaysUniqueSubQuery, and change
"subquery" to "sub-query" in comments
* Could you replace {{isAlwaysUniqueSubquery}} with
{{RelMetadataQuery.areRowsUnique}} or similar? Add tests to {{RelMetadataTest}}
to make sure that the cases you need are covered.
> UNIQUE predicate
> ----------------
>
> Key: CALCITE-4486
> URL: https://issues.apache.org/jira/browse/CALCITE-4486
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: duan xiong
> Priority: Major
>
> Implement the UNIQUE predicate, as specified by the SQL standard.
> Example:
> {code:java}
> UNIQUE (SELECT publishedIn FROM Book
> WHERE authorId = 3)
> NOT UNIQUE (SELECT publishedIn FROM BOOK
> WHERE authorId = 3)
> {code}
> {{UNIQUE}} returns {{FALSE}} if the query returns two or more rows that do
> not include NULL values and are equal. Like {{EXISTS}}, it never returns
> {{UNKNOWN}}.
> More details at
> [JOOQ|https://www.jooq.org/doc/3.0/manual/sql-building/conditional-expressions/unique-predicate/].
> This Issue support the UNIQUE predicate by set {{isExpand}} to return false,
> so sub-queries are converted to {{RexSubQuery}} expressions and handled later
> by {{SubQueryRemoveRule}}.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)