Skip to content

Conversation

abhinavmuk04
Copy link
Contributor

@abhinavmuk04 abhinavmuk04 commented Aug 13, 2025

Description

Add performance warning for MAP_FILTER

Motivation and Context

Partly due to the lack of builtins and partly due to not being familiar, users use lambdas on training tables. We should add a performance warning in the presto analyzer things like MAP_FILTER.

Impact

This will help improve user understanding, as well as prevent issues with performance

Test Plan

Units tests, looking for warnings. Amended tests ensuring new behavior is updated. Removed one obsolete test case

Contributor checklist

  • Please make sure your submission complies with our contributing guide, in particular code style and commit standards.
  • PR description addresses the issue accurately and concisely. If the change is non-trivial, a GitHub Issue is referenced.
  • Documented new properties (with its default value), SQL syntax, functions, or other functionality.
  • If release notes are required, they follow the release notes guidelines.
  • Adequate tests were added if applicable.
  • CI passed.
== NO RELEASE NOTE ==

@abhinavmuk04 abhinavmuk04 force-pushed the lambdawarnings branch 6 times, most recently from 4b18f30 to d8e1fff Compare August 13, 2025 22:56
@abhinavmuk04 abhinavmuk04 requested a review from kaikalur August 14, 2025 14:41
@abhinavmuk04 abhinavmuk04 marked this pull request as ready for review August 14, 2025 16:13
kaikalur
kaikalur previously approved these changes Aug 18, 2025
arguments.stream()
.skip(1).filter(arg -> {
String base = arg.getBase();
return "function".equals(base) || "lambda".equals(base);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"function".equals(base)

Do we have this use case?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do have this in some cases
Screenshot 2025-08-21 at 12 24 24 PM


if (!argumentTypes.isEmpty() && "map".equals(arguments.get(0).getBase())) {
arguments.stream()
.skip(1).filter(arg -> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this be a problem if there is only one argument?

String base = arg.getBase();
return "function".equals(base) || "lambda".equals(base);
}).findFirst().ifPresent(arg -> {
String warningMessage = createWarningMessage(node, "Lambdas on large maps are expensive, consider using map_subset");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to also print out the specific function which triggers this warning?

@abhinavmuk04 abhinavmuk04 added the from:Meta PR from Meta label Aug 26, 2025
@prestodb-ci
Copy link
Contributor

Saved that user @abhinavmuk04 is from Meta

@abhinavmuk04 abhinavmuk04 merged commit 52afa5a into prestodb:master Aug 26, 2025
67 checks passed
@abhinavmuk04 abhinavmuk04 deleted the lambdawarnings branch August 26, 2025 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
from:Meta PR from Meta
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants