[ https://issues.apache.org/jira/browse/CASSANDRA-17221?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17511141#comment-17511141 ]
Benjamin Lerer commented on CASSANDRA-17221: -------------------------------------------- [~xvade] Looking more deeply at the patch, I realized that there is one important part that I forgot to mention. The current apporach used by Cassandra for aggregation functions or arithmetic operators is to return the same type as the the input type. In case the user want a different type he should use CAST to modify the input type. Progresql use the same approach for its [Math functions|https://www.postgresql.org/docs/9.5/functions-math.html]. Therefore the patch should be modified to follow that pattern. Regarding the [BigDecimalUtil|https://github.com/xvade/cassandra/blob/249bbef8b5d818a2d876df097afd3003efd38659/src/java/org/apache/cassandra/utils/BigDecimalUtil.java#L25] class. I am not sure that the Apache rules allow us to use that code. [~mck] what is your opinion? If we cannot use it. I am fine with us not providing the functions for the {{numeric}} and {{varint}} type. > Add Math functions > ------------------- > > Key: CASSANDRA-17221 > URL: https://issues.apache.org/jira/browse/CASSANDRA-17221 > Project: Cassandra > Issue Type: Improvement > Components: CQL/Syntax > Reporter: Benjamin Lerer > Assignee: Simon Chess > Priority: Normal > Labels: AdventCalendar2021, lhf > Fix For: 4.x > > > We should add native Maths functions for the most common operations: > * {{abs\(x)}} returns the absolute value of the x > * {{exp\(x)}} returns the value of e (the base of natural logarithms) raised > to the power of x > * {{log\(x)}} returns the natural logarithm (base e) of x > * {{log10\(x)}} returns the base-10 logarithm of x > * {{round\(x)}} returns the closest integer to x > +Additional information for newcomers:+ > The new functions should be put in a new class {{MathFcts}} similar to > {{TimeFcts}}. > The {{MathsFcts.all()}} method should be called in > {{SystemKeyspace.functions}} > The unit tests for the functions should be put in a {{MathFctsTest}} similar > to {{TimeFctsTest}} -- This message was sent by Atlassian Jira (v8.20.1#820001) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org