Skip to main content

TiDB Profile

Vendor-supported plugin

Some core functionality may be limited. If you're interested in contributing, check out the source code repository listed below.

Overview of dbt-tidb​

Maintained by: PingCAP
Author: Xiang Zhang, Qiang Wu, Yuhang Shi
dbt Slack Channel: #db-tidb
Source: Github
Core version: v1.0.0 and newer
dbt Cloud: Not Supported

The easiest way to install it is to use pip:

pip install dbt-tidb

Connecting to TiDB with dbt-tidb​

User / Password Authentication​

Configure your dbt profile for using TiDB:

TiDB connection profile​
profiles.yml
dbt-tidb:
target: dev
outputs:
dev:
type: tidb
server: 127.0.0.1
port: 4000
schema: database_name
username: tidb_username
password: tidb_password

# optional
retries: 3 # default 1
Description of Profile Fields​
OptionDescriptionRequired?Example
typeThe specific adapter to useRequiredtidb
serverThe server (hostname) to connect toRequiredyourorg.tidb.com
portThe port to useRequired4000
schemaSpecify the schema (database) to build models intoRequiredanalytics
usernameThe username to use to connect to the serverRequireddbt_admin
passwordThe password to use for authenticating to the serverRequiredawesome_password
retriesThe retry times after an unsuccessful connectionOptionaldefault 1

Database User Privileges​

Your database user would be able to have some abilities to read or write, such as SELECT, CREATE, and so on. You can find some help here with TiDB privileges management.

Required Privilege
SELECT
CREATE
CREATE TEMPORARY TABLE
CREATE VIEW
INSERT
DROP
SHOW DATABASE
SHOW VIEW
SUPER

Supported features​

TiDB 4.XTiDB 5.0 ~ 5.2TiDB >= 5.3Feature
βœ…βœ…βœ…Table materialization
βœ…βœ…βœ…View materialization
βŒβŒβœ…Incremental materialization
βŒβœ…βœ…Ephemeral materialization
βœ…βœ…βœ…Seeds
βœ…βœ…βœ…Sources
βœ…βœ…βœ…Custom data tests
βœ…βœ…βœ…Docs generate
βŒβŒβœ…Snapshots
βœ…βœ…βœ…Grant
βœ…βœ…βœ…Connection retry

Note:

  • TiDB 4.0 ~ 5.0 does not support CTE, you should avoid using WITH in your SQL code.
  • TiDB 4.0 ~ 5.2 does not support creating a temporary table or view.
  • TiDB 4.X does not support using SQL func in CREATE VIEW, avoid it in your SQL code. You can find more detail here.