You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "yyanyy (via GitHub)" <gi...@apache.org> on 2026/02/18 02:17:32 UTC
[PR] [SPARK-51695][SQL][DOCS][FOLLOW-UP] Clarify NULL handling semantics in UNIQUE constraint Javadoc [spark]
yyanyy opened a new pull request, #54357:
URL: https://github.com/apache/spark/pull/54357
### What changes were proposed in this pull request?
Document NULLS DISTINCT behavior: NULL values are treated as distinct from each other, so rows with NULLs in unique columns never conflict. Also note that UNIQUE allows nullable columns (unlike PRIMARY KEY) and that NULLS NOT DISTINCT is not currently supported.
### Why are the changes needed?
Better javadoc clarity on UNIQUE constraint expectation.
### Does this PR introduce _any_ user-facing change?
No
### How was this patch tested?
N/A
### Was this patch authored or co-authored using generative AI tooling?
Co-Authored-By: Claude Opus 4.6 <no...@anthropic.com>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51695][SQL][DOCS][FOLLOW-UP] Clarify NULL handling semantics in UNIQUE constraint Javadoc [spark]
Posted by "gengliangwang (via GitHub)" <gi...@apache.org>.
gengliangwang commented on code in PR #54357:
URL: https://github.com/apache/spark/pull/54357#discussion_r2824805149
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/constraints/Unique.java:
##########
@@ -28,6 +28,15 @@
* <p>
* A UNIQUE constraint specifies one or more columns as unique columns. Such constraint is satisfied
* if and only if no two rows in a table have the same non-null values in the unique columns.
+ * Unlike PRIMARY KEY, UNIQUE allows nullable columns.
+ * <p>
+ * NULL values are treated as distinct from each other (NULLS DISTINCT semantics). Two rows
Review Comment:
We don’t need to define the suggested behavior in Spark itself. The behavior can be left to the connector implementations.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
Re: [PR] [SPARK-51695][SQL][DOCS][FOLLOW-UP] Clarify NULL handling semantics in UNIQUE constraint Javadoc [spark]
Posted by "holdenk (via GitHub)" <gi...@apache.org>.
holdenk commented on code in PR #54357:
URL: https://github.com/apache/spark/pull/54357#discussion_r2842873005
##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/catalog/constraints/Unique.java:
##########
@@ -28,6 +28,15 @@
* <p>
* A UNIQUE constraint specifies one or more columns as unique columns. Such constraint is satisfied
* if and only if no two rows in a table have the same non-null values in the unique columns.
+ * Unlike PRIMARY KEY, UNIQUE allows nullable columns.
+ * <p>
+ * NULL values are treated as distinct from each other (NULLS DISTINCT semantics). Two rows
Review Comment:
On the flipside if the connectors are different then querying the same data from two different backends could result in different results which might be confusing. Although I doubt the backends are going to care about our constraint spec here (although the connectors, hopefully, if they can't follow it would drop it).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org