MySQL
Module mysql
Important Capabilities
Capability | Status | Notes |
---|---|---|
Data Profiling | ✅ | Optionally enabled via configuration |
Detect Deleted Entities | ✅ | Enabled via stateful ingestion |
Domains | ✅ | Supported via the domain config field |
Platform Instance | ✅ | Enabled by default |
This plugin extracts the following:
Metadata for databases, schemas, and tables Column types and schema associated with each table Table, row, and column statistics via optional SQL profiling
Install the Plugin
pip install 'acryl-datahub[mysql]'
Quickstart Recipe
Check out the following recipe to get started with ingestion! See below for full configuration options.
For general pointers on writing and running a recipe, see our main recipe guide
source:
type: mysql
config:
# Coordinates
host_port: localhost:3306
database: dbname
# Credentials
username: root
password: example
sink:
# sink configs
Config Details
- Options
- Schema
Note that a .
is used to denote nested fields in the YAML recipe.
View All Configuration Options
Field | Required | Type | Description | Default |
---|---|---|---|---|
env | string | The environment that all assets produced by this connector belong to | PROD | |
platform | string | The platform that this source connects to | None | |
platform_instance | string | The instance of the platform that all assets produced by this recipe belong to | None | |
options | Dict | {} | ||
include_views | boolean | Whether views should be ingested. | True | |
include_tables | boolean | Whether tables should be ingested. | True | |
username | string | username | None | |
password | string | password | None | |
host_port | string | MySQL host URL. | localhost:3306 | |
database | string | database (catalog) | None | |
database_alias | string | Alias to apply to database when ingesting. | None | |
scheme | string | mysql+pymysql | ||
sqlalchemy_uri | string | URI of database to connect to. See https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls. Takes precedence over other connection parameters. | None | |
stateful_ingestion | SQLAlchemyStatefulIngestionConfig (see below for fields) | |||
stateful_ingestion.enabled | boolean | The type of the ingestion state provider registered with datahub. | False | |
stateful_ingestion.max_checkpoint_state_size | integer | The maximum size of the checkpoint state in bytes. Default is 16MB | 16777216 | |
stateful_ingestion.state_provider | DynamicTypedStateProviderConfig (see below for fields) | The ingestion state provider configuration. | ||
stateful_ingestion.state_provider.type | ✅ | string | The type of the state provider to use. For DataHub use datahub | None |
stateful_ingestion.state_provider.config | Generic dict | The configuration required for initializing the state provider. Default: The datahub_api config if set at pipeline level. Otherwise, the default DatahubClientConfig. See the defaults (https://github.com/datahub-project/datahub/blob/master/metadata-ingestion/src/datahub/ingestion/graph/client.py#L19). | None | |
stateful_ingestion.ignore_old_state | boolean | If set to True, ignores the previous checkpoint state. | False | |
stateful_ingestion.ignore_new_state | boolean | If set to True, ignores the current checkpoint state. | False | |
stateful_ingestion.remove_stale_metadata | boolean | Soft-deletes the tables and views that were found in the last successful run but missing in the current run with stateful_ingestion enabled. | True | |
schema_pattern | AllowDenyPattern (see below for fields) | regex patterns for schemas to filter in ingestion. | {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 _.-]'} | |
schema_pattern.allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
schema_pattern.deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
schema_pattern.ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
schema_pattern.alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
table_pattern | AllowDenyPattern (see below for fields) | regex patterns for tables to filter in ingestion. | {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 _.-]'} | |
table_pattern.allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
table_pattern.deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
table_pattern.ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
table_pattern.alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
view_pattern | AllowDenyPattern (see below for fields) | regex patterns for views to filter in ingestion. | {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 _.-]'} | |
view_pattern.allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
view_pattern.deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
view_pattern.ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
view_pattern.alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
profile_pattern | AllowDenyPattern (see below for fields) | regex patterns for profiles to filter in ingestion, allowed by the table_pattern . | {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 _.-]'} | |
profile_pattern.allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
profile_pattern.deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
profile_pattern.ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
profile_pattern.alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
domain | Dict[str, AllowDenyPattern] | regex patterns for tables/schemas to descide domain_key domain key (domain_key can be any string like "sales".) There can be multiple domain key specified. | {} | |
domain.key .allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
domain.key .deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
domain.key .ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
domain.key .alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
profiling | GEProfilingConfig (see below for fields) | {'enabled': False, 'limit': None, 'offset': None, 'reportdropped_profiles': False, 'turn_off_expensive_profiling_metrics': False, 'profile_table_level_only': False, 'include_field_null_count': True, 'include_field_min_value': True, 'include_field_max_value': True, 'include_field_mean_value': True, 'include_field_median_value': True, 'include_field_stddev_value': True, 'include_field_quantiles': False, 'include_field_distinct_value_frequencies': False, 'include_field_histogram': False, 'include_field_sample_values': True, 'allow_deny_patterns': {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 .-]'}, 'max_number_of_fields_to_profile': None, 'profile_if_updated_since_days': 1, 'max_workers': 10, 'query_combiner_enabled': True, 'catch_exceptions': True, 'partition_profiling_enabled': True, 'bigquery_temp_table_schema': None, 'partition_datetime': None} | ||
profiling.enabled | boolean | Whether profiling should be done. | False | |
profiling.limit | integer | Max number of documents to profile. By default, profiles all documents. | None | |
profiling.offset | integer | Offset in documents to profile. By default, uses no offset. | None | |
profiling.report_dropped_profiles | boolean | If datasets which were not profiled are reported in source report or not. Set to True for debugging purposes. | False | |
profiling.turn_off_expensive_profiling_metrics | boolean | Whether to turn off expensive profiling or not. This turns off profiling for quantiles, distinct_value_frequencies, histogram & sample_values. This also limits maximum number of fields being profiled to 10. | False | |
profiling.profile_table_level_only | boolean | Whether to perform profiling at table-level only, or include column-level profiling as well. | False | |
profiling.include_field_null_count | boolean | Whether to profile for the number of nulls for each column. | True | |
profiling.include_field_min_value | boolean | Whether to profile for the min value of numeric columns. | True | |
profiling.include_field_max_value | boolean | Whether to profile for the max value of numeric columns. | True | |
profiling.include_field_mean_value | boolean | Whether to profile for the mean value of numeric columns. | True | |
profiling.include_field_median_value | boolean | Whether to profile for the median value of numeric columns. | True | |
profiling.include_field_stddev_value | boolean | Whether to profile for the standard deviation of numeric columns. | True | |
profiling.include_field_quantiles | boolean | Whether to profile for the quantiles of numeric columns. | False | |
profiling.include_field_distinct_value_frequencies | boolean | Whether to profile for distinct value frequencies. | False | |
profiling.include_field_histogram | boolean | Whether to profile for the histogram for numeric fields. | False | |
profiling.include_field_sample_values | boolean | Whether to profile for the sample values for all columns. | True | |
profiling.allow_deny_patterns | AllowDenyPattern (see below for fields) | regex patterns for filtering of tables or table columns to profile. | {'allow': ['.*'], 'deny': [], 'ignoreCase': True, 'alphabet': '[A-Za-z0-9 _.-]'} | |
profiling.allow_deny_patterns.allow | Array of string | List of regex patterns for process groups to include in ingestion | ['.*'] | |
profiling.allow_deny_patterns.deny | Array of string | List of regex patterns for process groups to exclude from ingestion. | [] | |
profiling.allow_deny_patterns.ignoreCase | boolean | Whether to ignore case sensitivity during pattern matching. | True | |
profiling.allow_deny_patterns.alphabet | string | Allowed alphabets pattern | [A-Za-z0-9 _.-] | |
profiling.max_number_of_fields_to_profile | integer | A positive integer that specifies the maximum number of columns to profile for any table. None implies all columns. The cost of profiling goes up significantly as the number of columns to profile goes up. | None | |
profiling.profile_if_updated_since_days | number | Profile table only if it has been updated since these many number of days. None implies profile all tables. Only Snowflake supports this. | 1 | |
profiling.max_workers | integer | Number of worker threads to use for profiling. Set to 1 to disable. | 10 | |
profiling.query_combiner_enabled | boolean | This feature is still experimental and can be disabled if it causes issues. Reduces the total number of queries issued and speeds up profiling by dynamically combining SQL queries where possible. | True | |
profiling.catch_exceptions | boolean | True | ||
profiling.partition_profiling_enabled | boolean | True | ||
profiling.bigquery_temp_table_schema | string | On bigquery for profiling partitioned tables needs to create temporary views. You have to define a dataset where these will be created. Views will be cleaned up after profiler runs. (Great expectation tech details about this (https://legacy.docs.greatexpectations.io/en/0.9.0/reference/integrations/bigquery.html#custom-queries-with-sql-datasource). | None | |
profiling.partition_datetime | string | For partitioned datasets profile only the partition which matches the datetime or profile the latest one if not set. Only Bigquery supports this. | None |
The JSONSchema for this configuration is inlined below.
{
"title": "MySQLConfig",
"description": "Base configuration class for stateful ingestion for source configs to inherit from.",
"type": "object",
"properties": {
"env": {
"title": "Env",
"description": "The environment that all assets produced by this connector belong to",
"default": "PROD",
"type": "string"
},
"platform": {
"title": "Platform",
"description": "The platform that this source connects to",
"type": "string"
},
"platform_instance": {
"title": "Platform Instance",
"description": "The instance of the platform that all assets produced by this recipe belong to",
"type": "string"
},
"stateful_ingestion": {
"$ref": "#/definitions/SQLAlchemyStatefulIngestionConfig"
},
"options": {
"title": "Options",
"default": {},
"type": "object"
},
"schema_pattern": {
"title": "Schema Pattern",
"description": "regex patterns for schemas to filter in ingestion.",
"default": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"allOf": [
{
"$ref": "#/definitions/AllowDenyPattern"
}
]
},
"table_pattern": {
"title": "Table Pattern",
"description": "regex patterns for tables to filter in ingestion.",
"default": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"allOf": [
{
"$ref": "#/definitions/AllowDenyPattern"
}
]
},
"view_pattern": {
"title": "View Pattern",
"description": "regex patterns for views to filter in ingestion.",
"default": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"allOf": [
{
"$ref": "#/definitions/AllowDenyPattern"
}
]
},
"profile_pattern": {
"title": "Profile Pattern",
"description": "regex patterns for profiles to filter in ingestion, allowed by the `table_pattern`.",
"default": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"allOf": [
{
"$ref": "#/definitions/AllowDenyPattern"
}
]
},
"domain": {
"title": "Domain",
"description": " regex patterns for tables/schemas to descide domain_key domain key (domain_key can be any string like \"sales\".) There can be multiple domain key specified.",
"default": {},
"type": "object",
"additionalProperties": {
"$ref": "#/definitions/AllowDenyPattern"
}
},
"include_views": {
"title": "Include Views",
"description": "Whether views should be ingested.",
"default": true,
"type": "boolean"
},
"include_tables": {
"title": "Include Tables",
"description": "Whether tables should be ingested.",
"default": true,
"type": "boolean"
},
"profiling": {
"title": "Profiling",
"default": {
"enabled": false,
"limit": null,
"offset": null,
"report_dropped_profiles": false,
"turn_off_expensive_profiling_metrics": false,
"profile_table_level_only": false,
"include_field_null_count": true,
"include_field_min_value": true,
"include_field_max_value": true,
"include_field_mean_value": true,
"include_field_median_value": true,
"include_field_stddev_value": true,
"include_field_quantiles": false,
"include_field_distinct_value_frequencies": false,
"include_field_histogram": false,
"include_field_sample_values": true,
"allow_deny_patterns": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"max_number_of_fields_to_profile": null,
"profile_if_updated_since_days": 1,
"max_workers": 10,
"query_combiner_enabled": true,
"catch_exceptions": true,
"partition_profiling_enabled": true,
"bigquery_temp_table_schema": null,
"partition_datetime": null
},
"allOf": [
{
"$ref": "#/definitions/GEProfilingConfig"
}
]
},
"username": {
"title": "Username",
"description": "username",
"type": "string"
},
"password": {
"title": "Password",
"description": "password",
"type": "string",
"writeOnly": true,
"format": "password"
},
"host_port": {
"title": "Host Port",
"description": "MySQL host URL.",
"default": "localhost:3306",
"type": "string"
},
"database": {
"title": "Database",
"description": "database (catalog)",
"type": "string"
},
"database_alias": {
"title": "Database Alias",
"description": "Alias to apply to database when ingesting.",
"type": "string"
},
"scheme": {
"title": "Scheme",
"default": "mysql+pymysql",
"type": "string"
},
"sqlalchemy_uri": {
"title": "Sqlalchemy Uri",
"description": "URI of database to connect to. See https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls. Takes precedence over other connection parameters.",
"type": "string"
}
},
"additionalProperties": false,
"definitions": {
"DynamicTypedStateProviderConfig": {
"title": "DynamicTypedStateProviderConfig",
"type": "object",
"properties": {
"type": {
"title": "Type",
"description": "The type of the state provider to use. For DataHub use `datahub`",
"type": "string"
},
"config": {
"title": "Config",
"description": "The configuration required for initializing the state provider. Default: The datahub_api config if set at pipeline level. Otherwise, the default DatahubClientConfig. See the defaults (https://github.com/datahub-project/datahub/blob/master/metadata-ingestion/src/datahub/ingestion/graph/client.py#L19)."
}
},
"required": [
"type"
],
"additionalProperties": false
},
"SQLAlchemyStatefulIngestionConfig": {
"title": "SQLAlchemyStatefulIngestionConfig",
"description": "Specialization of basic StatefulIngestionConfig to adding custom config.\nThis will be used to override the stateful_ingestion config param of StatefulIngestionConfigBase\nin the SQLAlchemyConfig.",
"type": "object",
"properties": {
"enabled": {
"title": "Enabled",
"description": "The type of the ingestion state provider registered with datahub.",
"default": false,
"type": "boolean"
},
"max_checkpoint_state_size": {
"title": "Max Checkpoint State Size",
"description": "The maximum size of the checkpoint state in bytes. Default is 16MB",
"default": 16777216,
"exclusiveMinimum": 0,
"type": "integer"
},
"state_provider": {
"title": "State Provider",
"description": "The ingestion state provider configuration.",
"allOf": [
{
"$ref": "#/definitions/DynamicTypedStateProviderConfig"
}
]
},
"ignore_old_state": {
"title": "Ignore Old State",
"description": "If set to True, ignores the previous checkpoint state.",
"default": false,
"type": "boolean"
},
"ignore_new_state": {
"title": "Ignore New State",
"description": "If set to True, ignores the current checkpoint state.",
"default": false,
"type": "boolean"
},
"remove_stale_metadata": {
"title": "Remove Stale Metadata",
"description": "Soft-deletes the tables and views that were found in the last successful run but missing in the current run with stateful_ingestion enabled.",
"default": true,
"type": "boolean"
}
},
"additionalProperties": false
},
"AllowDenyPattern": {
"title": "AllowDenyPattern",
"description": "A class to store allow deny regexes",
"type": "object",
"properties": {
"allow": {
"title": "Allow",
"description": "List of regex patterns for process groups to include in ingestion",
"default": [
".*"
],
"type": "array",
"items": {
"type": "string"
}
},
"deny": {
"title": "Deny",
"description": "List of regex patterns for process groups to exclude from ingestion.",
"default": [],
"type": "array",
"items": {
"type": "string"
}
},
"ignoreCase": {
"title": "Ignorecase",
"description": "Whether to ignore case sensitivity during pattern matching.",
"default": true,
"type": "boolean"
},
"alphabet": {
"title": "Alphabet",
"description": "Allowed alphabets pattern",
"default": "[A-Za-z0-9 _.-]",
"type": "string"
}
},
"additionalProperties": false
},
"GEProfilingConfig": {
"title": "GEProfilingConfig",
"type": "object",
"properties": {
"enabled": {
"title": "Enabled",
"description": "Whether profiling should be done.",
"default": false,
"type": "boolean"
},
"limit": {
"title": "Limit",
"description": "Max number of documents to profile. By default, profiles all documents.",
"type": "integer"
},
"offset": {
"title": "Offset",
"description": "Offset in documents to profile. By default, uses no offset.",
"type": "integer"
},
"report_dropped_profiles": {
"title": "Report Dropped Profiles",
"description": "If datasets which were not profiled are reported in source report or not. Set to `True` for debugging purposes.",
"default": false,
"type": "boolean"
},
"turn_off_expensive_profiling_metrics": {
"title": "Turn Off Expensive Profiling Metrics",
"description": "Whether to turn off expensive profiling or not. This turns off profiling for quantiles, distinct_value_frequencies, histogram & sample_values. This also limits maximum number of fields being profiled to 10.",
"default": false,
"type": "boolean"
},
"profile_table_level_only": {
"title": "Profile Table Level Only",
"description": "Whether to perform profiling at table-level only, or include column-level profiling as well.",
"default": false,
"type": "boolean"
},
"include_field_null_count": {
"title": "Include Field Null Count",
"description": "Whether to profile for the number of nulls for each column.",
"default": true,
"type": "boolean"
},
"include_field_min_value": {
"title": "Include Field Min Value",
"description": "Whether to profile for the min value of numeric columns.",
"default": true,
"type": "boolean"
},
"include_field_max_value": {
"title": "Include Field Max Value",
"description": "Whether to profile for the max value of numeric columns.",
"default": true,
"type": "boolean"
},
"include_field_mean_value": {
"title": "Include Field Mean Value",
"description": "Whether to profile for the mean value of numeric columns.",
"default": true,
"type": "boolean"
},
"include_field_median_value": {
"title": "Include Field Median Value",
"description": "Whether to profile for the median value of numeric columns.",
"default": true,
"type": "boolean"
},
"include_field_stddev_value": {
"title": "Include Field Stddev Value",
"description": "Whether to profile for the standard deviation of numeric columns.",
"default": true,
"type": "boolean"
},
"include_field_quantiles": {
"title": "Include Field Quantiles",
"description": "Whether to profile for the quantiles of numeric columns.",
"default": false,
"type": "boolean"
},
"include_field_distinct_value_frequencies": {
"title": "Include Field Distinct Value Frequencies",
"description": "Whether to profile for distinct value frequencies.",
"default": false,
"type": "boolean"
},
"include_field_histogram": {
"title": "Include Field Histogram",
"description": "Whether to profile for the histogram for numeric fields.",
"default": false,
"type": "boolean"
},
"include_field_sample_values": {
"title": "Include Field Sample Values",
"description": "Whether to profile for the sample values for all columns.",
"default": true,
"type": "boolean"
},
"allow_deny_patterns": {
"title": "Allow Deny Patterns",
"description": "regex patterns for filtering of tables or table columns to profile.",
"default": {
"allow": [
".*"
],
"deny": [],
"ignoreCase": true,
"alphabet": "[A-Za-z0-9 _.-]"
},
"allOf": [
{
"$ref": "#/definitions/AllowDenyPattern"
}
]
},
"max_number_of_fields_to_profile": {
"title": "Max Number Of Fields To Profile",
"description": "A positive integer that specifies the maximum number of columns to profile for any table. `None` implies all columns. The cost of profiling goes up significantly as the number of columns to profile goes up.",
"exclusiveMinimum": 0,
"type": "integer"
},
"profile_if_updated_since_days": {
"title": "Profile If Updated Since Days",
"description": "Profile table only if it has been updated since these many number of days. `None` implies profile all tables. Only Snowflake supports this.",
"default": 1,
"exclusiveMinimum": 0,
"type": "number"
},
"max_workers": {
"title": "Max Workers",
"description": "Number of worker threads to use for profiling. Set to 1 to disable.",
"default": 10,
"type": "integer"
},
"query_combiner_enabled": {
"title": "Query Combiner Enabled",
"description": "*This feature is still experimental and can be disabled if it causes issues.* Reduces the total number of queries issued and speeds up profiling by dynamically combining SQL queries where possible.",
"default": true,
"type": "boolean"
},
"catch_exceptions": {
"title": "Catch Exceptions",
"default": true,
"type": "boolean"
},
"partition_profiling_enabled": {
"title": "Partition Profiling Enabled",
"default": true,
"type": "boolean"
},
"bigquery_temp_table_schema": {
"title": "Bigquery Temp Table Schema",
"description": "On bigquery for profiling partitioned tables needs to create temporary views. You have to define a dataset where these will be created. Views will be cleaned up after profiler runs. (Great expectation tech details about this (https://legacy.docs.greatexpectations.io/en/0.9.0/reference/integrations/bigquery.html#custom-queries-with-sql-datasource).",
"type": "string"
},
"partition_datetime": {
"title": "Partition Datetime",
"description": "For partitioned datasets profile only the partition which matches the datetime or profile the latest one if not set. Only Bigquery supports this.",
"type": "string",
"format": "date-time"
}
},
"additionalProperties": false
}
}
}
Prerequisites
In order to execute this source the user credentials needs the following privileges
grant select on DATABASE.* to 'USERNAME'@'%'
grant show view on DATABASE.* to 'USERNAME'@'%'
select
is required to see the table structure as well as for profiling.
Code Coordinates
- Class Name:
datahub.ingestion.source.sql.mysql.MySQLSource
- Browse on GitHub
Questions
If you've got any questions on configuring ingestion for MySQL, feel free to ping us on our Slack