{"action":"created","issue":{"url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/871","repository_url":"https://api.github.com/repos/googleapis/google-cloud-php","labels_url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/871/labels{/name}","comments_url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/871/comments","events_url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/871/events","html_url":"https://github.com/googleapis/google-cloud-php/issues/871","id":292206092,"node_id":"MDU6SXNzdWUyOTIyMDYwOTI=","number":871,"title":"BigQuery: Delay for inserting rows after a table is deleted and created again","user":{"login":"gsouf","id":3215399,"node_id":"MDQ6VXNlcjMyMTUzOTk=","avatar_url":"https://avatars0.githubusercontent.com/u/3215399?v=4","gravatar_id":"","url":"https://api.github.com/users/gsouf","html_url":"https://github.com/gsouf","followers_url":"https://api.github.com/users/gsouf/followers","following_url":"https://api.github.com/users/gsouf/following{/other_user}","gists_url":"https://api.github.com/users/gsouf/gists{/gist_id}","starred_url":"https://api.github.com/users/gsouf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsouf/subscriptions","organizations_url":"https://api.github.com/users/gsouf/orgs","repos_url":"https://api.github.com/users/gsouf/repos","events_url":"https://api.github.com/users/gsouf/events{/privacy}","received_events_url":"https://api.github.com/users/gsouf/received_events","type":"User","site_admin":false},"labels":[{"id":279131797,"node_id":"MDU6TGFiZWwyNzkxMzE3OTc=","url":"https://api.github.com/repos/googleapis/google-cloud-php/labels/api:%20bigquery","name":"api: bigquery","color":"f8f8f8","default":false},{"id":268638473,"node_id":"MDU6TGFiZWwyNjg2Mzg0NzM=","url":"https://api.github.com/repos/googleapis/google-cloud-php/labels/type:%20question","name":"type: question","color":"c5def5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":9,"created_at":"2018-01-28T13:52:18Z","updated_at":"2018-10-30T19:49:42Z","closed_at":"2018-01-29T19:06:56Z","author_association":"NONE","body":"Hi,\r\n\r\n\r\n### Initial case :\r\n\r\nI have been trying to implement a script that creates a table with a given schema (only if the table does not exist already) and after that I'm inserting data using ``Table::insertRows``.\r\n\r\nWhen I run this script for the first time (that means the table does not exist), then the table is correctly created, and the response for ``Table::insertRows`` is always successful with 0 failed rows.\r\n\r\n### expected result\r\n\r\nThe rows are created in my table\r\n\r\n### actual result\r\n\r\nWhen I query this table, it appears to be empty.\r\n\r\n### additional info\r\n\r\nIf I run the script again - that means the table is already created and its creation is then skipped - the rows are correctly inserted.\r\n\r\n### how to reproduce\r\n\r\nSee bellow an isolated case to reproduct this issue:\r\n\r\n```php\r\n\r\n// function to creates the table, only if not exists\r\nfunction createTableIfNotExist(BigQueryClient $client, $dataset, $tableName)\r\n{\r\n\r\n    // get table\r\n    $dataset = $client->dataset($dataset);\r\n    $table = $dataset->table($tableName);\r\n\r\n    // create table if not exists\r\n    if (!$table->exists()) {\r\n        $schema = [\r\n            [\r\n                'name'  => 'foo',\r\n                'type'  => 'string',\r\n                'mode'  => 'required'\r\n            ]\r\n        ];\r\n\r\n        // create table\r\n        $dataset->createTable($table->id(), [\r\n            'schema' => [\r\n                'fields' => $schema\r\n            ]\r\n        ]);\r\n    }\r\n}\r\n\r\n// function to insert rows\r\nfunction insertRows(array $rows, BigQueryClient $client, $dataset, $tableName)\r\n{\r\n    // get table\r\n    $dataset = $client->dataset($dataset);\r\n    $table = $dataset->table($tableName);\r\n\r\n    // insert rows\r\n    return $table->insertRows($rows);\r\n}\r\n\r\n// auth file\r\n$bigQueryAuthFile = [.....];\r\n\r\n// create a big query client\r\n$bigQueryClient = new BigQueryClient([\r\n    'projectId'   => 'projectName',\r\n    'keyFile' => $bigQueryAuthFile\r\n]);\r\n\r\n// tablename and dataset\r\n$tableName = 'foobar_table';\r\n$dataset = 'foobar_dataset';\r\n\r\n// create the table if not exists\r\ncreateTableIfNotExist($bigQueryClient, $dataset, $tableName);\r\n\r\n// rows to insert\r\n$rows = [\r\n    [\r\n        'insertId' => 'foo',\r\n        'data' => [\r\n            'foo' => 'foo'\r\n        ]\r\n    ],\r\n    [\r\n        'insertId' => 'bar',\r\n        'data' => [\r\n            'foo' => 'bar'\r\n        ]\r\n    ]\r\n];\r\n\r\n// Tried things like ``sleep(20);`` here,  but didn't help.\r\n\r\n// insert rows\r\n$response = insertRows($rows, $bigQueryClient, $dataset, $tableName);\r\n\r\n// check success\r\nvar_dump($response->isSuccessful());\r\n```"},"comment":{"url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/comments/434444280","html_url":"https://github.com/googleapis/google-cloud-php/issues/871#issuecomment-434444280","issue_url":"https://api.github.com/repos/googleapis/google-cloud-php/issues/871","id":434444280,"node_id":"MDEyOklzc3VlQ29tbWVudDQzNDQ0NDI4MA==","user":{"login":"gsouf","id":3215399,"node_id":"MDQ6VXNlcjMyMTUzOTk=","avatar_url":"https://avatars0.githubusercontent.com/u/3215399?v=4","gravatar_id":"","url":"https://api.github.com/users/gsouf","html_url":"https://github.com/gsouf","followers_url":"https://api.github.com/users/gsouf/followers","following_url":"https://api.github.com/users/gsouf/following{/other_user}","gists_url":"https://api.github.com/users/gsouf/gists{/gist_id}","starred_url":"https://api.github.com/users/gsouf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gsouf/subscriptions","organizations_url":"https://api.github.com/users/gsouf/orgs","repos_url":"https://api.github.com/users/gsouf/repos","events_url":"https://api.github.com/users/gsouf/events{/privacy}","received_events_url":"https://api.github.com/users/gsouf/received_events","type":"User","site_admin":false},"created_at":"2018-10-30T19:49:42Z","updated_at":"2018-10-30T19:49:42Z","author_association":"NONE","body":"@mitchellirvin not later than todayI wrote some unit tests on the top of streaming inserts. I wanted to rebuild the table everytime as I use to do when testing database operations and ofcourse that failed. I ended up using load operations to feed the database and only testing queries. Unfortunately we skipped all tests were e use streaming inserts :("}}
{"actor":{"display_login":"gsouf"}}