alxp1982 commented on code in PR #25301: URL: https://github.com/apache/beam/pull/25301#discussion_r1124089313
########## learning/tour-of-beam/learning-content/IO/big-query-io/read-table/description.md: ########## @@ -0,0 +1,40 @@ +<!-- +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +--> +### BigQuery reading table + +`BigQueryIO` allows you to read from a `BigQuery` table and read the results. By default, Beam invokes a `BigQuery` export request when you apply a BigQueryIO read transform. readTableRows returns a PCollection of BigQuery TableRow objects. Each element in the `PCollection` represents a single row in the table. `Integer` values in the `TableRow` objects are encoded as strings to match `BigQuery`’s exported JSON format. This method is convenient, but can be 2-3 times slower in performance compared to `read(SerializableFunction)`. + +{{if (eq .Sdk "go")}} + +``` +rows := bigqueryio.Read(s, bigquery.TableReference{ProjectID: projectID, DatasetID: datasetID, TableID: tableID}) +beam.ParDo0(s, &logOutput{}, rows) +``` +{{end}} +{{if (eq .Sdk "java")}} +``` + PCollection<MyData> rows = + pipeline + .apply( + "Read from BigQuery query", + BigQueryIO.readTableRows().from("tess-372508.fir.xasw") +``` +{{end}} +{{if (eq .Sdk "python")}} +``` +pipeline + | 'ReadTable' >> beam.io.ReadFromBigQuery(table=table_spec) \ + | beam.Map(lambda elem: elem['max_temperature']) +``` +{{end}} Review Comment: Please add runnable example description, e.g. ### Playground Excercise section -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
