> ## Documentation Index
> Fetch the complete documentation index at: https://docs.open-metadata.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Run the BigQuery Connector Externally

> Configure BigQuery database connections in OpenMetadata using YAML. Complete setup guide with authentication, SSL, and connection parameters.

![BigQuery](https://docs.open-metadata.org/public/images/connectors/bigquery.webp)

# BigQuery

PROD

In this section, we provide guides and references to use the BigQuery connector.

> [!NOTE]
>
> **Supported Authentication Types:**
>
> * **GCP Credentials Values** — Direct service account key values (type, project ID, private key, client email, etc.)
> * **GCP Credentials Path** — Path to a local service account key JSON file
> * **GCP External Account** — Workload Identity Federation for non-GCP environments
> * **GCP Application Default Credentials (ADC)** — Automatic credential discovery in GCP environments or via `gcloud auth application-default login`

Configure and schedule BigQuery metadata and profiler workflows from the OpenMetadata UI:

* [Requirements](#requirements)
* [Metadata Ingestion](#metadata-ingestion)
  * [Incremental Extraction](https://docs.open-metadata.org/v2.1.x/connectors/ingestion/workflows/metadata/incremental-extraction/bigquery.md)
* [Query Usage](#query-usage)
* [Lineage](#lineage)
* [Data Profiler](#data-profiler)
* [Data Quality](#data-quality)
* [dbt Integration](#dbt-integration)

## How to Run the Connector Externally

To run the Ingestion via the UI you'll need to use the OpenMetadata Ingestion Container, which comes shipped with
custom Airflow plugins to handle the workflow deployment.

If, instead, you want to manage your workflows externally on your preferred orchestrator, you can check
the following docs to run the Ingestion Framework **anywhere**.

> [card] [External Schedulers](https://docs.open-metadata.org/v2.1.x/deployment/ingestion.md)
>
> Get more information about running the Ingestion Framework Externally

## Requirements

### Python Requirements

Use Python 3.10 or later. Python 3.12 is recommended, because it is what the OpenMetadata 2.0 ingestion images use. To confirm the supported range for your release, check the `Requires-Python` metadata of that release’s `openmetadata-ingestion` package.

To run the BigQuery ingestion, you will need to install:

```bash theme={null}
pip3 install "openmetadata-ingestion[bigquery]"
```

### GCP Permissions

To execute metadata extraction and usage workflow successfully the user or the service account should have enough access to fetch required data. Following table describes the minimum required permissions

| # | GCP Permission | Required For |
| :- | :- | :- |
| 1 | bigquery.datasets.get | Metadata Ingestion |
| 2 | bigquery.tables.get | Metadata Ingestion |
| 3 | bigquery.tables.getData | Metadata Ingestion |
| 4 | bigquery.tables.list | Metadata Ingestion |
| 5 | resourcemanager.projects.get | Metadata Ingestion |
| 6 | bigquery.jobs.create | Metadata Ingestion |
| 7 | bigquery.jobs.listAll | Metadata Ingestion |
| 8 | bigquery.routines.get | Stored Procedure |
| 9 | bigquery.routines.list | Stored Procedure |
| 10 | datacatalog.taxonomies.get | Fetch Policy Tags |
| 11 | datacatalog.taxonomies.list | Fetch Policy Tags |
| 12 | bigquery.readsessions.create | Bigquery Usage & Lineage Workflow |
| 13 | bigquery.readsessions.getData | Bigquery Usage & Lineage Workflow |
| 14 | logging.operations.list | Incremental Metadata Ingestion |

> [!TIP]
>
> If the user has `External Tables`, please attach relevant permissions needed for external tables, along with the above list of permissions.

> [card] [Create Custom GCP Role](https://docs.open-metadata.org/v2.1.x/connectors/database/bigquery/create-credentials.md)
>
> Checkout this documentation on how to create a custom role and assign it to the service account.

## Partitioned Tables

Starting in OpenMetadata 2.0.3, automatically detected BigQuery time-unit and ingestion-time partitions use the following profiling windows:

| Partition granularity | Default window |
| - | - |
| Hour | 24 hours |
| Day | 3 days |
| Month | 35 days |
| Year | 370 days |
| Unknown or unspecified | 3 days |

Explicit table-level partition settings override these defaults. Integer-range and value-based partitions do not use these time windows.

## Resolution

If a partition filter returns no sample rows, the ingestion logs warn that the window may not cover the table's most recent data. Open the table's profiler configuration and widen the partition interval as needed. In the partition configuration, `partitionInterval` sets the size and `partitionIntervalUnit` sets the unit, for example `30` and `DAY` for a 30-day window. A wider window can increase the amount of data scanned.

### Group Date-Sharded Tables

You can optionally group BigQuery tables whose names use daily date suffixes into one logical table in OpenMetadata. The logical table reduces duplicate catalog entries while preserving the physical shard used to run profiling and sample queries. Lineage and Data Quality results also retain the physical execution source.

Set `sourceConfig.config.shardedTables.enabled` to `true` in the BigQuery metadata ingestion configuration. The property defaults to `false` when it is omitted. In the UI, the equivalent **Group Sharded Tables** switch is under **Scope & Behaviour** and is enabled by default for a new BigQuery metadata pipeline. Existing pipelines remain disabled until you enable it.

Enable grouping only when the suffixed tables represent daily shards of the same logical dataset. Keep it disabled when similarly named tables have different schemas or meanings.

## Metadata Ingestion

### 1. Define the YAML Config

This is a sample config for BigQuery:

#### Source Configuration

Configure the source type and service name for your BigQuery connector.

#### Connection Type

**type**: Set to `BigQuery` for BigQuery connections.

#### Host and Port

**hostPort**: Defaults to `bigquery.googleapis.com`. A custom value applies only when `universeDomain` isn't `googleapis.com`.

#### Billing Project ID

**billingProjectId** (Optional): The GCP project that should be charged for the BigQuery jobs OpenMetadata runs. Use this when the project that pays for metadata, usage, or lineage queries is different from the project ID or IDs you ingest from.

#### Credentials

**credentials**: You can authenticate with your BigQuery instance using either `GCP Credentials Path` where you can specify the file path of the service account key or you can pass the values directly by choosing the `GCP Credentials Values` from the service account key file.

You can checkout [this](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console) documentation on how to create the service account keys and download it.

#### GCP Configuration

**gcpConfig:** You can authenticate using:

**1.** Passing the raw credential values provided by BigQuery:

**gcpConfig:**

* **type**: Credentials Type is the type of the account, for a service account the value of this field is `service_account`. To fetch this key, look for the value associated with the `type` key in the service account key file.
* **projectId**: A project ID is a unique string used to differentiate your project from all others in Google Cloud. To fetch this key, look for the value associated with the `project_id` key in the service account key file. You can also pass multiple project id to ingest metadata from different BigQuery projects into one service.
* **privateKeyId**: This is a unique identifier for the private key associated with the service account. To fetch this key, look for the value associated with the `private_key_id` key in the service account file.
* **privateKey**: This is the private key associated with the service account that is used to authenticate and authorize access to BigQuery. To fetch this key, look for the value associated with the `private_key` key in the service account file.
* **clientEmail**: This is the email address associated with the service account. To fetch this key, look for the value associated with the `client_email` key in the service account key file.
* **clientId**: This is a unique identifier for the service account. To fetch this key, look for the value associated with the `client_id` key in the service account key  file.
* **authUri**: This is the URI for the authorization server. To fetch this key, look for the value associated with the `auth_uri` key in the service account key file. The default value to Auth URI is [https://accounts.google.com/o/oauth2/auth](https://accounts.google.com/o/oauth2/auth).
* **tokenUri**: The Google Cloud Token URI is a specific endpoint used to obtain an OAuth 2.0 access token from the Google Cloud IAM service. This token allows you to authenticate and access various Google Cloud resources and APIs that require authorization. To fetch this key, look for the value associated with the `token_uri` key in the service account credentials file. The default token URI is `https://oauth2.googleapis.com/token`.
* **authProviderX509CertUrl**: This is the URL of the certificate that verifies the authenticity of the authorization server. To fetch this key, look for the value associated with the `auth_provider_x509_cert_url` key in the service account key file. The Default value for Auth Provider X509Cert URL is [https://www.googleapis.com/oauth2/v1/certs](https://www.googleapis.com/oauth2/v1/certs)
* **clientX509CertUrl**: This is the URL of the certificate that verifies the authenticity of the service account. To fetch this key, look for the value associated with the `client_x509_cert_url` key in the service account key  file.

**2.** Passing a local file path that contains the credentials:

* **gcpCredentialsPath**: Path to the service account key file

If you prefer to pass the credentials file, you can do so as follows:

```yaml theme={null}
credentials:
  gcpConfig:
    path: <path to file>
```

**3.** Using [ADC authentication](https://cloud.google.com/docs/authentication#adc):

You can use ADC authentication by leaving the GCP credentials empty:

```yaml theme={null}
# ADC authentication with optional billing project
credentials:
  gcpConfig:
    type: gcp_adc
    projectId: ["your-data-project-id"]  # Optional
```

#### GCP Impersonate Service Account

**gcpImpersonateServiceAccount** (Optional): Enable the authenticated service account to impersonate another service account, instead of ingesting directly with the credentials above.

* **impersonateServiceAccount**: The email of the service account to impersonate.
* **lifetime**: Number of seconds the delegated credential should remain valid. Defaults to `3600`.

#### Include Policy Tags

**includePolicyTags** (Optional): Option to include policy tags as part of the column description. Enabled by default.

#### Taxonomy Configuration

**Taxonomy Project ID (Optional)**: BigQuery uses taxonomies to create hierarchical groups of policy tags. To apply access controls to BigQuery columns, tag the columns with policy tags. Learn more about how to create policy tags and set up column-level access control [here](https://cloud.google.com/bigquery/docs/column-level-security)

If you have attached policy tags to the columns of table available in BigQuery, then OpenMetadata will fetch those tags and attach it to the respective columns. In this field you need to specify the id of project in which the taxonomy was created.

**Taxonomy Location (Optional)**: In this field you need to specify the location/region in which the taxonomy was created.

#### Usage Location

**Usage Location (Optional)**: Location used to query `INFORMATION_SCHEMA.JOBS_BY_PROJECT` to fetch usage data. You can pass multi-regions, such as `us` or `eu`, or your specific region such as `us-east1`. Australia and Asia multi-regions are not yet supported.

#### Cost Per TiB

**Cost Per TiB (Optional)**: The cost (in USD) per tebibyte (TiB) of data processed during BigQuery usage analysis. This value is used to estimate query costs when analyzing usage metrics from `INFORMATION_SCHEMA.JOBS_BY_PROJECT`.

This setting does **not** affect actual billing—it is only used for internal reporting and visualization of estimated costs. The default value is \$6.25 per TiB; adjust it according to your organization's negotiated rates or flat-rate pricing model.

#### Connection Options

**Connection Options (Optional)**: Enter the details for any additional connection options that can be sent to database during the connection. These details must be added as Key-Value pairs.

#### Connection Arguments

**Connection Arguments (Optional)**: Enter the details for any additional connection arguments such as security or protocol configs that can be sent to database during the connection. These details must be added as Key-Value pairs.

* In case you are using Single-Sign-On (SSO) for authentication, add the `authenticator` details in the Connection Arguments as a Key-Value pair as follows: `"authenticator" : "sso_login_url"`

#### Source Config

The `sourceConfig` is defined [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/databaseServiceMetadataPipeline.json):

* **markDeletedTables**: To flag tables as soft-deleted if they are not present anymore in the source system.
* **markDeletedStoredProcedures**: Optional configuration to soft delete stored procedures in OpenMetadata if the source stored procedures are deleted. Also, if the stored procedure is deleted, all the associated entities like lineage, etc., with that stored procedure will be deleted.
* **markDeletedSchemas**: Optional configuration to soft delete schemas stored in OpenMetadata if the source schema is deleted. Setting this flag to true will only keep filtered schemas and delete any other schemas that do not match schemaFilterPattern or do not exist at source.
* **markDeletedDatabases**: Additional optional configuration for soft deletion, providing a granular option to select which particular entities should be deleted.
* **includeTables**: Set to `true` or `false` to ingest table data. Default is `true`.
* **includeViews**: Set to `true` or `false` to ingest view definitions.
* **includeTags**: Optional configuration to toggle the tags ingestion.
* **includeOwners**: Set the **Include Owners** toggle to control whether to include owners to the ingested entity if the owner email matches with a user stored in the OM server as part of metadata ingestion. If the ingested entity already exists and has an owner, the owner will not be overwritten.
* **ownerConfig**: Advanced, hierarchical configuration for assigning owners to databases, schemas, and tables during ingestion, with per-entity mappings and inheritance. For more information, see [Hierarchical Owner Configuration](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/hierarchical-owner-configuration).
* **includeStoredProcedures**: Optional configuration to toggle the Stored Procedures ingestion.
* **includeDDL**: Optional configuration to toggle the DDL Statements ingestion.
* **overrideMetadata** *(boolean)*: Set the **Override Metadata** toggle to control whether to override the existing metadata in the OpenMetadata server with the metadata fetched from the source. If the toggle is set to true, the metadata fetched from the source will override the existing metadata in the OpenMetadata server. If the toggle is set to false, the metadata fetched from the source will not override the existing metadata in the OpenMetadata server. This is applicable for fields like description, tags, owner, and displayName.
* **queryLogDuration**: Configuration to tune how far we want to look back in query logs to process Stored Procedures results.
* **queryParsingTimeoutLimit**: Configuration to set the timeout for parsing the query in seconds.
* **useFqnForFiltering**: Regex will be applied on the fully qualified name (for example, `service_name.db_name.schema_name.table_name`) instead of the raw name (for example, `table_name`).
* **databaseFilterPattern**, **schemaFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/filter-patterns/database).
* **tableFilterPattern**: Note that the filter supports regex as include or exclude. You can find examples [here](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/filter-patterns/table).
* **threads (beta)**: The number of threads to use when extracting the metadata using multithreading.
* **databaseMetadataConfigType** *(string)*: Database Source Config Metadata Pipeline type.
* **incremental (beta)**: Incremental Extraction configuration. Currently implemented for [BigQuery](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/bigquery), [Redshift](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/redshift), and [Snowflake](https://docs.open-metadata.org/connectors/ingestion/workflows/metadata/incremental-extraction/snowflake).

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

#### Workflow Configuration

The main property here is `openMetadataServerConfig`, where you can define the host and security provider of your OpenMetadata installation.

* **loggerLevel**: Specify the logger level depending on your needs. If you are troubleshooting an ingestion, use `DEBUG` for more detailed traces.
* **JWT token**: JWT tokens allow clients to authenticate against the OpenMetadata server. See [Enable JWT Tokens](https://docs.open-metadata.org/deployment/security/enable-jwt-tokens) and [JWT Troubleshooting](https://docs.open-metadata.org/deployment/security/jwt-troubleshooting) for more information.
* **storeServiceConnection**: If set to `true` (default), sensitive information is stored encrypted with the Fernet Key or externally if you have configured a [Secrets Manager](https://docs.open-metadata.org/deployment/secrets-manager). If set to `false`, the service is created, but the service connection information is only used by the Ingestion Framework at runtime and is not sent to the OpenMetadata server.
* **SSL configuration**: If you have added SSL to the [OpenMetadata server](https://docs.open-metadata.org/deployment/security/enable-ssl), configure the certificates for ingestion. Set `verifySSL` to `ignore`, or set it to `validate` and provide `sslConfig.caCertificate` with a local path to the server certificate. See [SSL Troubleshooting](https://docs.open-metadata.org/deployment/security/enable-ssl/ssl-troubleshooting) for more information.
* **ingestionPipelineFQN**: Fully qualified name of the ingestion pipeline, used to identify the current ingestion pipeline.

bigquery\_config.yaml
Copy full code

```yaml theme={null}
source:
  type: bigquery
  serviceName: "<service name>"
  serviceConnection:
    config:
      type: BigQuery
      # hostPort: bigquery.googleapis.com
      # billingProjectId: project-id-1
      credentials:
        gcpConfig:
```

```yaml theme={null}
          type: service_account
          projectId: project-id # ["project-id-1", "project-id-2"]
          privateKeyId: abc123
          privateKey: |
            -----BEGIN PRIVATE KEY-----
            Super secret key
            -----END PRIVATE KEY-----
          clientEmail: role@project.iam.gserviceaccount.com
          clientId: "1234"
          # authUri: https://accounts.google.com/o/oauth2/auth (default)
          # tokenUri: https://oauth2.googleapis.com/token (default)
          # authProviderX509CertUrl: https://www.googleapis.com/oauth2/v1/certs (default)
          clientX509CertUrl: https://www.googleapis.com/robot/v1/metadata/x509/role%40project.iam.gserviceaccount.com
```

```yaml theme={null}
        # gcpImpersonateServiceAccount:
        #   impersonateServiceAccount: target-service-account@project.iam.gserviceaccount.com
        #   lifetime: 3600
      # includePolicyTags: true
      # taxonomyProjectID: ["project-id-1", "project-id-2"]
      # taxonomyLocation: us
      # usageLocation: us
      # costPerTB: 5.00
      # connectionOptions:
      #   key: value
      # connectionArguments:
      #   key: value
```

```yaml theme={null}
  sourceConfig:
    config:
      type: DatabaseMetadata
      markDeletedTables: true
      markDeletedStoredProcedures: true
      markDeletedSchemas: true
      markDeletedDatabases: true
      includeTables: true
      includeViews: true
      # includeTags: true
      # includeOwners: false
      # ownerConfig:
      #   default: data-platform-team
      #   database:
      #     database1: owner1
      #   databaseSchema:
      #     database1.schema1: owner1
      #   table:
      #     database1.schema1.table1: owner1
      #   enableInheritance: true
      # includeStoredProcedures: true
      # includeDDL: true
      # overrideMetadata: false
      # queryLogDuration: 1
      # queryParsingTimeoutLimit: 300
      # useFqnForFiltering: false
      # threads: 1
      # databaseMetadataConfigType: ()
      # incremental:
      #   enabled: true
      #   lookbackDays: 7
      #   safetyMarginDays: 1
      # databaseFilterPattern:
      #   includes:
      #     - database1
      #     - database2
      #   excludes:
      #     - database3
      #     - database4
      # schemaFilterPattern:
      #   includes:
      #     - schema1
      #     - schema2
      #   excludes:
      #     - schema3
      #     - schema4
      # tableFilterPattern:
      #   includes:
      #     - users
      #     - type_test
      #   excludes:
      #     - table3
      #     - table4
```

```yaml theme={null}
sink:
  type: metadata-rest
  config: {}
```

```yaml theme={null}
workflowConfig:
  loggerLevel: INFO  # DEBUG, INFO, WARNING or ERROR
  openMetadataServerConfig:
    hostPort: "http://localhost:8585/api"
    authProvider: openmetadata
    securityConfig:
      jwtToken: "{bot_jwt_token}"
    ## Store the service Connection information
    storeServiceConnection: true  # false
    ## Secrets Manager Configuration
    # secretsManagerProvider: aws, azure or noop
    # secretsManagerLoader: airflow or env
    ## If SSL, fill the following
    # verifySSL: validate  # or ignore
    # sslConfig:
    #   caCertificate: /local/path/to/certificate
# ingestionPipelineFQN: <service name>.<ingestion name> ## e.g., "my_redshift.metadata"
```

### 2. Run with the CLI

First, we will need to save the YAML file. Afterward, and with all requirements installed, we can run:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

Note that from connector to connector, this recipe will always be the same. By updating the YAML configuration,
you will be able to extract metadata from different sources.

## Query Usage

The Query Usage workflow will be using the `query-parser` processor.

After running a Metadata Ingestion workflow, we can run Query Usage workflow.
While the `serviceName` will be the same to that was used in Metadata Ingestion, so the ingestion bot can get the `serviceConnection` details from the server.

### 1. Define the YAML Config

This is a sample config for bigquery Usage:

#### Source Configuration

Configure the source type and service name for your usage workflow.

#### Usage Config Type

**type**: Set to `DatabaseUsage` for database usage ingestion.

#### Query Log Duration

**queryLogDuration**: Configuration to tune how far we want to look back in query logs to process usage data (in days).

#### Stage File Location

**stageFileLocation**: Temporary file name to store the query logs before processing. Absolute file path required.

Note that the location is a directory that will be cleaned at the end of the ingestion.

#### Result Limit

**resultLimit**: Configuration to set the limit for query logs.

#### Query Log File Path

**queryLogFilePath**: Configuration to set the file path for query logs. If instead of getting the query logs from the database we want to pass a file with the queries.

#### Processor Configuration

Choose the `query-parser` processor to parse and process the query logs.

#### Stage Configuration

Configure the staging location for table usage data before it's sent to OpenMetadata.

#### Bulk Sink Configuration

Configure the bulk sink for metadata usage ingestion.

\{connector}\_usage.yaml
Copy full code

```yaml theme={null}
source:
  type: bigquery-usage
  serviceName: bigquery
  sourceConfig:
    config:
      type: DatabaseUsage
      # Number of days to look back
      queryLogDuration: 7
      # This is a directory that will be DELETED after the usage runs
      stageFileLocation: <path to store the stage file>
      # resultLimit: 1000
      # If instead of getting the query logs from the database we want to pass a file with the queries
      # queryLogFilePath: path-to-file
processor:
  type: query-parser
  config: {}
stage:
  type: table-usage
  config:
    filename: /tmp/bigquery_usage
bulkSink:
  type: metadata-usage
  config:
    filename: /tmp/bigquery_usage
```

### 2. Run with the CLI

After saving the YAML config, we will run the command the same way we did for the metadata ingestion:

```bash theme={null}
metadata usage -c <path-to-yaml>
```

## Lineage

After running a Metadata Ingestion workflow, we can run Lineage workflow.
While the `serviceName` will be the same to that was used in Metadata Ingestion, so the ingestion bot can get the `serviceConnection` details from the server.

### 1. Define the YAML Config

This is a sample config for bigquery Lineage:

#### Source Configuration

Configure the source type and service name for your lineage workflow.

You can find all the definitions and types for the `sourceConfig` [here](https://github.com/open-metadata/OpenMetadata/blob/main/openmetadata-spec/src/main/resources/json/schema/metadataIngestion/databaseServiceQueryLineagePipeline.json).

#### Lineage Config Type

**type**: Set to `DatabaseLineage` for database lineage ingestion.

#### Query Log Duration

**queryLogDuration**: Configuration to tune how far we want to look back in query logs to process lineage data in days.

#### Parsing Timeout Limit

**parsingTimeoutLimit**: Configuration to set the timeout for parsing the query in seconds.

#### Filter Condition

**filterCondition**: Condition to filter the query history.

#### Result Limit

**resultLimit**: Configuration to set the limit for query logs.

#### Query Log File Path

**queryLogFilePath**: Configuration to set the file path for query logs. If instead of getting the query logs from the database we want to pass a file with the queries.

#### Database Filter Pattern

**databaseFilterPattern**: Regex to only fetch databases that matches the pattern.

#### Schema Filter Pattern

**schemaFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Table Filter Pattern

**tableFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Override View Lineage

**overrideViewLineage**: Set the 'Override View Lineage' toggle to control whether to override the existing view lineage.

#### Process View Lineage

**processViewLineage**: Set the 'Process View Lineage' toggle to control whether to process view lineage.

#### Process Query Lineage

**processQueryLineage**: Set the 'Process Query Lineage' toggle to control whether to process query lineage.

#### Process Stored Procedure Lineage

**processStoredProcedureLineage**: Set the 'Process Stored ProcedureLog Lineage' toggle to control whether to process stored procedure lineage.

#### Threads

**threads**: Number of Threads to use in order to parallelize lineage ingestion.

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

\{connector}\_lineage.yaml
Copy full code

```yaml theme={null}
source:
  type: bigquery-lineage
  serviceName: bigquery
  sourceConfig:
    config:
      type: DatabaseLineage
      # Number of days to look back
      queryLogDuration: 1
      parsingTimeoutLimit: 300
      # filterCondition: query_text not ilike '--- metabase query %'
      resultLimit: 1000
      # If instead of getting the query logs from the database we want to pass a file with the queries
      # queryLogFilePath: /tmp/query_log/file_path
      # databaseFilterPattern:
      #   includes:
      #     - database1
      #     - database2
      #   excludes:
      #     - database3
      # schemaFilterPattern:
      #   includes:
      #     - schema1
      #     - schema2
      #   excludes:
      #     - schema3
      # tableFilterPattern:
      #   includes:
      #     - table1
      #     - table2
      #   excludes:
      #     - table3
      #     - table4
      overrideViewLineage: false
      processViewLineage: true
      processQueryLineage: true
      processStoredProcedureLineage: true
      threads: 1
sink:
  type: metadata-rest
  config: {}
```

* You can learn more about how to configure and run the Lineage Workflow to extract Lineage data from [here](https://docs.open-metadata.org/connectors/ingestion/workflows/lineage)

### 2. Run with the CLI

After saving the YAML config, we will run the command the same way we did for the metadata ingestion:

```bash theme={null}
metadata ingest -c <path-to-yaml>
```

## Data Profiler

The Data Profiler workflow will be using the `orm-profiler` processor.

After running a Metadata Ingestion workflow, we can run the Data Profiler workflow.
While the `serviceName` will be the same to that was used in Metadata Ingestion, so the ingestion bot can get the `serviceConnection` details from the server.

### 1. Define the YAML Config

This is a sample config for the profiler:

#### Source Configuration

Configure the source type and service name for your profiler workflow.

#### Profiler Config Type

**type**: Set to `Profiler` for data profiling ingestion.

#### Profile Sample Config

**profileSampleConfig**: How much data the profiler and tests run on.

* **sampleConfigType**: `DYNAMIC` (default) resolves the sample size at runtime from the table's row count. `STATIC` uses a fixed size you set yourself.
* **config**: the settings for the chosen type. With `DYNAMIC`, `smartSampling: true` applies the built-in tiers. Set it to `false` and provide `thresholds` to define your own. With `STATIC`, set `profileSample`, and optionally `profileSampleType` and `samplingMethodType`.

#### Thread Count

**threadCount**: Number of threads to use during metric computations.

#### Timeout Seconds

**timeoutSeconds**: Profiler Timeout in Seconds.

#### Database Filter Pattern

**databaseFilterPattern**: Regex to only fetch databases that matches the pattern.

#### Schema Filter Pattern

**schemaFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Table Filter Pattern

**tableFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Processor Configuration

Choose the `orm-profiler`. Its config can also be updated to define tests from the YAML itself instead of the UI.

**tableConfig**: `tableConfig` allows you to set up some configuration at the table level including:

* Profile sample settings per table
* Custom profile queries
* Column-level configuration (include/exclude columns, specific metrics)
* Partition configuration for large tables

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

\{connector}\_profiler.yaml
Copy full code

```yaml theme={null}
source:
  type: bigquery
  serviceName: bigquery
  sourceConfig:
    config:
      type: Profiler
      # profileSampleConfig:
      #   sampleConfigType: DYNAMIC  # DYNAMIC (default) or STATIC
      #   config:
      #     smartSampling: true
      # threadCount: 5
      # timeoutSeconds: 43200
      # databaseFilterPattern:
      #   includes:
      #     - database1
      #     - database2
      #   excludes:
      #     - database3
      # schemaFilterPattern:
      #   includes:
      #     - schema1
      #     - schema2
      #   excludes:
      #     - schema3
      # tableFilterPattern:
      #   includes:
      #     - table1
      #     - table2
      #   excludes:
      #     - table3
processor:
  type: orm-profiler
  config: {}  # Remove braces if adding properties
    # tableConfig:
    #   - fullyQualifiedName: <table fqn>
    #     profileSampleConfig:
    #       sampleConfigType: STATIC  # omit entirely to inherit dynamic sampling
    #       config:
    #         profileSample: <number between 0 and 99>
    #     profileQuery: <query to use for sampling data for the profiler>
    #     columnConfig:
    #       excludeColumns:
    #         - <column name>
    #       includeColumns:
    #         - columnName: <column name>
    #         - metrics:
    #           - MEAN
    #           - MEDIAN
    #           - ...
    #     partitionConfig:
    #       enablePartitioning: <set to true to use partitioning>
    #       partitionColumnName: <partition column name>
    #       partitionIntervalType: <TIME-UNIT, INTEGER-RANGE, INGESTION-TIME, COLUMN-VALUE>
    #       Pick one of the variation shown below
    #       ----'TIME-UNIT' or 'INGESTION-TIME'-------
    #       partitionInterval: <partition interval>
    #       partitionIntervalUnit: <YEAR, MONTH, DAY, HOUR>
    #       ------------'INTEGER-RANGE'---------------
    #       partitionIntegerRangeStart: <integer>
    #       partitionIntegerRangeEnd: <integer>
    #       -----------'COLUMN-VALUE'----------------
    #       partitionValues:
    #         - <value>
    #         - <value>
sink:
  type: metadata-rest
  config: {}
```

* You can learn more about how to configure and run the Profiler Workflow to extract Profiler data and execute the Data Quality from [here](https://docs.open-metadata.org/how-to-guides/data-quality-observability/profiler/profiler-workflow)

### 2. Run with the CLI

After saving the YAML config, we will run the command the same way we did for the metadata ingestion:

```bash theme={null}
metadata profile -c <path-to-yaml>
```

Note now instead of running `ingest`, we are using the `profile` command to select the Profiler workflow.

> [card] [Data Profiler](https://docs.open-metadata.org/v2.1.x/how-to-guides/data-quality-observability/profiler/profiler-workflow.md)
>
> Find more information about the Data Profiler here

## Auto Classification

The Auto Classification workflow will be using the `orm-profiler` processor.

After running a Metadata Ingestion workflow, we can run the Auto Classification workflow.
While the `serviceName` will be the same to that was used in Metadata Ingestion, so the ingestion bot can get the `serviceConnection` details from the server.

### 1. Define the YAML Config

This is a sample config for the Auto Classification Workflow:

#### Source Configuration

Configure the source type and service name for your auto classification workflow.

#### Auto Classification Config Type

**type**: Set to `AutoClassification` for automatic PII tagging.

#### Store Sample Data

**storeSampleData**: Option to turn on/off storing sample data. If enabled, we will ingest sample data for each table.

#### Enable Auto Classification

**enableAutoClassification**: Optional configuration to automatically tag columns that might contain sensitive information.

#### Confidence

**confidence**: Set the Confidence value for which you want the column to be tagged as PII. Confidence value ranges from 0 to 100. A higher number will yield less false positives but more false negatives. A lower number will yield more false positives but less false negatives.

#### Database Filter Pattern

**databaseFilterPattern**: Regex to only fetch databases that matches the pattern.

#### Schema Filter Pattern

**schemaFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Table Filter Pattern

**tableFilterPattern**: Regex to only fetch tables or databases that matches the pattern.

#### Processor Configuration

Choose the `orm-profiler`. Its config can also be updated to define tests from the YAML itself instead of the UI.

**tableConfig**: `tableConfig` allows you to set up some configuration at the table level.

#### Sink Configuration

To send the metadata to OpenMetadata, it needs to be specified as `type: metadata-rest`.

\{connector}\_auto\_classification.yaml
Copy full code

```yaml theme={null}
source:
  type: bigquery
  serviceName: bigquery
  sourceConfig:
    config:
      type: AutoClassification
      # storeSampleData: true
      # enableAutoClassification: true
      # confidence: 80
      # databaseFilterPattern:
      #   includes:
      #     - database1
      #     - database2
      #   excludes:
      #     - database3
      # schemaFilterPattern:
      #   includes:
      #     - schema1
      #     - schema2
      #   excludes:
      #     - schema3
      # tableFilterPattern:
      #   includes:
      #     - table1
      #     - table2
      #   excludes:
      #     - table3
processor:
  type: orm-profiler
  config: {}
sink:
  type: metadata-rest
  config: {}
```

### 2. Run with the CLI

After saving the YAML config, we will run the command the same way we did for the metadata ingestion:

```bash theme={null}
metadata classify -c <path-to-yaml>
```

> [!TIP]
>
> Now instead of running `ingest`, we are using the `classify` command to select the Auto Classification workflow.

## Data Quality

### Adding Data Quality Test Cases from yaml config

When creating a JSON config for a test workflow the source configuration is very simple.

```yaml theme={null}
source:
  type: TestSuite
  serviceName: <your_service_name>
  sourceConfig:
    config:
      type: TestSuite
      entityFullyQualifiedName: <entityFqn>
```

The only sections you need to modify here are the `serviceName` (this name needs to be unique) and `entityFullyQualifiedName` (the entity for which we'll be executing tests against) keys.

Once you have defined your source configuration you'll need to define te processor configuration.

```yaml theme={null}
processor:
  type: "orm-test-runner"
  config:
    forceUpdate: <false|true>
    testCases:
      - name: <testCaseName>
        testDefinitionName: columnValueLengthsToBeBetween
        columnName: <columnName>
        parameterValues:
          - name: minLength
            value: 10
          - name: maxLength
            value: 25
      - name: <testCaseName>
        testDefinitionName: tableRowCountToEqual
        parameterValues:
          - name: value
            value: 10
```

The processor type should be set to ` "orm-test-runner"`. For accepted test definition names and parameter value names refer to the [tests page](https://docs.open-metadata.org/how-to-guides/data-quality-observability/quality/tests-yaml).

> [!TIP]
>
> Note that while you can define tests directly in this YAML configuration, running the
> workflow will execute ALL THE TESTS present in the table, regardless of what you are defining in the YAML.
>
> This makes it easy for any user to contribute tests via the UI, while maintaining the test execution external.

You can keep your YAML config as simple as follows if the table already has tests.

```yaml theme={null}
processor:
  type: "orm-test-runner"
  config: {}
```

### Key reference:

* `forceUpdate`: if the test case exists (base on the test case name) for the entity, implements the strategy to follow when running the test (i.e. whether or not to update parameters)
* `testCases`: list of test cases to add to the entity referenced. Note that we will execute all the tests present in the Table.
* `name`: test case name
* `testDefinitionName`: test definition
* `columnName`: only applies to column test. The name of the column to run the test against
* `parameterValues`: parameter values of the test

The `sink` and `workflowConfig` will have the same settings as the ingestion and profiler workflow.

### Full  `yaml` config example

```yaml theme={null}
source:
  type: TestSuite
  serviceName: MyAwesomeTestSuite
  sourceConfig:
    config:
      type: TestSuite
      entityFullyQualifiedName: MySQL.default.openmetadata_db.tag_usage
#     testCases: ["run_only_this_test_case"] # Optional, if not provided all tests will be executed

processor:
  type: "orm-test-runner"
  config:
    forceUpdate: false
    testCases:
      - name: column_value_length_tagFQN
        testDefinitionName: columnValueLengthsToBeBetween
        columnName: tagFQN
        parameterValues:
          - name: minLength
            value: 10
          - name: maxLength
            value: 25
      - name: table_row_count_test
        testDefinitionName: tableRowCountToEqual
        parameterValues:
          - name: value
            value: 10

sink:
  type: metadata-rest
  config: {}
workflowConfig:
  openMetadataServerConfig:
    hostPort: <OpenMetadata host and port>
    authProvider: <OpenMetadata auth provider>
```

### How to Run Tests

To run the tests from the CLI execute the following command

```
metadata test -c /path/to/my/config.yaml
```

## dbt Integration

You can learn more about how to ingest dbt models' definitions and their lineage [here](https://docs.open-metadata.org/v2.1.x/connectors/database/dbt.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.