在 Datalab 中将 Bigquery 结果写入 Bigquery

Write Bigquery results to Bigquery in Datalab

我 运行 查询 abc 并在 Datalab 中得到结果 table m。

有什么方法可以在 Bigquery 中创建一个新的 table 并在 Datalab 中将 table m 的内容写入其中?

%%bq query --name abc
select *
from `test`

m=abc.execute().result()

是的,Datalab 支持许多 BigQuery 魔法命令,其中包括 create,它允许创建数据集和表。

请参阅此处的文档: http://googledatalab.github.io/pydatalab/datalab.magics.html

特别是这一部分,它详细介绍了所有可用的 BigQuery 命令:

positional arguments:
  {sample,create,delete,dryrun,udf,execute,pipeline,table,schema,datasets,tables,extract,load}
                        commands
    sample              Display a sample of the results of a BigQuery SQL
                        query. The cell can optionally contain arguments for
                        expanding variables in the query, if -q/--query was
                        used, or it can contain SQL for a query.
    create              Create a dataset or table.
    delete              Delete a dataset or table.
    dryrun              Execute a dry run of a BigQuery query and display
                        approximate usage statistics
    udf                 Create a named Javascript BigQuery UDF
    execute             Execute a BigQuery SQL query and optionally send the
                        results to a named table. The cell can optionally
                        contain arguments for expanding variables in the
                        query.
    pipeline            Define a deployable pipeline based on a BigQuery
                        query. The cell can optionally contain arguments for
                        expanding variables in the query.
    table               View a BigQuery table.
    schema              View a BigQuery table or view schema.
    datasets            List the datasets in a BigQuery project.
    tables              List the tables in a BigQuery project or dataset.
    extract             Extract BigQuery query results or table to GCS.
    load                Load data from GCS into a BigQuery table.