Database Reference
In-Depth Information
is relative to the parent, while the fully-qualified ID is the full name of
the object, which can be used to find it in any context. The table in the
previous example has a relative ID of latest and a fully-qualified ID of
bigquery-e2e:logs.latest .
In the API, however, the name components are split to make it easier to
create and parse names. For example, if you have the fully-qualified ID
bigquery-e2e:logs.latest and you want to find out the dataset ID,
you'd have to figure out a way to extract only the portion you need from the
full name. This extraction is an error-prone process, and relies on knowing
exactly what characters are expected to be in the different portions of the
ID. To prevent you from having to try to parse identifiers, the API returns
a JSON object with the individual name components. These JSON objects
are called references . The reference corresponding to the table
bigquery-e2e:logs.latest is:
{"projectId": "bigquery-e2e", "datasetId": "logs",
"tableId": "latest"}
The datasetId field can be easily extracted from this result. In Python, to
extract the dataset ID from the table reference, you can treat the reference
as a dict:
dataset_id = table_ref["datasetId"]
In Java, if you use the BigQuery client library, the TableReference object
would have a getDatasetId() method:
String datasetId = tableRef.getDatasetId();
Table 4.1 shows the identifier and reference format for BigQuery objects.
 
Search WWH ::




Custom Search