You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/02/17 12:08:50 UTC

[GitHub] [spark] zero323 commented on a change in pull request #27278: [SPARK-30569][SQL][PYSPARK][SPARKR] Add percentile_approx DSL functions.

zero323 commented on a change in pull request #27278: [SPARK-30569][SQL][PYSPARK][SPARKR] Add percentile_approx DSL functions.
URL: https://github.com/apache/spark/pull/27278#discussion_r380145375
 
 

 ##########
 File path: sql/core/src/main/scala/org/apache/spark/sql/functions.scala
 ##########
 @@ -652,6 +652,50 @@ object functions {
    */
   def min(columnName: String): Column = min(Column(columnName))
 
+  /**
+   * Aggregate function: Returns and array of the approximate percentile values
+   * of numeric column col at the given percentages.
+   *
+   * Each value of the percentage array must be between 0.0 and 1.0.
+   *
+   * The accuracy parameter is a positive numeric literal
+   * which controls approximation accuracy at the cost of memory.
+   * Higher value of accuracy yields better accuracy, 1.0/accuracy
+   * is the relative error of the approximation.
+   *
+   * @group agg_funcs
+   * @since 3.1.0
+   */
+  def percentile_approx(e: Column, percentage: Array[Double], accuracy: Long): Column = {
 
 Review comment:
   Huh... Usability aside, could you clarify one thing for me. Percentiles have to be provided, as a literal. Even assuming that prevailing attitude is "exception is good enough" when non literal is passed
   
   > AnalysisException: cannot resolve ... due to data type mismatch: The accuracy or percentage provided must be a constant literal;
   
   However, arguments that require SQL literals:
   
   - `ignoreNulls` in `first`
   - `ignoreNulls` in `last`
   - ` rsd`in `approx_count_distinct` 
   
   not to count different args in strict window functions are exclusively passed as external literals not `Columns`\*. So what is the rationale behind diverging here? What makes this case different? 
   
   It doesn't seem to be particularly verbose, two signatures are on the low side for overloaded functions with multiple arguments  and I don't see any reason to anticipate significant maintenance effort (docs or otherwise).
   
   I've seen some echos of discussions about growing size of `o.a.s.sql.functions`, but these were hardly convincing, at least in the diluted form they reached me.
   
   ---------------------------
   
   * In fact there are quite a few functions, where only external literal are passed, despite planner accepting any expression.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org