public static class BigQueryIO.Read extends Object
PTransform
that reads from a BigQuery table and returns a
PCollection
of TableRows
containing each of the rows of the table.
Each TableRow
contains values indexed by column name. Here is a
sample processing function that processes a "line" column from rows:
static class ExtractWordsFn extends DoFn<TableRow, String> {
public void processElement(ProcessContext c) {
// Get the "line" field of the TableRow object, split it into words, and emit them.
TableRow row = c.element();
String[] words = row.get("line").toString().split("[^a-zA-Z']+");
for (String word : words) {
if (!word.isEmpty()) {
c.output(word);
}
}
}
}
Modifier and Type | Class and Description |
---|---|
static class |
BigQueryIO.Read.Bound
|
Modifier and Type | Method and Description |
---|---|
static BigQueryIO.Read.Bound |
from(String tableSpec)
Reads a BigQuery table specified as
"[project_id]:[dataset_id].[table_id]" or
"[dataset_id].[table_id]" for tables within the current project. |
static BigQueryIO.Read.Bound |
from(TableReference table)
Reads a BigQuery table specified as a
TableReference object. |
static BigQueryIO.Read.Bound |
fromQuery(String query)
Reads results received after executing the given query.
|
static BigQueryIO.Read.Bound |
named(String name)
Returns a
BigQueryIO.Read.Bound with the given name. |
static BigQueryIO.Read.Bound |
withoutValidation()
Disables BigQuery table validation, which is enabled by default.
|
public static BigQueryIO.Read.Bound named(String name)
BigQueryIO.Read.Bound
with the given name. The BigQuery table or query to be read
from has not yet been configured.public static BigQueryIO.Read.Bound from(String tableSpec)
"[project_id]:[dataset_id].[table_id]"
or
"[dataset_id].[table_id]"
for tables within the current project.public static BigQueryIO.Read.Bound fromQuery(String query)
public static BigQueryIO.Read.Bound from(TableReference table)
TableReference
object.public static BigQueryIO.Read.Bound withoutValidation()