public abstract static class BigQueryIO.TypedRead<T> extends PTransform<PBegin,PCollection<T>> implements ProjectionProducer<PTransform<PBegin,PCollection<T>>>
BigQueryIO.read(SerializableFunction)
.Modifier and Type | Class and Description |
---|---|
static class |
BigQueryIO.TypedRead.Method
Determines the method used to read data from BigQuery.
|
static class |
BigQueryIO.TypedRead.QueryPriority
An enumeration type for the priority of a query.
|
annotations, displayData, name, resourceHints
Constructor and Description |
---|
TypedRead() |
Modifier and Type | Method and Description |
---|---|
PTransform<PBegin,PCollection<T>> |
actuateProjectionPushdown(java.util.Map<TupleTag<?>,FieldAccessDescriptor> outputFields)
Actuate a projection pushdown.
|
PCollection<T> |
expand(PBegin input)
Override this method to specify how this
PTransform should be expanded on the given
InputT . |
BigQueryIO.TypedRead<T> |
from(java.lang.String tableSpec)
|
BigQueryIO.TypedRead<T> |
from(TableReference table)
|
BigQueryIO.TypedRead<T> |
from(ValueProvider<java.lang.String> tableSpec)
|
BigQueryIO.TypedRead<T> |
fromQuery(java.lang.String query)
|
BigQueryIO.TypedRead<T> |
fromQuery(ValueProvider<java.lang.String> query)
|
abstract BigQueryIO.TypedRead.Method |
getMethod() |
@Nullable TableReference |
getTable()
|
@Nullable ValueProvider<TableReference> |
getTableProvider()
|
void |
populateDisplayData(DisplayData.Builder builder)
Register display data for the given transform or component.
|
static <T> void |
readSource(PipelineOptions options,
TupleTag<T> rowTag,
DoFn.MultiOutputReceiver outputReceiver,
BoundedSource<T> streamSource,
org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ErrorHandlingParseFn<T> errorHandlingParseFn,
BadRecordRouter badRecordRouter) |
boolean |
supportsProjectionPushdown()
Whether
this supports projection pushdown. |
BigQueryIO.TypedRead<T> |
useAvroLogicalTypes() |
BigQueryIO.TypedRead<T> |
usingStandardSql()
|
void |
validate(PipelineOptions options)
Called before running the Pipeline to verify this transform is fully and correctly specified.
|
BigQueryIO.TypedRead<T> |
withBeamRowConverters(TypeDescriptor<T> typeDescriptor,
org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ToBeamRowFunction<T> toRowFn,
org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.FromBeamRowFunction<T> fromRowFn)
Sets the functions to convert elements to/from
Row objects. |
BigQueryIO.TypedRead<T> |
withCoder(Coder<T> coder)
Sets a
Coder for the result of the parse function. |
BigQueryIO.TypedRead<T> |
withErrorHandler(ErrorHandler<BadRecord,?> badRecordErrorHandler) |
BigQueryIO.TypedRead<T> |
withFormat(com.google.cloud.bigquery.storage.v1.DataFormat format)
See
DataFormat . |
BigQueryIO.TypedRead<T> |
withKmsKey(java.lang.String kmsKey)
For query sources, use this Cloud KMS key to encrypt any temporary tables created.
|
BigQueryIO.TypedRead<T> |
withMethod(BigQueryIO.TypedRead.Method method)
|
BigQueryIO.TypedRead<T> |
withoutResultFlattening()
|
BigQueryIO.TypedRead<T> |
withoutValidation()
|
BigQueryIO.TypedRead<T> |
withQueryLocation(java.lang.String location)
BigQuery geographic location where the query job will be
executed.
|
BigQueryIO.TypedRead<T> |
withQueryPriority(BigQueryIO.TypedRead.QueryPriority priority)
|
BigQueryIO.TypedRead<T> |
withQueryTempDataset(java.lang.String queryTempDatasetRef)
Temporary dataset reference when using
fromQuery(String) . |
BigQueryIO.TypedRead<T> |
withQueryTempProjectAndDataset(java.lang.String queryTempProjectRef,
java.lang.String queryTempDatasetRef)
|
BigQueryIO.TypedRead<T> |
withRowRestriction(java.lang.String rowRestriction)
|
BigQueryIO.TypedRead<T> |
withRowRestriction(ValueProvider<java.lang.String> rowRestriction)
Read only rows which match the specified filter, which must be a SQL expression compatible
with Google standard
SQL.
|
BigQueryIO.TypedRead<T> |
withSelectedFields(java.util.List<java.lang.String> selectedFields)
|
BigQueryIO.TypedRead<T> |
withSelectedFields(ValueProvider<java.util.List<java.lang.String>> selectedFields)
Read only the specified fields (columns) from a BigQuery table.
|
BigQueryIO.TypedRead<T> |
withTemplateCompatibility() |
BigQueryIO.TypedRead<T> |
withTestServices(BigQueryServices testServices) |
addAnnotation, compose, compose, getAdditionalInputs, getAnnotations, getDefaultOutputCoder, getDefaultOutputCoder, getDefaultOutputCoder, getKindString, getName, getResourceHints, setDisplayData, setResourceHints, toString, validate
public abstract BigQueryIO.TypedRead.Method getMethod()
public void validate(PipelineOptions options)
PTransform
By default, does nothing.
validate
in class PTransform<PBegin,PCollection<T>>
public PCollection<T> expand(PBegin input)
PTransform
PTransform
should be expanded on the given
InputT
.
NOTE: This method should not be called directly. Instead apply the PTransform
should
be applied to the InputT
using the apply
method.
Composite transforms, which are defined in terms of other transforms, should return the output of one of the composed transforms. Non-composite transforms, which do not apply any transforms internally, should return a new unbound output and register evaluators (via backend-specific registration methods).
expand
in class PTransform<PBegin,PCollection<T>>
public static <T> void readSource(PipelineOptions options, TupleTag<T> rowTag, DoFn.MultiOutputReceiver outputReceiver, BoundedSource<T> streamSource, org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ErrorHandlingParseFn<T> errorHandlingParseFn, BadRecordRouter badRecordRouter) throws java.lang.Exception
java.lang.Exception
public void populateDisplayData(DisplayData.Builder builder)
PTransform
populateDisplayData(DisplayData.Builder)
is invoked by Pipeline runners to collect
display data via DisplayData.from(HasDisplayData)
. Implementations may call super.populateDisplayData(builder)
in order to register display data in the current namespace,
but should otherwise use subcomponent.populateDisplayData(builder)
to use the namespace
of the subcomponent.
By default, does not register any display data. Implementors may override this method to provide their own display data.
populateDisplayData
in interface HasDisplayData
populateDisplayData
in class PTransform<PBegin,PCollection<T>>
builder
- The builder to populate with display data.HasDisplayData
public @Nullable ValueProvider<TableReference> getTableProvider()
public @Nullable TableReference getTable()
public BigQueryIO.TypedRead<T> withCoder(Coder<T> coder)
Coder
for the result of the parse function. This may be required if a coder
can not be inferred automatically.public BigQueryIO.TypedRead<T> withKmsKey(java.lang.String kmsKey)
public BigQueryIO.TypedRead<T> withBeamRowConverters(TypeDescriptor<T> typeDescriptor, org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.ToBeamRowFunction<T> toRowFn, org.apache.beam.sdk.io.gcp.bigquery.BigQueryIO.TypedRead.FromBeamRowFunction<T> fromRowFn)
public BigQueryIO.TypedRead<T> from(java.lang.String tableSpec)
public BigQueryIO.TypedRead<T> from(ValueProvider<java.lang.String> tableSpec)
public BigQueryIO.TypedRead<T> fromQuery(java.lang.String query)
public BigQueryIO.TypedRead<T> fromQuery(ValueProvider<java.lang.String> query)
public BigQueryIO.TypedRead<T> from(TableReference table)
public BigQueryIO.TypedRead<T> withoutValidation()
public BigQueryIO.TypedRead<T> withoutResultFlattening()
public BigQueryIO.TypedRead<T> usingStandardSql()
public BigQueryIO.TypedRead<T> withQueryPriority(BigQueryIO.TypedRead.QueryPriority priority)
public BigQueryIO.TypedRead<T> withQueryLocation(java.lang.String location)
public BigQueryIO.TypedRead<T> withQueryTempDataset(java.lang.String queryTempDatasetRef)
fromQuery(String)
. When reading from a query,
BigQuery will create a temporary dataset and a temporary table to store the results of the
query. With this option, you can set an existing dataset to create the temporary table.
BigQueryIO will create a temporary table in that dataset, and will remove it once it is not
needed. No other tables in the dataset will be modified. If your job does not have
permissions to create a new dataset, and you want to use fromQuery(String)
(for
instance, to read from a view), you should use this option. Remember that the dataset must
exist and your job needs permissions to create and remove tables inside that dataset.public BigQueryIO.TypedRead<T> withQueryTempProjectAndDataset(java.lang.String queryTempProjectRef, java.lang.String queryTempDatasetRef)
public BigQueryIO.TypedRead<T> withMethod(BigQueryIO.TypedRead.Method method)
public BigQueryIO.TypedRead<T> withFormat(com.google.cloud.bigquery.storage.v1.DataFormat format)
DataFormat
.public BigQueryIO.TypedRead<T> withSelectedFields(java.util.List<java.lang.String> selectedFields)
public BigQueryIO.TypedRead<T> withSelectedFields(ValueProvider<java.util.List<java.lang.String>> selectedFields)
Requires BigQueryIO.TypedRead.Method.DIRECT_READ
. Not compatible with fromQuery(String)
.
public BigQueryIO.TypedRead<T> withRowRestriction(java.lang.String rowRestriction)
public BigQueryIO.TypedRead<T> withRowRestriction(ValueProvider<java.lang.String> rowRestriction)
Requires BigQueryIO.TypedRead.Method.DIRECT_READ
. Not compatible with fromQuery(String)
.
public BigQueryIO.TypedRead<T> withErrorHandler(ErrorHandler<BadRecord,?> badRecordErrorHandler)
public BigQueryIO.TypedRead<T> withTemplateCompatibility()
public BigQueryIO.TypedRead<T> withTestServices(BigQueryServices testServices)
public BigQueryIO.TypedRead<T> useAvroLogicalTypes()
public boolean supportsProjectionPushdown()
ProjectionProducer
this
supports projection pushdown.supportsProjectionPushdown
in interface ProjectionProducer<PTransform<PBegin,PCollection<T>>>
public PTransform<PBegin,PCollection<T>> actuateProjectionPushdown(java.util.Map<TupleTag<?>,FieldAccessDescriptor> outputFields)
ProjectionProducer
actuateProjectionPushdown
in interface ProjectionProducer<PTransform<PBegin,PCollection<T>>>
outputFields
- Map keyed by the TupleTag
for each output on which pushdown is
requested. The value is the FieldAccessDescriptor
containing the list of fields
needed for that output; fields not present in the descriptor should be dropped.T
that implements the projection pushdown. The return value is assumed to be a
drop-in replacement for this
; it must have all the same functionality. For this
reason, T
is usually the same class as this
.