datafuselabs / databend

𝗗𝗮𝘁𝗮, 𝗔𝗻𝗮𝗹𝘆𝘁𝗶𝗰𝘀 & 𝗔𝗜. Modern alternative to Snowflake. Cost-effective and simple for massive-scale analytics. https://databend.com
https://docs.databend.com
Other
7.31k stars 704 forks source link

[functions] more functions working with number #2563

Closed sundy-li closed 1 year ago

sundy-li commented 2 years ago

Summary

From MySQL docs in https://dev.mysql.com/doc/refman/8.0/en/numeric-functions.html

Tasks list:

If you are interested in one or more tasks in this issue, you can comment like: /assignme abs functions to make this subtask assigned to you, then I'll mark that as wip.

flaneur2020 commented 2 years ago

/assignme abs function

flaneur2020 commented 2 years ago

/assignme ABS() Return the absolute value

flaneur2020 commented 2 years ago
you can comment like: /assignme abs functions to make this subtask assigned to you.

hmm, i tried /assignme abs functions but it assigned this issue to me but not the subtask, is this behaviour as expected?

BohuTANG commented 2 years ago
you can comment like: /assignme abs functions to make this subtask assigned to you.

hmm, i tried /assignme abs functions but it assigned this issue to me but not the subtask, is this behaviour as expected?

I guess it's OK, @sundy-li will maintain this issue :)

junnplus commented 2 years ago

PI() Return the value of pi

take this

PsiACE commented 2 years ago

/assignme rand() function

junnplus commented 2 years ago

/assignme sin() cos() cot() tan() function

flaneur2020 commented 2 years ago

/assignme LOG(), LOG10(), LOG2()

junnplus commented 2 years ago

/assignme crc32()

junnplus commented 2 years ago

/assignme DEGREES() RADIANS()

junnplus commented 2 years ago

/assignme ACOS() ASIN() ATAN() ATAN2()

kyon0304 commented 2 years ago

/assignme CEIL() CEILING() FLOOR()

mshauneu commented 2 years ago

/assignme sign() function

mshauneu commented 2 years ago

/assignme ROUND() Round the argument

junnplus commented 2 years ago

/assignme POW() POWER()

mshauneu commented 2 years ago

/assignme TRUNCATE() Truncate to specified number of decimal places

mshauneu commented 2 years ago

/assignme DIV Integer division

junnplus commented 2 years ago

hi @sundy-li , Can you update the issue? CONV DIV RAND is wip, others have been completed.

PsiACE commented 2 years ago

/assignme rand() function

I need to unassign this task for now. Sorry I should manage my task list more sensibly.

also, @Junnplus would you be interested in taking it?

mshauneu commented 2 years ago

/assignme rand() function

mshauneu commented 2 years ago

@PsiACE @sundy-li I am working on DIV operator. To finish it I need a help:

mysql -h0.0.0.0 -P3307 -uroot -e 'SELECT 1 / 0' +---------+ | (1 / 0) | +---------+ | inf | +---------+


That complicate 'SELECT 1 DIV 0' case much.

I can share my code without support of SELECT 1 DIV 0 for now...with hope databend change `/ 0` in nearest feature.
sundy-li commented 2 years ago

@mshauneu we can have a new function named intDiv and map the div operator into this function.

For MySQL return NULL if divided by zero, it's related to config ERROR_FOR_DIVISION_BY_ZERO in MySQL. This config will not be introduced in databend, it's too complicated.

I think it is ok to output inf, because 3/0 = 3.0f64/0.0f64 = f64::INFINITY. Some design of MySQL is poor, no need to be compatible with that.

Xuanwo commented 1 year ago

@soyeric128 Please take a look at this issue.

sundy-li commented 1 year ago

@soyeric128 Please take a look at this issue.

We will use other issues to track the doc.