spark-test commented on code in PR #60168:
URL: https://github.com/apache/spark/pull/60168#discussion_r4500569097


##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/ValueInterval.scala:
##########
@@ -62,12 +62,13 @@ object ValueInterval {
   }
 
   def isIntersected(r1: ValueInterval, r2: ValueInterval): Boolean = (r1, r2) 
match {
-    case (_, _: DefaultValueInterval) | (_: DefaultValueInterval, _) =>
-      // The DefaultValueInterval represents string/binary types which do not 
have max/min stats,
-      // we assume they are intersected to be conservative on estimation
-      true
     case (_, _: NullValueInterval) | (_: NullValueInterval, _) =>
+      // Null values intersect no interval, even one whose range is unknown
       false
+    case (_, _: DefaultValueInterval) | (_: DefaultValueInterval, _) =>
+      // The DefaultValueInterval has an unknown range, e.g. for string/binary 
types which do not

Review Comment:
   **Nit (P3):** This comment now describes `DefaultValueInterval` as an 
unknown range in general, and `keyInterval` also returns it for non-string join 
keys that have distinct values but no min/max. Two other comments in this file 
still describe it only as the string/binary interval: the class doc ("This 
version of Spark does not have min/max for binary/string types, we define their 
default behaviors by this class.") and the `intersect` arm ("binary/string 
types don't support intersecting."). A later change could add string-specific 
handling there that would silently also apply to numeric, boolean or date keys 
without min/max. Could you reword both to cover either case (string/binary 
types, or a key whose stats have distinct values but no min/max), without 
extending it to a column that holds only nulls?
   
   See **Shared repair plan 1** in the review body.



##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/plans/logical/statsEstimation/JoinEstimation.scala:
##########
@@ -223,6 +224,19 @@ case class JoinEstimation(join: Join) extends Logging {
     (joinCard, AttributeMap(keyStatsAfterJoin))
   }
 
+  /**
+   * Returns the value range of a join key. A key with distinct values but no 
min/max (a data
+   * source may not report them, and a union drops them for some types) has an 
unknown range, not
+   * only nulls. Like a string key, it is assumed to overlap the other key.

Review Comment:
   **Nit (P3):** Because `isIntersected` now rejects a `NullValueInterval` 
first, a key with an unknown range does not overlap the other key when that key 
holds only nulls. The new test "a join key holding only nulls matches no key 
without min/max" asserts 0 rows for that case. The comparison with string keys 
breaks there too: two string keys always overlap, even when one holds only 
nulls, because both map to `DefaultValueInterval`. A qualifier such as "unless 
the other key holds only nulls" would make the sentence accurate.
   
   See **Shared repair plan 1** in the review body.



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to