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

[#3701]refactor(API): Refactoring SupportsSchemas.listSchemas() method to return String[] #3722

Merged
merged 4 commits into from
Jun 4, 2024

Conversation

shaofengshi
Copy link
Contributor

What changes were proposed in this pull request?

Currently, the SupportsSchemas.listSchemas() method returns an array of NameIdentifier to represents the schemas. Actually a String[] will be more clear and easier to use.

Why are the changes needed?

To make the API more clear to use.

Fix: #3701

Does this PR introduce any user-facing change?

Almost not; Just return type changed, will be more simple.

How was this patch tested?

Yes, many test cases cover this API.

@shaofengshi shaofengshi self-assigned this Jun 3, 2024
@shaofengshi
Copy link
Contributor Author

@yuqi1129 @mchades please review this small API change; The update for doc will be made a little bit later in batch after the code be merged.

@mchades
Copy link
Contributor

mchades commented Jun 3, 2024

Missing changes in Python client?

@shaofengshi
Copy link
Contributor Author

Missing changes in Python client?

The change in Python will be tracked with another issue: #3732

@mchades
Copy link
Contributor

mchades commented Jun 3, 2024

Overall LGTM

Arrays.stream(nameIdentifiers).map(NameIdentifier::name).collect(Collectors.toSet());
Assertions.assertTrue(schemaNames.contains(schemaName));
String[] schemaNames = schemas.listSchemas();
Assertions.assertTrue(Arrays.asList(schemaNames).contains(schemaName));
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you can check if you can use ArrayUtils.contains() without introducing extra dependencies.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't understand; Arrays is the JDK utility class, while ArrayUtils is apache commons lang; As this is so simple a case, I don't think it is necessary to use ArrayUtils here.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a personal preference and the current implementation looks good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, thanks~

@@ -81,7 +81,7 @@ public NameIdentifier[] listSchemas() throws NoSuchCatalogException {
ErrorHandlers.schemaErrorHandler());
resp.validate();

return resp.identifiers();
return Arrays.stream(resp.identifiers()).map(NameIdentifier::name).toArray(String[]::new);
Copy link
Contributor

Choose a reason for hiding this comment

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

So, will the server side of this interface remain the same?

Copy link
Contributor

Choose a reason for hiding this comment

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

Can you respond to it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Right, server side won't change; The "SupportsSchemas" has two version, one is for client, the other is for server side. This change has already been made in the main branch.

@jerryshao jerryshao changed the title [#3701]refactor: Refactoring SupportsSchemas.listSchemas() method to return String[] [#3701]refactor(API): Refactoring SupportsSchemas.listSchemas() method to return String[] Jun 3, 2024
@jerryshao
Copy link
Contributor

LGTM.

Copy link
Contributor

@yuqi1129 yuqi1129 left a comment

Choose a reason for hiding this comment

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

LGTM

@shaofengshi shaofengshi merged commit 2c41f4d into apache:main Jun 4, 2024
33 checks passed
@shaofengshi shaofengshi deleted the 3701-SupportsSchemas branch June 4, 2024 02:03
diqiu50 pushed a commit to diqiu50/gravitino that referenced this pull request Jun 13, 2024
… method to return String[] (apache#3722)

### What changes were proposed in this pull request?

Currently, the SupportsSchemas.listSchemas() method returns an array of
NameIdentifier to represents the schemas. Actually a String[] will be
more clear and easier to use.

### Why are the changes needed?

To make the API more clear to use.

Fix: apache#3701

### Does this PR introduce _any_ user-facing change?

Almost not; Just return type changed, will be more simple.

### How was this patch tested?

Yes, many test cases cover this API.
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.

[Subtask] Refactoring SupportsSchemas.listSchemas() method in client side
4 participants