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

   ### What changes were proposed in this pull request?
   1, Make function `count_min_sketch` accept number arguments;
   2, Make argument `seed` optional;
   3, fix the type hints of `eps/confidence/seed` from `ColumnOrName` to 
`Column`, because they require a foldable value and actually do not accept 
column reference:
   ```
   In [3]: from pyspark.sql import functions as sf
   
   In [4]: df = spark.range(10000).withColumn("seed", sf.lit(1).cast("int"))
   
   In [5]: df.select(sf.hex(sf.count_min_sketch("id", sf.lit(0.5), sf.lit(0.5), 
"seed")))
   ...
   AnalysisException: [DATATYPE_MISMATCH.NON_FOLDABLE_INPUT] Cannot resolve 
"count_min_sketch(id, 0.5, 0.5, seed)" due to data type mismatch: the input 
`seed` should be a foldable "INT" expression; however, got "seed". SQLSTATE: 
42K09;
   'Aggregate [unresolvedalias('hex(count_min_sketch(id#1L, 0.5, 0.5, seed#2, 
0, 0)))]
   +- Project [id#1L, cast(1 as int) AS seed#2]
      +- Range (0, 10000, step=1, splits=Some(12))
   ...
   ```
   
   
   ### Why are the changes needed?
   1, seed is optional in other similar functions;
   2,
   
   
   ### Does this PR introduce _any_ user-facing change?
   yes, it support number arguments
   
   ### How was this patch tested?
   updated doctests
   
   
   ### 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: [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