实战指南:用DataHub管理Hive元数据
通过DataHub提取和管理hive元数据
本文由「大千AI助手」原创发布,专注用真话讲AI,回归技术本质。拒绝神话或妖魔化。搜索「大千AI助手」关注我,一起撕掉过度包装,学习真实的AI技术!
简介
- 通过DataHub的Hive数据源连接器可以接入Hive的库、表、列、存储信息、统计信息等元数据
- 哪些元数据
- 库、表的元数据
- 列的类型的元数据
- 详细的表属性和存储的元数据
- 表、行、列的统计信息的元数据(需要SQL Profiling功能)
- DataHub中的功能点
- 资产容器(Asset Containers)
- 描述信息(Descriptions)
- 平台实例(Platform Instance)
- Schema元数据(Schema Metadata)
- 分类(Classification)
- 需要设置
classification.enabled
- 需要设置
- 删除实体检测(Detect Deleted Entities)
- 需要设置
stateful_ingestion.remove_stale_metadata
- 需要设置
- 领域(Domains)
- 需要设置
domain
- 需要设置
- 底层通过Python的
pyhive
库进行提取
往期文章推荐:
- 20.Python3安装MySQL-python踩坑实录:从报错到完美解决的实战指南
- 19.Git可视化革命:3分钟学会用Mermaid+AI画专业分支图
- 18.vscode常用快捷命令和插件
- 17.AI制图新纪元:3分钟用Mermaid画出专业类图
- 16.3分钟搞定数据可视化:Mermaid饼图终极指南
- 15.5分钟玩转Swagger UI:Docker部署+静态化实战
- 14.记录下blog的成长过程
- 13.再说一说LangChain Runnable接口
- 12.Docker实战:5分钟搞定MySQL容器化部署与最佳实践
- 11.Ollama模板全解析:从基础语法到高级应用实战
- 10.Ollama完全指南:从零开始玩转本地大模型部署
- 9.django中如何解析content-type=application/json的请求
- 8.实测DeepSeek分词机制:你的输入如何变成计费Token?
- 7.英语分词进化论:BPE相关论文汇总
- 6.硬核实战 | 3分钟Docker部署ClickHouse列存数据库
- 5.技术深解 | DeepSeek-R1-0528训练参数全透视:163K上下文与MoE高效架构的基石
- 4.DeepSeek最新升级实测:推理能力翻倍,但离世界顶尖还有多远?
- 3.血泪教训!Redis默认配置竟会导致数据丢失?Docker生产部署指南
- 2.Function Call:大模型如何突破自身局限“使用工具“
- 1.DeepSeek动手实践:创建一个自动连点器
配置
基本配置
从哪里取
sqlalchemy_uri
- string, 连接URI. 优先级最高(高于其他连接参数).- 参考 - https://docs.sqlalchemy.org/en/14/core/engines.html#database-urls.
host_port
- string, hive地址和端口, 默认hive:9083
, 腾讯云emr为ip:7001
username
- string, 用户名password
- string(password), 密码options
- map, 该配置都会作为kwargs参数传给SQLAlchemy.create_engine
- 设置URL中的连接参数,可以通过
connect_args
参数指定 - 比如设置认证方式为LDAP,
connect_args: auth: LDAP
- 设置URL中的连接参数,可以通过
取什么
include_tables
- boolean, 是否提取tables的元数据, 默认True
include_views
- boolean, 是否提取views的元数据. 默认True
include_view_lineage
- boolean, 是否自动提取view->view和table->view的血缘关系(通过DataHub的sql parser从view的创建语句中提取). 默认 Trueinclude_column_lineage
- boolean, 是否提取列级血缘关系(从storage中提取), 默认True
include_view_column_lineage
- boolean, 是否自动提取view->view和table->view的列级血缘关系(通过DataHub的sql parser从view的创建语句中提取), 依赖include_view_lineage
, 默认True
emit_storage_lineage
- boolean, 是否生成storage-to-Hive的血缘, 默认False
hive_storage_lineage_direction
- string,upstream
则storage是Hive的上游,downstream
则storage是Hive的下游, 默认upstream
database
- string, database (catalog), 如果不设置则从所有数据库取(可通过database_pattern
过滤)database_pattern
- AllowDenyPattern, 要提取的数据库的正则表达式, 默认{'allow': ['.*'], 'deny': [], 'ignoreCase': True}
database_pattern.ignoreCase
- boolean, 正则匹配时是否忽略大小写, 默认True
database_pattern.allow
- array, 要提取的数据库的正则表达式, 默认['.*']
database_pattern.allow.string
- stringdatabase_pattern.deny
- array, 不提取的数据库的正则表达式, 默认[]
database_pattern.deny.string
- string
table_pattern
- AllowDenyPattern, 要提取的表的正则表达式, 全名匹配database.schema.table
, 默认{'allow': ['.*'], 'deny': [], 'ignoreCase': True}
- 示例
'Customer.public.customer.*'
- 实际验证还是
<database>.<table>
的格式 table_pattern.ignoreCase
- boolean, 正则匹配时是否忽略大小写, 默认True
table_pattern.allow
- array, 要提取的表的正则表达式, 默认['.*']
table_pattern.allow.string
- stringtable_pattern.deny
- array, 不提取的表的正则表达式, 默认[]
table_pattern.deny.string
- string
- 示例
view_pattern
- AllowDenyPattern, 要提取的视图的正则表达式, 全名匹配database.schema.table
, 默认取值同table_pattern
- 示例
'Customer.public.customer.*'
view_pattern.ignoreCase
- boolean, 正则匹配时是否忽略大小写, 默认True
view_pattern.allow
- array, 要提取的视图的正则表达式, 默认['.*']
view_pattern.allow.string
- stringview_pattern.deny
- array, 不提取的视图的正则表达式, 默认[]
view_pattern.deny.string
- string
- 示例
column_pattern
- AllowDenyPattern, 要提取的列的正则表达式, 全名匹配database.schema.table.column
, 默认{'allow': ['.*'], 'deny': [], 'ignoreCase': True}
column_pattern.ignoreCase
- boolean, 正则匹配时是否忽略大小写, 默认True
column_pattern.allow
- Array of string, 要提取的列的正则表达式列表, 默认['.*']
column_pattern.allow.string
- stringcolumn_pattern.deny
- Array of string, 不要提取的列的正则表达式列表, 默认[]
column_pattern.deny.string
- string
profile_pattern
- AllowDenyPattern, 用来提取profile的表或列的正则表达式(与table_pattern
取交集), 默认{'allow': ['.*'], 'deny': [], 'ignoreCase': True}
- 参考datahub-profile
profiling
- profile的配置, 默认{'enabled': False, 'operation_config': {'lower_freq_profile_enabled': False, 'profile_day_of_week': None, 'profile_date_of_month': None}, 'limit': None, 'offset': None, 'profile_table_level_only': False, 'include_field_null_count': True, 'include_field_distinct_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, 'max_workers': 20, 'report_dropped_profiles': False, 'turn_off_expensive_profiling_metrics': False, 'field_sample_values_limit': 20, 'max_number_of_fields_to_profile': None, 'profile_if_updated_since_days': None, 'profile_table_size_limit': 5, 'profile_table_row_limit': 5000000, 'profile_table_row_count_estimate_only': False, 'query_combiner_enabled': True, 'catch_exceptions': True, 'partition_profiling_enabled': True, 'partition_datetime': None, 'use_sampling': True, 'sample_size': 10000, 'profile_external_tables': False, 'tags_to_ignore_sampling': None, 'profile_nested_fields': False}
- 参考datahub-profile
特殊标识
platform_instance
- string, 平台实例(该配置获取的所有资产所属的平台实例)- 参考 - https://datahubproject.io/docs/platform-instances/
storage_platform_instance
- string, storage系统的平台实例env
- string, 环境名(该配置获取的所有资产所属的环境), 默认PROD
- 比如从多个Hive实例获取数据,则可以设置
env
为不同的值
- 比如从多个Hive实例获取数据,则可以设置
domain
- map(str,AllowDenyPattern)- 参考datahub-domain
classification
- ClassificationConfig, 分类信息, 默认{'enabled': False, 'sample_size': 100, 'max_workers': 4, 'table_pattern': {'allow': ['.*'], 'deny': [], 'ignoreCase': True}, 'column_pattern': {'allow': ['.*'], 'deny': [], 'ignoreCase': True}, 'info_type_to_term': {}, 'classifiers': [{'type': 'datahub', 'config': None}]}
- 参考 - https://datahubproject.io/docs/0.15.0/metadata-ingestion/docs/dev_guides/classification/
- 参考datahub-classification
怎么取
incremental_lineage
- boolean, 是否增量更新DataHub中已有的血缘关系, 默认False
convert_urns_to_lowercase
- boolean, 是否转换dataset的urns为全小写, 默认False
use_file_backed_cache
- boolean, 是否对view定义使用基于文件的缓存, 默认 Truestateful_ingestion
- StatefulStaleMetadataRemovalConfig, 提取状态设置stateful_ingestion.enabled
- boolean, 是否有状态的提取,默认如果设置pipeline_name
且指定datahub-rest
或datahub_api
则为True
, 否则False
stateful_ingestion.fail_safe_threshold
- number, 阻止状态改变的阈值(和之前的entity相比如果新提取的entity变化的比例超过该阈值则主动失败), 取值0-100, 默认75.0
stateful_ingestion.remove_stale_metadata
- boolean, 是否软删除上次成功运行提取的有但本次提取没有的实体, 默认True
- 依赖
stateful_ingestion.enabled=True
- 依赖
实例配置
基本配置
source:type: hiveconfig:host_port: localhost:10000database: DemoDatabaseusername: userpassword: pass# For more details on authentication, see the PyHive docs:# https://github.com/dropbox/PyHive#passing-session-configuration.# LDAP, Kerberos, etc. are supported using connect_args, which can be# added under the `options` config parameter.#options:# connect_args:# auth: KERBEROS# kerberos_service_name: hive#scheme: 'hive+http' # set this if Thrift should use the HTTP transport#scheme: 'hive+https' # set this if Thrift should use the HTTP with SSL transport#scheme: 'sparksql' # set this for Spark Thrift Server
参考
- https://datahubproject.io/docs/generated/ingestion/sources/hive/
本文由「大千AI助手」原创发布,专注用真话讲AI,回归技术本质。拒绝神话或妖魔化。搜索「大千AI助手」关注我,一起撕掉过度包装,学习真实的AI技术!