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

[Enhancement] Support aggregate function map_agg. #51967

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Jcnessss
Copy link

@Jcnessss Jcnessss commented Oct 16, 2024

Why I'm doing:

Map_agg is an aggregate function to generate map value, which is frequently used in Trino. To support migrate from Trino to Starrocks, develop the same function in Starrocks.

Related issue #40894

What I'm doing:

I tried 3 ways to develop this function:

  1. Using template: key type as KT, value type as VT, in which case neither the key or value could be complex type.
  2. Not using template: Both key and value could be complex type, however, we need to call map_column#remove_duplicated_keys, and there is a triple loop in it, which will highly decrease the performance of map_agg.
  3. Using template: key type as KT, in which case the value could be complex type.

I think the 3rd one will be the best one, and the behavior is just like Trino.

What type of PR is this:

  • BugFix
  • Feature
  • Enhancement
  • Refactor
  • UT
  • Doc
  • Tool

Does this PR entail a change in behavior?

  • Yes, this PR will result in a change in behavior.
  • No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • Parameter changes: default values, similar parameters but with different default values
  • Policy changes: use new policy to replace old one, functionality automatically enabled
  • Feature removed
  • Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • I have added test cases for my bug fix or my new feature
  • This pr needs user documentation (for new or modified features or behaviors)
    • I have added documentation for my new feature or new function
  • This is a backport pr

Bugfix cherry-pick branch check:

  • I have checked the version labels which the pr will be auto-backported to the target branch
    • 3.3
    • 3.2
    • 3.1
    • 3.0
    • 2.5

@Jcnessss Jcnessss requested review from a team as code owners October 16, 2024 07:07
be/src/exprs/agg/map_agg.h Outdated Show resolved Hide resolved
be/src/exprs/agg/map_agg.h Outdated Show resolved Hide resolved
using KeyType = typename SliceHashSet::key_type;

MyHashMap hash_map;
void update(MemPool* mem_pool,
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems other system implement has a max limit for map_agg

Copy link
Author

Choose a reason for hiding this comment

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

I'm not sure. It seems that the map_agg of Trino does not have a limit, all my implement is simulating the one in Trino.

@Jcnessss
Copy link
Author

@stdpain Thanks for the review again! I have changed the code according to your review. Could you please help me review again?

@Jcnessss Jcnessss requested a review from stdpain October 16, 2024 11:18
stdpain
stdpain previously approved these changes Oct 17, 2024
@Jcnessss
Copy link
Author

@stdpain Thanks for all the reviews!

@Jcnessss
Copy link
Author

@stdpain Hi, I'm sorry that I forgot to commit a part of FE codes. Could you please review this again?

Copy link

sonarcloud bot commented Oct 18, 2024

Copy link

[Java-Extensions Incremental Coverage Report]

pass : 0 / 0 (0%)

Copy link

[BE Incremental Coverage Report]

fail : 10 / 73 (13.70%)

file detail

path covered_line new_line coverage not_covered_line_detail
🔵 be/src/exprs/agg/map_agg.h 1 64 01.56% [35, 40, 42, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 57, 67, 70, 71, 73, 74, 77, 78, 79, 80, 81, 83, 84, 86, 88, 89, 90, 92, 94, 96, 97, 98, 101, 102, 103, 107, 108, 110, 112, 113, 116, 117, 118, 120, 121, 122, 124, 126, 127, 128, 129, 130, 131, 132, 133, 135, 136, 137, 139, 141]
🔵 be/src/exprs/agg/factory/aggregate_resolver_avg.cpp 9 9 100.00% []

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants