velox icon indicating copy to clipboard operation
velox copied to clipboard

Rewrite Presto function greatest/least using simple function interface

Open Yuhta opened this issue 2 years ago • 14 comments

Description

Use the Variadic Arguments feature we can reimplement greatest/least in Presto using simple function interface. Old code is at https://github.com/facebookincubator/velox/blob/main/velox/functions/prestosql/GreatestLeast.cpp.

Do not forget to add a benchmark to make sure no performance degradation.

Yuhta avatar Jan 17 '23 23:01 Yuhta

Hey @Yuhta,

Could you assign this issue to me?

Thanks, Tiago.

tiagokepe avatar Jan 19 '23 13:01 tiagokepe

@tiagokepe Sure it's yours now

Yuhta avatar Jan 19 '23 15:01 Yuhta

@Yuhta is this issue resolved or still going on ? I am newbie to opensource and I would love to contribute , But I don't find any , it would be much appreciated if you may please help me find something or assign me something .

SANTHOSH-MAMIDISETTI avatar Apr 26 '23 19:04 SANTHOSH-MAMIDISETTI

How can we register a simple function with DECIMAL type?

The problem is that since PR https://github.com/facebookincubator/velox/pull/4434 we do not have Long/ShortDecimal... ☹️

At the same time greatest/least have a variant for decimals:

signatures.emplace_back(exec::FunctionSignatureBuilder()
                            .integerVariable("precision")
                            .integerVariable("scale")
                            .returnType("DECIMAL(precision, scale)")
                            .argumentType("DECIMAL(precision, scale)")
                            .variableArity()
                            .build());

mslapek avatar May 13 '23 16:05 mslapek

@mslapek No, we cannot register a simple function with DECIMAL type. You have to write a Vector Function.

majetideepak avatar May 15 '23 03:05 majetideepak

@mslapek Simple Function API now supports decimal types.

mbasmanova avatar Mar 25 '24 15:03 mbasmanova

Hi, I am currently working on this issue if nobody is. It seems like this issue can be resolved after Simple Function API supports decimal types. Expected to give an update in one to two weeks.

Real-Chen-Happy avatar Mar 29 '24 05:03 Real-Chen-Happy

@Real-Chen-Happy For reference, decimal type support was added in https://github.com/facebookincubator/velox/pull/9096

mbasmanova avatar Mar 29 '24 09:03 mbasmanova

Thank you! I just finished coding and all the existing test cases are passing. Before creating PR, may I know how to add a benchmark? I want to double check there is no performance degradation.

Real-Chen-Happy avatar Mar 29 '24 10:03 Real-Chen-Happy

@Real-Chen-Happy Sounds like you are making great progress. Check out velox/functions/prestosql/benchmarks/ArraySumBenchmark.cpp for an example of a benchmark and look at ExpressionBenchmarkBuilder as well as search the codebase for other usages of ExpressionBenchmarkBuilder.

mbasmanova avatar Mar 29 '24 10:03 mbasmanova

Got it! Are we expected to run benchmark on our local computer and compare the performance or it should be on some standard cloud instances?

Real-Chen-Happy avatar Mar 29 '24 10:03 Real-Chen-Happy

@Real-Chen-Happy For this change, I think running benchmarks is not necessary. When it is needed, we currently run on local computers of whatever hardware is available. It would be nice to standardize this a bit though.

mbasmanova avatar Mar 29 '24 10:03 mbasmanova

Makes sense! Thank you!

Real-Chen-Happy avatar Mar 29 '24 11:03 Real-Chen-Happy

Hi, PR is out https://github.com/facebookincubator/velox/pull/9308 Can somebody help review? Thank you!

Real-Chen-Happy avatar Mar 29 '24 21:03 Real-Chen-Happy

@mbasmanova cc @s4ayub It seems like the simple function implementations are breaking existing internal UDF registration https://github.com/facebookincubator/velox/pull/9493 . May I know what are the issues and if there is anything I can fix on my end?

Real-Chen-Happy avatar Apr 16 '24 22:04 Real-Chen-Happy

Hi @Real-Chen-Happy , thank you for checking in. The internal issue was caused due to the switch to using Simple function interface instead of vector function. This changed the registration path that the internal product employed and caused unexpected behavior affecting production workloads. Therefore it was promptly rolled back. However, since the issue is isolated to the internal product and nothing needs to be rectified on velox, we will re-introduce the original velox change once it has been fixed internally which should be a couple of days at max.

bikramSingh91 avatar Apr 22 '24 18:04 bikramSingh91