BigQueryIO.read( (SchemaAndRecord elem) -> (Double) elem.getRecord().get("max_temperature")) .fromQuery( "SELECT max_temperature FROM [clouddataflow-readonly:samples.weather_stations]") .withCoder(DoubleCoder.of())); BigQueryIO.read( (SchemaAndRecord elem) -> (Double) elem.getRecord().get("max_temperature")) .fromQuery( "SELECT max_temperature FROM `clouddataflow-readonly.samples.weather_stations`") .usingStandardSql() (Double) record.get("max_temperature")); }) .fromQuery( "SELECT year, month, day, max_temperature " + "FROM [clouddataflow-readonly:samples.weather_stations] "
bigQueryIOPTransform = BigQueryIO.readTableRows().fromQuery(dataset.query.getValue()); if (!dataset.useLegacySql.getValue()) { bigQueryIOPTransform = bigQueryIOPTransform.usingStandardSql();
bigQueryIOPTransform = BigQueryIO.readTableRows().fromQuery(dataset.query.getValue()); if (!dataset.useLegacySql.getValue()) { bigQueryIOPTransform = bigQueryIOPTransform.usingStandardSql();
p.apply("ReadFlattened", BigQueryIO.readTableRows().fromQuery(options.getInput())); PCollection<TableRow> nonFlattenedCollection = p.apply( "ReadNonFlattened", BigQueryIO.readTableRows().fromQuery(options.getInput()).withoutResultFlattening()); PCollection<TableRow> unflattenableCollection = p.apply( "ReadUnflattenable", BigQueryIO.readTableRows() .fromQuery(options.getUnflattenableInput()) .withoutResultFlattening());
@Override public PCollectionTuple expand(PBegin begin) { return begin .apply( "AvroToEntity", BigQueryIO.read( AvroToEntity.newBuilder() .setEntityKind(entityKind()) .setUniqueNameColumn(uniqueNameColumn()) .setNamespace(namespace()) .build()) .fromQuery(query()) .withoutValidation() .withTemplateCompatibility() .usingStandardSql()) .apply( "CheckNoKey", CheckNoKey.newBuilder() .setFailureTag(failureTag()) .setSuccessTag(successTag()) .build()); } }
/** Same as {@code fromQuery(String)}, but with a {@link ValueProvider}. */ public Read fromQuery(ValueProvider<String> query) { return new Read(this.inner.fromQuery(query)); }
/** See {@link Read#fromQuery(String)}. */ public TypedRead<T> fromQuery(String query) { return fromQuery(StaticValueProvider.of(query)); }
/** * Reads results received after executing the given query. * * <p>By default, the query results will be flattened -- see "flattenResults" in the <a * href="https://cloud.google.com/bigquery/docs/reference/v2/jobs">Jobs documentation</a> for * more information. To disable flattening, use {@link Read#withoutResultFlattening}. * * <p>By default, the query will use BigQuery's legacy SQL dialect. To use the BigQuery Standard * SQL dialect, use {@link Read#usingStandardSql}. */ public Read fromQuery(String query) { return new Read(this.inner.fromQuery(query)); }