Here is the issue with a BigQuery query. I know this query is missing a dataset name, so the error "Table name "my_table" missing dataset while no default dataset is set in the request."
select * from my_table;
Changing 'my_tabale' to 'my_dataset.my_table' will fix the issue. But can somebody help me with setting a default dataset. The error message clearly giving an indication that BigQuery has such an option.
Renaming datasets Currently, you cannot change the name of an existing dataset, but you can copy a dataset.
Google BigQuery is not case sensitive, so all names default to lowercase.
BigQuery datasets are subject to the following limitations: You can set the geographic location at creation time only. All tables referenced in a query must be stored in datasets in the same location. When copying a table, the datasets containing the source table and destination table must reside in the same location.
Here is the issue with a BigQuery query. I know this query is missing a dataset name, so the error "Table name "my_table" missing dataset while no default dataset is set in the request." Changing 'my_tabale' to 'my_dataset.my_table' will fix the issue.
Note: If your project is not associated with a billing account, BigQuery automatically sets the default table expiration for datasets that you create in the project. You can specify a shorter default table expiration for a dataset, but you can't specify a longer default table expiration. Click Create dataset.
After a dataset is created, the location can't be changed. Note: If you choose EU or an EU-based region for the dataset location, your Core BigQuery Customer Data resides in the EU. Core BigQuery Customer Data is defined in the Service Specific Terms.
Depending on which API you are using, you can specify the defaultDataset
parameter when running your BigQuery job. More information for the jobs.query
api can be found here https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query.
For example, using the NodeJS API for createQueryJob
https://googleapis.dev/nodejs/bigquery/latest/BigQuery.html#createQueryJob, you can do something similar to this:
const options = {
keyFilename: process.env.GOOGLE_APPLICATION_CREDENTIALS,
projectId: process.env.GOOGLE_APPLICATION_PROJECT_ID,
defaultDataset: {
datasetId: process.env.BIGQUERY_DATASET_ID,
projectId: process.env.GOOGLE_APPLICATION_PROJECT_ID
},
query: `select * from my_table;`
}
const [job] = await bigquery.createQueryJob(options);
let [rows] = await job.getQueryResults();
The short answer is: SET @@dataset_id = 'whatever';
But, this is a scripting command, so you will have to enclose your SQL query in a BEGIN ... END block. Note the semicolon. Scripting gives you some added flexibility. On the other hand, it prevents the console from doing that fun thing where it estimates the processing cost.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With