使用适用于 BigQuery 的连接器串行运行多个查询。
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
使用 BigQuery 连接器按顺序运行多个查询。
深入探索
如需查看包含此代码示例的详细文档,请参阅以下内容:
代码示例
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","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)."]]