BIQ 查询/通过 php 覆盖表



我正在寻找一种通过客户端库 php 覆盖 BIG 查询中现有表的方法。

在WEB UI中,我可以轻松地使用"目标表"和"写入首选项"选项是否可以在 php 中做同样的事情?

composer.json

{
    "require": {
        "google/cloud": "^0.13.0",
        "google/apiclient": "^2.0"
    }
}

我有这段代码来覆盖一个表

        $builder = $this->getServiceBuilder();
        $bigQuery = $builder->bigQuery();
// Get an instance of a previously created table.
        $dataset = $bigQuery->dataset('wr_temp');
        $table = $dataset->table('shop_api_order_id');
// Begin a job to import data from a CSV file into the table.
        if (!is_file($data['params']['filename'])) {
            $this->e('File ' . $data['params']['filename'] . ' cannot be located');
            return false;
        }
        $job = $table->load(
                fopen($data['params']['filename'], 'r'), array(
            'jobConfig' => array(
                "writeDisposition" => 'WRITE_TRUNCATE',
                "schema" => array(
                    "fields" => array(array(
                            "name" => 'order_id',
                            "type" => 'INTEGER',
                            "mode" => 'NULLABLE',
                        )
                    )
                )
            )
                )
        );
        $isComplete = $job->isComplete();
        while (!$isComplete) {
            sleep(1); // let's wait for a moment...
            $job->reload();
            $isComplete = $job->isComplete();
        }

最新更新