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 2 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 @@ -263,7 +263,7 @@ Table toPb() {
}

@SuppressWarnings("unchecked")
static StandardTableDefinition fromPb(Table tablePb) {
static StandardTableDefinition fromPb(Table tablePb) throws Throwable {
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
Builder builder = newBuilder().table(tablePb);
if (tablePb.getNumRows() != null) {
builder.setNumRows(tablePb.getNumRows().longValue());
Expand All @@ -272,7 +272,23 @@ 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().toPrettyString()
+ " in table "
+ tablePb.getTableReference().toPrettyString(),
e);
} catch (NullPointerException e) {
throw new NullPointerException(
"Got unexpected time partitioning "
+ tablePb.getTimePartitioning().toPrettyString()
+ " in table "
+ tablePb.getTableReference().toPrettyString())
.initCause(e);
}
}
if (tablePb.getRangePartitioning() != null) {
builder.setRangePartitioning(RangePartitioning.fromPb(tablePb.getRangePartitioning()));
Expand Down
Expand Up @@ -20,6 +20,7 @@
import com.google.api.services.bigquery.model.Table;
import com.google.cloud.StringEnumType;
import com.google.cloud.StringEnumValue;
import java.io.IOException;
import java.io.Serializable;
import javax.annotation.Nullable;

Expand Down Expand Up @@ -145,7 +146,7 @@ Table toPb() {
}

@SuppressWarnings("unchecked")
static <T extends TableDefinition> T fromPb(Table tablePb) {
static <T extends TableDefinition> T fromPb(Table tablePb) throws IOException, Throwable {
stephaniewang526 marked this conversation as resolved.
Show resolved Hide resolved
switch (Type.valueOf(tablePb.getType()).toString()) {
case "TABLE":
return (T) StandardTableDefinition.fromPb(tablePb);
Expand Down