You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by "zhengruifeng (via GitHub)" <gi...@apache.org> on 2023/10/27 11:33:15 UTC

[PR] [SPARK-45707][SQL] Simplify `DataFrameStatFunctions. countMinSketch` with `CountMinSketchAgg` [spark]

zhengruifeng opened a new pull request, #43560:
URL: https://github.com/apache/spark/pull/43560

   ### What changes were proposed in this pull request?
   Simplify `DataFrameStatFunctions. countMinSketch` with `CountMinSketchAgg`
   
   
   ### Why are the changes needed?
   to make it consistent with sql functions
   
   
   ### Does this PR introduce _any_ user-facing change?
   
   better error messages: `IllegalArgumentException` -> `AnalysisException`
   
   
   ### How was this patch tested?
   ci
   
   ### Was this patch authored or co-authored using generative AI tooling?
   no
   


-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on code in PR #43560:
URL: https://github.com/apache/spark/pull/43560#discussion_r1374467471


##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala:
##########
@@ -483,7 +482,9 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {
    * @since 2.0.0
    */
   def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {
-    countMinSketch(col, CountMinSketch.create(depth, width, seed))
+    val eps = 2.0 / width
+    val confidence = 1 - 1 / Math.pow(2, depth)

Review Comment:
   Why need the two? `eps = 2.0 / width` and `confidence = 1 - 1 / Math.pow(2, depth)`?



-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "beliefer (via GitHub)" <gi...@apache.org>.
beliefer commented on code in PR #43560:
URL: https://github.com/apache/spark/pull/43560#discussion_r1375584740


##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala:
##########
@@ -483,7 +482,9 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {
    * @since 2.0.0
    */
   def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {
-    countMinSketch(col, CountMinSketch.create(depth, width, seed))
+    val eps = 2.0 / width
+    val confidence = 1 - 1 / Math.pow(2, depth)

Review Comment:
   I got 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


Re: [PR] [SPARK-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #43560:
URL: https://github.com/apache/spark/pull/43560#discussion_r1375571116


##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala:
##########
@@ -483,7 +482,9 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {
    * @since 2.0.0
    */
   def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {
-    countMinSketch(col, CountMinSketch.create(depth, width, seed))
+    val eps = 2.0 / width
+    val confidence = 1 - 1 / Math.pow(2, depth)

Review Comment:
   this is used to convert `depth & width` to `eps & confidence`
   
   https://github.com/apache/spark/blob/b0576fff9b72880cd81a9d22c044dec329bc67d0/common/sketch/src/main/java/org/apache/spark/util/sketch/CountMinSketchImpl.java#L44-L45



-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #43560:
URL: https://github.com/apache/spark/pull/43560#discussion_r1375570887


##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala:
##########
@@ -483,7 +482,9 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {
    * @since 2.0.0
    */
   def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {
-    countMinSketch(col, CountMinSketch.create(depth, width, seed))
+    val eps = 2.0 / width
+    val confidence = 1 - 1 / Math.pow(2, depth)

Review Comment:
   ? what do you mean?
   
   



-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "dongjoon-hyun (via GitHub)" <gi...@apache.org>.
dongjoon-hyun closed pull request #43560: [SPARK-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg`
URL: https://github.com/apache/spark/pull/43560


-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on code in PR #43560:
URL: https://github.com/apache/spark/pull/43560#discussion_r1375571333


##########
sql/core/src/main/scala/org/apache/spark/sql/DataFrameStatFunctions.scala:
##########
@@ -483,7 +482,9 @@ final class DataFrameStatFunctions private[sql](df: DataFrame) {
    * @since 2.0.0
    */
   def countMinSketch(col: Column, depth: Int, width: Int, seed: Int): CountMinSketch = {
-    countMinSketch(col, CountMinSketch.create(depth, width, seed))
+    val eps = 2.0 / width
+    val confidence = 1 - 1 / Math.pow(2, depth)

Review Comment:
   `CountMinSketchAgg` doesn't have a constructor with `depth & width` 



-- 
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-45707][SQL] Simplify `DataFrameStatFunctions.countMinSketch` with `CountMinSketchAgg` [spark]

Posted by "zhengruifeng (via GitHub)" <gi...@apache.org>.
zhengruifeng commented on PR #43560:
URL: https://github.com/apache/spark/pull/43560#issuecomment-1784546683

   thanks @beliefer @dongjoon-hyun @HyukjinKwon for reviews


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