How do I get the datasetId and tableId from BigQuery. I tried to click the dropdown on the sidebar and copied the dataset info and table info, Is there any way, I can query the datasetId and tableId? but I got this error. I am using php client libraries to pull the BigQuery data.
How do I get the datasetId and tableId from BigQuery. I tried to click the dropdown on the sidebar and copied the dataset info and table info, Is there any way, I can query the datasetId and tableId? but I got this error. I am using php client libraries to pull the BigQuery data.
use Google\Cloud\BigQuery\BigQueryClient;
/** Uncomment and populate these variables in your code */
// $projectId = 'The Google project ID';
// $datasetId = 'The BigQuery dataset ID';
// $tableId = 'The BigQuery table ID';
// $maxResults = 10;
$maxResults = 10;
$startIndex = 0;
$options = [
'maxResults' => $maxResults,
'startIndex' => $startIndex
];
$bigQuery = new BigQueryClient([
'projectId' => $projectId,
]);
$dataset = $bigQuery->dataset($datasetId);
$table = $dataset->table($tableId);
$numRows = 0;
foreach ($table->rows($options) as $row) {
print('---');
foreach ($row as $column => $value) {
printf('%s: %s' . PHP_EOL, $column, $value);
}
$numRows++;
}
I am getting this error.
Google\Cloud\Core\Exception\BadRequestException : {
"error": {
"code": 400,
"message": "Invalid dataset ID \"mc-data-2:Turnflex\". Dataset IDs must be alphanumeric (plus underscores and dashes) and must be at most 1024 characters long.",
"errors": [
{
"message": "Invalid dataset ID \"mc-data-2:Turnflex\". Dataset IDs must be alphanumeric (plus underscores and dashes) and must be at most 1024 characters long.",
"domain": "global",
"reason": "invalid"
}
],
"status": "INVALID_ARGUMENT"
}
}