Dataflow Workbench で CloudSQL のデータを BigQuery フェデレーションでみる
Dataflow Workbench の起動
Google Cloud Console > Dataflow > Workbench
新しいノートブック > Apache Beam > Without GPUs をクリックして、設定はそのままに「作成」。
立ち上がったら、「JUPYTERLABを開く」をクリック。
コード
import apache_beam as beam
from apache_beam.runners.interactive.interactive_runner import InteractiveRunner
import apache_beam.runners.interactive.interactive_beam as ib
from apache_beam.options import pipeline_options
#from apache_beam.options.pipeline_options import GoogleCloudOptions
#import google.auth
from apache_beam.io import ReadFromBigQuery
ib.options.recording_duration = '1m'
options = pipeline_options.PipelineOptions(project='<project id>', temp_location='gs://<bucket name>/temp')
p = beam.Pipeline(InteractiveRunner(), options=options)
# need to grand BigQuery connection user paermission to Compute Engine default Service Account
query='SELECT * FROM EXTERNAL_QUERY("projects/<project id>/locations/us/connections/cloudesql-fed", "SELECT * FROM federation_test.item;");'
query_results = p | beam.io.ReadFromBigQuery(
query=query, use_standard_sql=True)
ib.show(query_results, include_window_info=True)
結果
import apache_beam as beam
from apache_beam.runners.interactive.interactive_runner import InteractiveRunner
import apache_beam.runners.interactive.interactive_beam as ib
from apache_beam.options import pipeline_options
#from apache_beam.options.pipeline_options import GoogleCloudOptions
#import google.auth
from apache_beam.io import ReadFromBigQuery
ib.options.recording_duration = '1m'
options = pipeline_options.PipelineOptions(project='<project id>', temp_location='gs://<bucket name>/temp')
p = beam.Pipeline(InteractiveRunner(), options=options)
# need to grand BigQuery connection user paermission to Compute Engine default Service Account
query='SELECT * FROM EXTERNAL_QUERY("projects/<project id>/locations/us/connections/cloudesql-fed", "SELECT * FROM federation_test.item;");'
query_results = p | beam.io.ReadFromBigQuery(
query=query, use_standard_sql=True)
ib.show(query_results, include_window_info=True)
Author And Source
この問題について(Dataflow Workbench で CloudSQL のデータを BigQuery フェデレーションでみる), 我々は、より多くの情報をここで見つけました https://qiita.com/ShuA/items/e586cdb3c2887842452b著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .