Get model metadata

This page shows you how to get information or metadata about BigQuery MLmodels. You can get model metadata by:

  • Using the Google Cloud console
  • Using thebq show CLI command
  • Calling themodels.getAPI method directly or by using the client libraries
Note: Getting information about models by querying theINFORMATION_SCHEMAviews is unsupported.

Required permissions

To get model metadata, you must be assigned theREADERrole on the dataset, or you must be assigned a project-level Identity and Access Management (IAM) role thatincludesbigquery.models.getMetadata permissions. If you are grantedbigquery.models.getMetadata permissions at the project level, you can getmetadata on models in any dataset in the project. The following predefined,project-level IAM roles includebigquery.models.getMetadata permissions:

  • bigquery.dataViewer
  • bigquery.dataEditor
  • bigquery.dataOwner
  • bigquery.metadataViewer
  • bigquery.admin

For more information on IAM roles and permissions in BigQuery ML,seeAccess control.

Get model metadata

To get metadata about models:

Console

  1. In the left pane, clickExplorer:

    Highlighted button for the Explorer pane.

    If you don't see the left pane, clickExpand left pane to open the pane.

  2. In theExplorer pane, expand the project, clickDatasets, andthen select the dataset.

  3. Click theModels tab, and then click a model nameto select the model.

  4. Click theDetails tab. This tab displays themodel's metadata, including the description, labels, model type, andtraining options.

bq

Issue thebq show command with the--model or-m flag to displaymodel metadata. The--formatflag can be used to control the output.

To see only the feature columns for your model, use the--schema flagwith the--model flag. When you use the--schema flag,--format mustbe set to eitherjson orprettyjson.

If you are getting information about a model in a project other thanyour default project, add the project ID to the dataset in the followingformat:[PROJECT_ID]:[DATASET].

bq show --model --format=prettyjsonPROJECT_ID:DATASET.MODEL

Replace the following:

  • PROJECT_ID is your project ID.
  • DATASET is the name of the dataset.
  • MODEL is the name of the model.

The command output looks like the following when the--format=prettyflag is used. To see full details, use the--format=prettyjson format. Thesample output shows metadata for a logistic regression model.

+--------------+---------------------+---------------------+---------------------------+--------+-----------------+-----------------+|      Id      |     Model Type      |   Feature Columns   |       Label Columns       | Labels |  Creation Time  | Expiration Time |+--------------+---------------------+---------------------+---------------------------+--------+-----------------+-----------------+| sample_model | LOGISTIC_REGRESSION | |- column1: string  | |- label_column: int64    |        | 03 May 23:14:42 |                 ||              |                     | |- column2: bool    |                           |        |                 |                 ||              |                     | |- column3: string  |                           |        |                 |                 ||              |                     | |- column4: int64   |                           |        |                 |                 |+--------------+---------------------+---------------------+---------------------------+--------+-----------------+-----------------+

Examples:

Enter the following command to display all information aboutmymodel inmydataset.mydataset is in your default project.

bq show --model --format=prettyjson mydataset.mymodel

Enter the following command to display all information aboutmymodel inmydataset.mydataset is inmyotherproject, not your default project.

bq show --model --format=prettyjson myotherproject:mydataset.mymodel

Enter the following command to display only the feature columns formymodel inmydataset.mydataset is inmyotherproject, not yourdefault project.

bq show --model --schema --format=prettyjson \myotherproject:mydataset.mymodel

API

To get model metadata by using the API, call themodels.getmethod and provide theprojectId,datasetId, andmodelId.

Go

Before trying this sample, follow theGo setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryGo API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

import("context""fmt""io""cloud.google.com/go/bigquery")// printModelInfo demonstrates fetching metadata about a BigQuery ML model and printing some of// it to an io.Writer.funcprintModelInfo(wio.Writer,projectID,datasetID,modelIDstring)error{// projectID := "my-project-id"// datasetID := "mydataset"// modelID := "mymodel"ctx:=context.Background()client,err:=bigquery.NewClient(ctx,projectID)iferr!=nil{returnfmt.Errorf("bigquery.NewClient: %w",err)}deferclient.Close()meta,err:=client.Dataset(datasetID).Model(modelID).Metadata(ctx)iferr!=nil{returnfmt.Errorf("couldn't retrieve metadata: %w",err)}fmt.Fprintf(w,"Got model '%q' with friendly name '%q'\n",modelID,meta.Name)returnnil}

Java

Before trying this sample, follow theJava setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryJava API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

importcom.google.cloud.bigquery.BigQuery;importcom.google.cloud.bigquery.BigQueryException;importcom.google.cloud.bigquery.BigQueryOptions;importcom.google.cloud.bigquery.Model;importcom.google.cloud.bigquery.ModelId;publicclassGetModel{publicstaticvoidrunGetModel(){// TODO(developer): Replace these variables before running the sample.StringdatasetName="MY_DATASET_NAME";StringmodelName="MY_MODEL_ID";getModel(datasetName,modelName);}publicstaticvoidgetModel(StringdatasetName,StringmodelName){try{// Initialize client that will be used to send requests. This client only needs to be created// once, and can be reused for multiple requests.BigQuerybigquery=BigQueryOptions.getDefaultInstance().getService();ModelIdmodelId=ModelId.of(datasetName,modelName);Modelmodel=bigquery.getModel(modelId);System.out.println("Model: "+model.getDescription());System.out.println("Successfully retrieved model");}catch(BigQueryExceptione){System.out.println("Cannot retrieve model \n"+e.toString());}}}

Node.js

Before trying this sample, follow theNode.js setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryNode.js API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

// Import the Google Cloud client libraryconst{BigQuery}=require('@google-cloud/bigquery');constbigquery=newBigQuery();asyncfunctiongetModel(){// Retrieves model named "my_existing_model" in "my_dataset"./**   * TODO(developer): Uncomment the following lines before running the sample   */// const datasetId = "my_dataset";// const modelId = "my_existing_model";constdataset=bigquery.dataset(datasetId);const[model]=awaitdataset.model(modelId).get();console.log('Model:');console.log(model.metadata.modelReference);}

Python

Before trying this sample, follow thePython setup instructions in theBigQuery quickstart using client libraries. For more information, see theBigQueryPython API reference documentation.

To authenticate to BigQuery, set up Application Default Credentials. For more information, seeSet up authentication for client libraries.

fromgoogle.cloudimportbigquery# Construct a BigQuery client object.client=bigquery.Client()# TODO(developer): Set model_id to the ID of the model to fetch.# model_id = 'your-project.your_dataset.your_model'model=client.get_model(model_id)# Make an API request.full_model_id="{}.{}.{}".format(model.project,model.dataset_id,model.model_id)friendly_name=model.friendly_nameprint("Got model '{}' with friendly_name '{}'.".format(full_model_id,friendly_name))

What's next

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2026-02-19 UTC.