Skip to content

Conversation

@nastra
Copy link
Contributor

@nastra nastra commented Jun 16, 2021

No description provided.

@github-actions github-actions bot added the API label Jun 16, 2021
@nastra
Copy link
Contributor Author

nastra commented Jun 16, 2021

@rdblue is this something that you could potentially review?

private TableIdentifier(Namespace namespace, String name) {
Preconditions.checkArgument(name != null && !name.isEmpty(), "Invalid table name %s", name);
Preconditions.checkArgument(namespace != null, "Namespace must be non-null");
Preconditions.checkArgument(name != null && !name.isEmpty(), "Table name must be non-null/non-empty");
Copy link
Contributor

Choose a reason for hiding this comment

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

There's no need to move this check. Reordering without a clear reason just results in more commit conflicts later.

Also, the original error message conforms to our conventions better than the new one. Our convention is to be as direct as possible, which is why it started with "Invalid table name". If you'd like to add the "non-null/non-empty" part, I'd recommend using "Invalid table name (null or empty): %s".

Copy link
Contributor Author

@nastra nastra Jun 17, 2021

Choose a reason for hiding this comment

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

sure thing. I would probably just have Invalid table name (null or empty) / Invalid table name: null or empty (to align with other error messages) without printing what the actual name is, since it's already mentioned in the error message (null or empty)

Copy link
Contributor

Choose a reason for hiding this comment

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

It's a minor distinction, but I would normally include what the user actually had. If it was null, then it will show up as Invalid table name (null or empty): null. Not a big deal the way it is here, though.

@nastra nastra force-pushed the table-identifier-improvements branch from 8bd133f to c88fe3c Compare June 17, 2021 06:50
@rdblue rdblue merged commit 629da77 into apache:master Jun 17, 2021
@rdblue
Copy link
Contributor

rdblue commented Jun 17, 2021

Thanks for the fix, @nastra!

private final String name;

public static TableIdentifier of(String... names) {
Preconditions.checkArgument(names != null, "Cannot create table identifier from null array");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think null check is needed for java varargs. The names will be empty array if no input is given. I verified it locally:

private void met(String... strs) {
    System.out.println(Arrays.toString(strs));
  }

met();

The result is []

Copy link
Contributor

Choose a reason for hiding this comment

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

The problem isn't when this is used as a varargs call. It is that this actually creates of(String[] names) in the class file. So you can call it directly with a String array:

String[] levels = null;
return Namespace.of(levels); // fails

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I see, never thought about this use case, thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nastra nastra deleted the table-identifier-improvements branch June 18, 2021 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants