Run multiple queries serially using the connector for BigQuery.
Stay organized with collections
Save and categorize content based on your preferences.
Runs multiple queries serially, one after the other, using the connector for BigQuery.
Explore further
For detailed documentation that includes this code sample, see the following:
Code sample
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],[],[],[],null,["# Run multiple queries serially using the connector for BigQuery.\n\nRuns multiple queries serially, one after the other, using the connector for BigQuery.\n\nExplore further\n---------------\n\n\nFor detailed documentation that includes this code sample, see the following:\n\n- [Run multiple BigQuery jobs in parallel](/workflows/docs/tutorials/bigquery-parallel-jobs)\n\nCode sample\n-----------\n\n### YAML\n\n main:\n steps:\n - init:\n assign:\n - results : {} # result from each iteration keyed by table name\n - tables:\n - 201201h\n - 201202h\n - 201203h\n - 201204h\n - 201205h\n - runQueries:\n for:\n value: table\n in: ${tables}\n steps:\n - logTable:\n call: sys.log\n args:\n text: ${\"Running query for table \" + table}\n - runQuery:\n call: googleapis.bigquery.v2.jobs.query\n args:\n projectId: ${sys.get_env(\"GOOGLE_CLOUD_PROJECT_ID\")}\n body:\n useLegacySql: false\n useQueryCache: false\n timeoutMs: 30000\n # Find top 100 titles with most views on Wikipedia\n query: ${\n \"SELECT TITLE, SUM(views)\n FROM `bigquery-samples.wikipedia_pageviews.\" + table + \"`\n WHERE LENGTH(TITLE) \u003e 10\n GROUP BY TITLE\n ORDER BY SUM(VIEWS) DESC\n LIMIT 100\"\n }\n result: queryResult\n - returnResult:\n assign:\n # Return the top title from each table\n - results[table]: {}\n - results[table].title: ${queryResult.rows[0].f[0].v}\n - results[table].views: ${queryResult.rows[0].f[1].v}\n - returnResults:\n return: ${results}\n\nWhat's next\n-----------\n\n\nTo search and filter code samples for other Google Cloud products, see the\n[Google Cloud sample browser](/docs/samples?product=workflows)."]]