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: add debug statement to StandardTableDefinition #128

Merged
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -272,7 +272,28 @@ static StandardTableDefinition fromPb(Table tablePb) {
builder.setStreamingBuffer(StreamingBuffer.fromPb(tablePb.getStreamingBuffer()));
}
if (tablePb.getTimePartitioning() != null) {
builder.setTimePartitioning(TimePartitioning.fromPb(tablePb.getTimePartitioning()));
try {
builder.setTimePartitioning(TimePartitioning.fromPb(tablePb.getTimePartitioning()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException(
"Got unexpected time partitioning "
+ tablePb.getTimePartitioning()
+ " in table "
+ tablePb.getTableReference(),
e);
} catch (NullPointerException e) {
try {
throw new NullPointerException(
"Got unexpected time partitioning "
+ tablePb.getTimePartitioning()
+ " in table "
+ tablePb.getTableReference())
.initCause(e);
// catching Throwable due to adding initCause
} catch (Throwable throwable) {
throwable.printStackTrace();
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
if (tablePb.getRangePartitioning() != null) {
builder.setRangePartitioning(RangePartitioning.fromPb(tablePb.getRangePartitioning()));
Expand Down
Expand Up @@ -64,6 +64,13 @@ public class StandardTableDefinitionTest {
.setClustering(CLUSTERING)
.build();

// to test invalid time partitioning type set in table definition
private static final StandardTableDefinition INVALID_TABLE_DEFINITION =
StandardTableDefinition.newBuilder()
.setSchema(TABLE_SCHEMA)
.setTimePartitioning(null)
.build();

@Test
public void testToBuilder() {
compareStandardTableDefinition(TABLE_DEFINITION, TABLE_DEFINITION.toBuilder().build());
Expand Down Expand Up @@ -118,6 +125,12 @@ public void testToAndFromPb() {
definition, TableDefinition.<StandardTableDefinition>fromPb(definition.toPb()));
}

@Test(expected = IllegalArgumentException.class)
public void testInvalidTableDef() {
// not supposed to have this time partitioning type
StandardTableDefinition.fromPb(INVALID_TABLE_DEFINITION.toPb());
}

stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
@Test
public void testFromPbWithNullEstimatedRowsAndBytes() {
StandardTableDefinition.fromPb(
Expand Down