[ 
https://issues.apache.org/jira/browse/CALCITE-4486?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17403191#comment-17403191
 ] 

duan xiong commented on CALCITE-4486:
-------------------------------------

In the ISO/IEC 9075-2:2016(E), Partie 2: Fondations (SQL/Fondations) describe 
the _UNIQUE:_
 * If there are no two rows in _T_ such that the value of each column in one 
row is non-null and is not distinct from the value of the corresponding column 
in the other row, then the result of the <unique predicate> is _True_; 
otherwise, the result of the <unique predicate> is _False._

Other resources link: 
[UNIQUE|https://www.dummies.com/programming/sql/how-to-use-exists-unique-distinct-and-overlaps-in-sql-statements]
  [UNIQUE|https://www.geeksforgeeks.org/sql-unique-constraint] 
[UNIQUE|https://www.red-gate.com/simple-talk/sql/t-sql-programming/predicates-with-subqueries]
 .

So I think we should add notNullCondition.

> 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)

Reply via email to