赞
踩
执行下面sql即可
-- 查看hive里表和字段字典信息 -- 如果是用create table 的方式建的表,这里是查不到的。 -- 建的表必须要有表注释,否则查不出来。 select d.name as db_name -- 数据库名 ,c.tbl_name -- 表名 ,e.param_value as tbl_name_desc -- 表中文注释 ,a.integer_idx as column_seq -- 表列序列 ,a.column_name -- 列名 ,a.type_name as column_type -- 列数据类型 ,a.COMMENT as column_desc -- 列中文注释 from columns_v2 a inner join sds b on a.cd_id=b.cd_id inner join tbls c on b.sd_id=c.sd_id inner join dbs d on c.db_id=d.db_id inner join table_params e on c.tbl_id=e.tbl_id where e.param_key='comment' and d.name in ( 'dm_estate_hr' ,'dm_estate_mk' ,'dm_estate_ce' ,'dm_estate_ct' ,'dm_estate_de' ,'dm_estate_co' ,'dm_estate_fi' ,'dm_pub' ,'dm_estate') -- 库名列表 and a.COMMENT like '%目的%' order by d.name,c.tbl_name,a.integer_idx;
pd的版本是16.7
一、从hive导出建表脚本(hive 脚本!!)
1.从平台导出建表语句
(1)show create db.table_name 一定要带上数据库名!!!
(2)可以把多个表的建表语句放在一个文档里,用分号隔开
二、格式化建表语句:将符号 ` 去掉
三、文件类型保存为.sql
四、导入到PD模型
1.反向工程导入
2.将字段的comment复制到name列
comment2name.vbs 代码如何下 Option Explicit ValidationMode = True
InteractiveMode = im_Batch Dim mdl ’ the current model
’ get the current active model Set mdl = ActiveModel
If (mdl Is Nothing) Then MsgBox “There is no
current Model " ElseIf Not mdl.IsKindOf(PdPDM.cls_Model) Then
MsgBox “The current model is not an Physical Data
model. " Else ProcessFolder mdl End If Private sub
ProcessFolder(folder) On Error Resume Next Dim Tab 'running
table for each Tab in folder.tables if not
tab.isShortcut then tab.name = tab.comment Dim col ’
running column for each col in tab.columns if
col.comment=”” then else col.name= col.comment end if next
end if next
Dim view 'running view for each view in folder.Views if not view.isShortcut then view.name =
view.comment end if next
’ go into the sub-packages Dim f ’ running folder For Each f In folder.Packages if not
f.IsShortcut then ProcessFolder f end if Next end sub
3.将表的name调回code
五.排版分层,建依赖
1.全选需要调整颜色的数仓层
六、生成pdm文件,然后导入到PDMReader中即可
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。