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

Followup multiple eventlistener plugin changes (Fix tests). #24755

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

Conversation

ScrapCodes
Copy link

Description

A previous PR
#24456
added the needed changes to support Multiple event listener.
However it missed some changes in tests, query runners etc.
So here we fix the follow up, i.e. fix tests etc..

Motivation and Context

Impact

An API in QueryRunner to get EventListener is marked as Deprecated.

Test Plan

Existing tests.

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.

Release Notes

Please follow release notes guidelines and fill in the release notes below.

== NO RELEASE NOTE ==

Sorry, something went wrong.

@ScrapCodes ScrapCodes requested a review from presto-oss March 19, 2025 12:18
@prestodb-ci prestodb-ci added the from:IBM PR from IBM label Mar 19, 2025
@prestodb-ci prestodb-ci requested review from a team, auden-woolfson and imsayari404 and removed request for a team March 19, 2025 12:19
@ScrapCodes
Copy link
Author

cc @zac, @aditi-pandit and @evanvdia

@ScrapCodes ScrapCodes force-pushed the followup_multiple_eventlistener branch from d846344 to d3c9ef0 Compare March 19, 2025 12:21
Copy link
Contributor

@auden-woolfson auden-woolfson left a comment

Choose a reason for hiding this comment

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

Looks good, just a couple small changes

List<EventListener> eventListener = getQueryRunner().getEventListeners();
assertFalse(eventListener.isEmpty());
assertTrue(eventListener.get(0) instanceof TestHiveEventListenerPlugin.TestingHiveEventListener, eventListener.get(0).getClass().getName());
return (TestHiveEventListenerPlugin.TestingHiveEventListener) eventListener.get(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

same here

return Optional.of(getEventListeners().get(0));
}

List<EventListener> getEventListeners();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a log here if there are multiple event listeners?

Copy link
Author

Choose a reason for hiding this comment

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

Adding a log message here, is not a good convention. What I could do is add an assert, that invoker of this method expects no more than one eventlistener. But that has consequences, if people are upgrading.

Copy link
Contributor

@aditi-pandit aditi-pandit left a comment

Choose a reason for hiding this comment

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

Thanks @ScrapCodes. Have a small nit, and also please address Auden's comments. Otherwise it looks good.

assertTrue(eventListener.isPresent());
assertTrue(eventListener.get() instanceof TestHiveEventListenerPlugin.TestingHiveEventListener, eventListener.get().getClass().getName());
return (TestHiveEventListenerPlugin.TestingHiveEventListener) eventListener.get();
List<EventListener> eventListener = getQueryRunner().getEventListeners();
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit : Change variable name to eventListeners

A previous PR
added the needed changes to support Multiple event listener.
However it missed some changes in tests, query runners etc.
So here we fix the follow up, i.e. fix tests etc..
@ScrapCodes ScrapCodes force-pushed the followup_multiple_eventlistener branch from d3c9ef0 to 00ac731 Compare March 20, 2025 05:43
@ScrapCodes
Copy link
Author

Hi @aditi-pandit and @auden-woolfson , updated the PR. Please take a look again!

@@ -607,10 +607,10 @@ public StatsCalculator getStatsCalculator()
}

@Override
public Optional<EventListener> getEventListener()
public List<EventListener> getEventListeners()
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be Optional<List

Copy link
Author

@ScrapCodes ScrapCodes Mar 21, 2025

Choose a reason for hiding this comment

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

Thanks @jaystarshot for taking a look. I am not fully sure, I understand that. List can have zero elements (an List#isEmpty check similar to Optional#isPresent check), and if we are concerned about not breaking existing users, we added a default Optional<EventListener> in QueryRunner interface Link.

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

Successfully merging this pull request may close these issues.

None yet

5 participants