apache / incubator-gluten

Gluten is a middle layer responsible for offloading JVM-based SQL engines' execution to native engines.
https://gluten.apache.org/
Apache License 2.0
1.19k stars 433 forks source link

[VL] add div function #5574

Open guixiaowen opened 6 months ago

guixiaowen commented 6 months ago

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

guixiaowen commented 5 months ago

@PHILO-HE PH hi, Can you help me check if the direction of the issuse I mentioned is correct.

guixiaowen commented 5 months ago

@Yohahaha yo hi, Can you help me check if the direction of the issuse I mentioned is correct.

Yohahaha commented 5 months ago

@Yohahaha yo hi, Can you help me check if the direction of the issuse I mentioned is correct.

yeah, IntegralDivide for Long type is missed, you can verify it with an UT.

guixiaowen commented 5 months ago

@Yohahaha yo hi, Can you help me check if the direction of the issuse I mentioned is correct.

yeah, IntegralDivide for Long type is missed, you can verify it with an UT.

@Yohahaha 3q.

PHILO-HE commented 5 months ago

@guixiaowen, the proposal looks good! Just left some comments on the velox PR. Thanks!

guixiaowen commented 5 months ago

@guixiaowen, the proposal looks good! Just left some comments on the velox PR. Thanks!

OK. Thanks.