Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Presto function greatest/least using simple function interface #3728

Closed
Yuhta opened this issue Jan 17, 2023 · 16 comments
Closed

Rewrite Presto function greatest/least using simple function interface #3728

Yuhta opened this issue Jan 17, 2023 · 16 comments
Assignees
Labels
enhancement New feature or request function good first issue Good for newcomers

Comments

@Yuhta
Copy link
Contributor

Yuhta commented Jan 17, 2023

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 Yuhta added enhancement New feature or request good first issue Good for newcomers function labels Jan 17, 2023
@tiagokepe
Copy link

Hey @Yuhta,

Could you assign this issue to me?

Thanks,
Tiago.

@Yuhta
Copy link
Contributor Author

Yuhta commented Jan 19, 2023

@tiagokepe Sure it's yours now

@SANTHOSH-MAMIDISETTI
Copy link

@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 .

@mslapek
Copy link

mslapek commented May 13, 2023

How can we register a simple function with DECIMAL type?

The problem is that since PR #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());

@majetideepak
Copy link
Collaborator

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

@mbasmanova
Copy link
Contributor

@mslapek Simple Function API now supports decimal types.

@Real-Chen-Happy
Copy link
Contributor

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.

@mbasmanova
Copy link
Contributor

@Real-Chen-Happy For reference, decimal type support was added in #9096

@Real-Chen-Happy
Copy link
Contributor

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.

@mbasmanova
Copy link
Contributor

@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.

@Real-Chen-Happy
Copy link
Contributor

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?

@mbasmanova
Copy link
Contributor

@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.

@Real-Chen-Happy
Copy link
Contributor

Makes sense! Thank you!

@Real-Chen-Happy
Copy link
Contributor

Hi, PR is out #9308
Can somebody help review? Thank you!

@Real-Chen-Happy
Copy link
Contributor

Real-Chen-Happy commented Apr 16, 2024

@mbasmanova cc @s4ayub It seems like the simple function implementations are breaking existing internal UDF registration #9493 . May I know what are the issues and if there is anything I can fix on my end?

@bikramSingh91
Copy link
Contributor

bikramSingh91 commented Apr 22, 2024

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.

Joe-Abraham pushed a commit to Joe-Abraham/velox that referenced this issue Jun 7, 2024
facebookincubator#9308)

Summary:
Refactor the greatest/least functions using simple function API.

Also, add support for NaN comparisons for DOUBLE and REAL. NaN is the biggest according to prestodb/presto#22391

Fixes facebookincubator#3728

Pull Request resolved: facebookincubator#9308

Reviewed By: xiaoxmeng

Differential Revision: D55793910

Pulled By: mbasmanova

fbshipit-source-id: c389bad91197f00ced549d816a15efab5a2dd910
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request function good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants