Integrations

The following examples are queries related to related to tables, warehouses, and BI tools.

Please note that the sample queries below only show a subset of the fields available for brevity. You can use introspection to see all available fields.

Warehouses:

Get the Warehouse Id (dwId)

Your warehouse id can be retrieved using getUser.

The warehouse uuid (referred to as dwID) is used in subsequent queries to specify the warehouse context.

query getUser {
  getUser {
    account {
      warehouses {
        uuid
        connectionType
      }
    }
  }
}
{
  "data": {
    "getUser": {
      "account": {
        "warehouses": [
          {
            "uuid": "dummy_warehouse_id",
            "connectionType": "SNOWFLAKE"
          }
        ]
      }
    }
  }
}

Get Table Metadata

Table status and metadata can be retrieved using getTable. For multiple tables you can paginate through getTables instead.

The mcon can be used in subsequent queries as a unique identifier for the asset. If you already have the mcon that can be used in place of the fullTableId in the request.

query getTable {
  getTable(
    dwId:"dummy_warehouse_id", 
    fullTableId:"database:schema.table") {
      mcon
      fullTableId
      discoveredTime
      description
      location
      tableType
      createdTime
      status
      freshnessAnomaly
      sizeAnomaly
      freshnessSizeAnomaly
      metricAnomaly
      dynamicTable
      isDeleted
  }
}
{
  "data": {
    "getTable": {
      “mcon”: “dummy_table_id”
      "fullTableId": "database:schema.table",
      "discoveredTime": "2020-10-17T00:36:28.190057+00:00",
      "description": null,
      "location": null,
      "tableType": "TABLE",
      "createdTime": "2021-02-02T11:23:38.777000+00:00",
      "status": "Y",
      "freshnessAnomaly": false,
      "sizeAnomaly": false,
      "freshnessSizeAnomaly": false,
      "metricAnomaly": false,
      "dynamicTable": false,
      "isDeleted": false
    }
  }
}

Get Table Schema

The latest table schema (and previous versions of the schema) can be retrieved using getTable. These fields can be paginated through using the cursor.

query getTable {
  getTable(
    dwId:"dummy_warehouse_id", 
    fullTableId:"database:schema.table") {
      fullTableId
      schemaChangeCount
      versions (first:1) {
        edges {
          node {
            fields(first:10) {
              pageInfo {
                endCursor
                hasNextPage
              }
              edges {
                node {
                  name
                  fieldType
                }
              }
            }
          }
        }
      }
    }
}
{
  "data": {
    "getTable": {
      "fullTableId": "database:schema.table",
      "schemaChangeCount": 3,
      "versions": {
        "edges": [
          {
            "node": {
              "fields": {
                "pageInfo": {
                  "endCursor": ""
                  "hasNextPage": false
                },
                "edges": [
                  {
                    "node": {
                      "name": "ingestion_time",
                      "fieldType": "timestamp_ltz(9)"
                    }
                  }
                ]
              }
            }
          }
        ]
      }
    }
  }
}

Get Table Freshness

The table's freshness graph can be retrieved using getTable.

query getTable {
  getTable(
    dwId:"dummy_warehouse_id", 
    fullTableId:"database:schema.table") {
      fullTableId
      mcon
      lastUpdates (startTime: "2021-03-24T06:59:59.999Z", endTime:"2021-03-31T06:59:59.999Z") {
        value
        measurementTimestamp
      }
    }
}
{
  "data": {
    "getTable": {
      "lastUpdates": [
        {
          "value": "2021-03-30T13:35:53+00:00",
          "measurementTimestamp": "2021-03-31T01:17:15+00:00"
        },
        {
          "value": "2021-03-30T01:34:16+00:00",
          "measurementTimestamp": "2021-03-30T13:07:03+00:00"
        },
        {
          "value": "2021-03-29T13:35:05+00:00",
          "measurementTimestamp": "2021-03-30T00:56:15+00:00"
        }
      ]
    }
  }
}

Get Table Size

The table's size (number of rows) can be retrieved using getTable. To query byte counts, replace totalRowCounts with totalByteCounts.

query getTable {
  getTable(
    dwId:"dummy_warehouse_id", 
    fullTableId:"database:schema.table") {
      totalRowCounts(startTime: "2021-03-24T06:59:59.999Z", endTime:"2021-03-31T06:59:59.999Z"){
        value
        measurementTimestamp
      }
    }
}
{
  "data": {
    "getTable": {
      "totalRowCounts": [
        {
          "value": 42,
          "measurementTimestamp": "2021-03-31T01:17:15+00:00"
        },
        {
          "value": 50,
          "measurementTimestamp": "2021-03-31T00:16:00+00:00"
        }
      ]
    }
  }
}

Get Table Tags

Table (or field) tags can be retrieved using getObjectProperties. Similarly, tags can be created and/or updated using createOrUpdateObjectProperty. These tags can be defined in the dashboard or retrieved from the warehouse. The results can be paginated through.

query getObjectProperties{
  getObjectProperties(mconId:"dummy_table_id", first: 10) {
    edges {
      node {
        propertyName
        propertyValue
        propertySource
      }
    }
  }
}
{
  "data": {
    "getObjectProperties": {
      "edges": [
        {
          "node": {
            "propertyName": "is_important",
            "propertyValue": "true",
            "propertySource": SNOWFLAKE
          }
        }
      ]
    }
  }
}

📘

Using getTable

Please note that you can retrieve all these fields in one query (request). The separation was for demonstration purposes.

BI Tools:

Add Multiple LookML Repositories

In order to add more than one LookML repo, you will want to first to create an SSH Key. Next, you'll pass this SSH key into the below query.

Parameters:

repoUrl: Repository URL as ssh://[[email protected]]server/project.git or the shorter form [[email protected]]server:project.git
sshKey: SSH Key, base64-encoded

mutation {
  testLookerGitSshCredentials(
    repoUrl: "url_here"
    sshKey: "base64_encoded_ssh_key_here" 
  ){
    key
    success
  }
}

Once you have the returned key, you can pass this into the addBiConnection function.

Parameters:

connectionType: This will be looker-git-ssh in this case.
key: This is the key returned from the testLookerGitSshCredentials function

mutation{
  addBiConnection(
    connectionType: "looker-git-ssh"
    key: "your_key_here"
  ){
    connection{
      uuid
    }
  }
}

Did this page help you?