Querying data from external data sources

Run the following command to query and show the first name from the CSV file. This command specifies the external data source and provides an alias name for the temporarily linked table as employees and run the specified query:

bq query --external_table_definition=employees::tabledefinition.txt 'SELECT EMPLOYEE_FIRST_NAME FROM employees;'

To create a permanent linked table for the file in Google Cloud Storage, run the following command. This command will create a new permanent link in BigQuery between the file and an alias in BigQuery under the specified dataset:

bq mk --external_table_definition=tabledefinition.txt  HumanResourceDS.Employees_Linked

The linked table can be queried like a normal table using the query command in the bq utility shown as follows. The following command will show all the records from the file in the console:

bq query 'select * from HumanResourceDS.Employees_Linked'
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.216.27.251