Skip to content

Conversation

@aokolnychyi
Copy link
Contributor

This PR applies Baseline to iceberg-hive and resolves #157.

}
}

protected abstract void close(C client);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one might be questionable. Our code style requires overloaded methods to be together.

Copy link
Contributor

Choose a reason for hiding this comment

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

Can we move the other close to just below the abstract methods instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* Copyright 2004 Clinton Begin
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 am not sure about the header here.

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to keep the old header. Apache projects do not change copyright headers, except to add additional notes about modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

<check level="error" class="org.scalastyle.scalariform.NoWhitespaceBeforeLeftBracketChecker" enabled="true"/>
<check level="error" class="org.scalastyle.scalariform.NoWhitespaceAfterLeftBracketChecker" enabled="true"/>
<check level="error" class="org.scalastyle.scalariform.ReturnChecker" enabled="true"/>
<check level="error" class="org.scalastyle.scalariform.ReturnChecker" enabled="false"/>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a leftover after the PR for Spark.


if (tableType == null || !tableType.equalsIgnoreCase(ICEBERG_TABLE_TYPE_VALUE)) {
throw new IllegalArgumentException(format("Invalid tableName, not Iceberg: %s.%s", database, table));
throw new IllegalArgumentException(String.format("Invalid tableName, not Iceberg: %s.%s", database, table));
Copy link
Contributor

@rdsr rdsr Jun 26, 2019

Choose a reason for hiding this comment

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

Would it make sense to simply use Preconditions.checkArgument here [and other places where we use IllegalArgumentException] which supports formatting out of the box?

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 to this

} catch (NoSuchObjectException e) {
if (currentMetadataLocation() != null) {
throw new NoSuchTableException(format("No such table: %s.%s", database, tableName));
throw new NoSuchTableException(String.format("No such table: %s.%s", database, tableName));
Copy link
Contributor

Choose a reason for hiding this comment

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

NoSuchTableException supports string formatting

} catch (TException e) {
throw new RuntimeException(format("Failed to get table info from metastore %s.%s", database, tableName), e);
String errMsg = String.format("Failed to get table info from metastore %s.%s", database, tableName);
throw new RuntimeException(errMsg, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

We have a RuntimeMetaException which supports formatting, should we create a RuntimeTException to supporting formatting ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Good ideas. I'm fine either way with this. It would be nice to clean this up now, but I am fine with doing it in a separate commit since this is supposed to clean up formatting, not make substantive changes.

if (!Objects.equals(currentMetadataLocation(), metadataLocation)) {
throw new CommitFailedException(format("metadataLocation = %s is not same as table metadataLocation %s for %s.%s",
currentMetadataLocation(), metadataLocation, database, tableName));
String errMsg = String.format("metadataLocation = %s is not same as table metadataLocation %s for %s.%s",
Copy link
Contributor

Choose a reason for hiding this comment

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

Same, CommitFailedException supports formatting. We do not need to wrap it with String.fromat

private final List<FieldSchema> columns(Schema schema) {
return schema.columns().stream().map(col -> new FieldSchema(col.name(), HiveTypeConverter.convert(col.type()), "")).collect(Collectors.toList());
private List<FieldSchema> columns(Schema schema) {
return schema.columns().stream()
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we replace this with Lists.transform , since we prefer using Guava's HOFs

if (!state.equals(LockState.ACQUIRED)) {
throw new CommitFailedException(format("Could not acquire the lock on %s.%s, " +
"lock request ended in state %s", database, tableName, state));
throw new CommitFailedException(String.format("Could not acquire the lock on %s.%s, " +
Copy link
Contributor

Choose a reason for hiding this comment

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

As above

@rdblue
Copy link
Contributor

rdblue commented Jun 27, 2019

@aokolnychyi, this looks good to me except for the copyright header change. That needs to be reverted.

As for the problems that @rdsr noted, I'm okay fixing them either here or in a follow-up to keep this focused on baseline changes.

@aokolnychyi
Copy link
Contributor Author

Thanks for the review @rdsr and @rdblue! Let's keep this PR Baseline-specific and I'll follow up with another PR to fix issues that @rdsr noted. +1 on them

@rdblue rdblue merged commit d6d9e4d into apache:master Jun 28, 2019
@rdblue
Copy link
Contributor

rdblue commented Jun 28, 2019

@aokolnychyi, thanks for fixing this!

I made some of the suggested changes in #240. Let's get #240 and #239 in and then follow up with fixes for the remaining items.

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.

[Baseline] Apply Baseline to iceberg-hive

3 participants