[jira] [Commented] (CALCITE-6077) Add FACTORIAL functions (enabled in Hive and Spark library)

2023-10-26 Thread Runkang He (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780133#comment-17780133
 ] 

Runkang He commented on CALCITE-6077:
-

[~julianhyde] thanks for the advice. The combinations and permutations have a 
wider range of use, but currently there are no such functions after I checked 
the main dialects includes MySQL/PostgreSQL/Oracle/BigQuery/Spark/Hive.

> Add FACTORIAL functions (enabled in Hive and Spark library)
> ---
>
> Key: CALCITE-6077
> URL: https://issues.apache.org/jira/browse/CALCITE-6077
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Runkang He
>Assignee: Runkang He
>Priority: Major
>
> Add FACTORIAL functions (enabled in Hive and Spark library)
> FACTORIAL(expr): Returns the factorial of expr. expr is [0..20]. Otherwise, 
> returns NULL.
> For example:
> {code:sql}
> SELECT factorial(5); 
> >120
> {code}
> See more at 
> [Hive|https://cwiki.apache.org/confluence/display/hive/languagemanual+udf#LanguageManualUDF-MathematicalFunctions]
>  and 
> [Spark|https://spark.apache.org/docs/latest/api/sql/index.html#factorial] doc.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6077) Add FACTORIAL functions (enabled in Hive and Spark library)

2023-10-26 Thread Julian Hyde (Jira)


[ 
https://issues.apache.org/jira/browse/CALCITE-6077?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780045#comment-17780045
 ] 

Julian Hyde commented on CALCITE-6077:
--

Do these dialects have functions for combinations and permutations?
{quote}
p(n, r) = n! / (n - r)!
c(n, r) = n! / (r! . (n - r)!)
{quote}

These are related to factorial but are more useful because, by dividing 
factorials by factorials, they tend to stay in a useful range of values. 

> Add FACTORIAL functions (enabled in Hive and Spark library)
> ---
>
> Key: CALCITE-6077
> URL: https://issues.apache.org/jira/browse/CALCITE-6077
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Affects Versions: 1.35.0
>Reporter: Runkang He
>Assignee: Runkang He
>Priority: Major
>
> Add FACTORIAL functions (enabled in Hive and Spark library)
> FACTORIAL(expr): Returns the factorial of expr. expr is [0..20]. Otherwise, 
> returns NULL.
> For example:
> {code:sql}
> SELECT factorial(5); 
> >120
> {code}
> See more at 
> [Hive|https://cwiki.apache.org/confluence/display/hive/languagemanual+udf#LanguageManualUDF-MathematicalFunctions]
>  and 
> [Spark|https://spark.apache.org/docs/latest/api/sql/index.html#factorial] doc.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)