apache / apache/gluten

[VL] add div function

Open
#5,574 6 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Scala
Stars
1.6k
Forks
657
Avg merge
2d 14h
Merged PRs (30d)
80

Description

### Description

div function
expr1 div expr2 - Divide expr1 by expr2. It returns NULL if an operand is NULL or expr2 is 0. The result is casted to long.

Examples:

`
SELECT 3 div 2;
SELECT INTERVAL '1-1' YEAR TO MONTH div INTERVAL '-1' MONTH;
-13

`

**In Spark, the implementation class of div is: IntegralDivide.**

In 3.2.x, supports two types of div:

div(long, long) , return long result

div(decimal, decimal), return long result

After 3.3.x, add new type:

div(YearMonthIntervalType, YearMonthIntervalType), return long result

div(DayTimeIntervalType, DayTimeIntervalType), return long result

**In velox, the currently supported DIV scenarios are:**

divide(x, y) → double

divide(x, y) → decimal

//TODO:
To support div, add velox udf function.

divide(x, y) → long
div(long, long) , return long result
Pr:
https://github.com/facebookincubator/velox/pull/9621

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.