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

feat(database): supports query database by tenantName、clusterNam and dataSourceName #4232

Open
wants to merge 8 commits into
base: dev/4.3.x
Choose a base branch
from

Conversation

ysjemmm
Copy link
Collaborator

@ysjemmm ysjemmm commented Feb 14, 2025

What type of PR is this?

type-feature

What this PR does / why we need it:

Databases can be queried by tenantName, clusterName and dataSourceName

@ysjemmm ysjemmm added the type-feature The functionality to be implemented label Feb 14, 2025
@ysjemmm ysjemmm added this to the ODC 4.3.4 milestone Feb 14, 2025
@ysjemmm ysjemmm self-assigned this Feb 14, 2025
guowl3
guowl3 previously approved these changes Feb 21, 2025
String clusterName) {
long conditionCount = Stream.of(dataSourceName, tenantName, clusterName).filter(StringUtils::isNotBlank)
.count();
if (conditionCount == 0L || conditionCount >= 2L) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why return empty set when conditionCount >= 2?
It's tricky to use magic numbers 0L and 2L.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I only need one condition at most, otherwise it doesn't fit the function

Copy link
Collaborator

Choose a reason for hiding this comment

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

Then just verify the conditionCount == 1, and throw an exception if not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👌

Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW, this method is not readable. The caller is not aware that you only accept one of the parameters. Think about what you will do when you are required to accept more parameters in future features.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

BTW, this method is not readable. The caller is not aware that you only accept one of the parameters. Think about what you will do when you are required to accept more parameters in future features.

If there are multiple conditions, all I can think of is using Map, or using Function, leaving the decision to the caller

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-feature The functionality to be implemented
Projects
Status: Reopen
Development

Successfully merging this pull request may close these issues.

5 participants