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

BigQuery: Add support to FormatOptions for AVRO #1576

Merged
merged 1 commit into from
Jan 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class FormatOptions implements Serializable {
static final String CSV = "CSV";
static final String JSON = "NEWLINE_DELIMITED_JSON";
static final String DATASTORE_BACKUP = "DATASTORE_BACKUP";
static final String AVRO = "AVRO";
private static final long serialVersionUID = -443376052020423691L;

private final String type;
Expand Down Expand Up @@ -94,6 +95,13 @@ public static FormatOptions datastoreBackup() {
return new FormatOptions(DATASTORE_BACKUP);
}

/**
* Default options for AVRO format.
*/
public static FormatOptions avro() {
return new FormatOptions(AVRO);
}

/**
* Default options for the provided format.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,29 @@ public void testConstructor() {
assertEquals(FormatOptions.JSON, options.getType());
options = new FormatOptions(FormatOptions.DATASTORE_BACKUP);
assertEquals(FormatOptions.DATASTORE_BACKUP, options.getType());
options = new FormatOptions(FormatOptions.AVRO);
assertEquals(FormatOptions.AVRO, options.getType());
}

@Test
@SuppressWarnings("deprecation")

This comment was marked as spam.

This comment was marked as spam.

public void testConstructorDeprecated() {
FormatOptions options = new FormatOptions(FormatOptions.CSV);
assertEquals(FormatOptions.CSV, options.type());
options = new FormatOptions(FormatOptions.JSON);
assertEquals(FormatOptions.JSON, options.type());
options = new FormatOptions(FormatOptions.DATASTORE_BACKUP);
assertEquals(FormatOptions.DATASTORE_BACKUP, options.type());
options = new FormatOptions(FormatOptions.AVRO);
assertEquals(FormatOptions.AVRO, options.type());
}

@Test
public void testFactoryMethods() {
assertEquals(FormatOptions.CSV, FormatOptions.csv().getType());
assertEquals(FormatOptions.JSON, FormatOptions.json().getType());
assertEquals(FormatOptions.DATASTORE_BACKUP, FormatOptions.datastoreBackup().getType());
assertEquals(FormatOptions.AVRO, FormatOptions.avro().getType());
}

@Test
Expand Down