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

[Tour of Beam] add work example #27080

Merged
merged 11 commits into from
Jun 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -63,7 +63,7 @@ func main() {
s := p.Root()
project := "apache-beam-testing"

// Build a PCollection<CommentRow> by querying BigQuery.
// Build a PCollection<Game> by querying BigQuery.
rows := bigqueryio.Read(s, project, "bigquery-public-data:baseball.schedules", reflect.TypeOf(Game{}))

fixedSizeLines := top.Largest(s, rows, 5, less)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,8 @@
# - hellobeam

import argparse
import os
import warnings

import apache_beam as beam
from apache_beam.options.pipeline_options import PipelineOptions, GoogleCloudOptions, SetupOptions
from apache_beam.io.gcp.bigquery import ReadFromBigQueryRequest, ReadAllFromBigQuery

class WeatherData:
def __init__(self, station_number, wban_number, year, month, day):
Expand All @@ -56,7 +52,7 @@ def run(argv=None):


with beam.Pipeline(options=pipeline_options, argv=argv) as p:
(p | 'ReadFromBigQuery' >> beam.io.ReadFromBigQuery(query='select * from `apache-beam-testing.clouddataflow_samples.weather_stations`',
(p | 'ReadFromBigQuery' >> beam.io.ReadFromBigQuery(table='apache-beam-testing:clouddataflow_samples.weather_stations',
riteshghorse marked this conversation as resolved.
Show resolved Hide resolved
method=beam.io.ReadFromBigQuery.Method.DIRECT_READ)
| beam.combiners.Sample.FixedSizeGlobally(5)
| beam.FlatMap(lambda line: line)
Expand Down