您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

mysql表结构转hive表结构,字段映射脚本

bubuko 2022/1/25 20:06:29 mysql 字数 5344 阅读 881 来源 http://www.bubuko.com/infolist-5-1.html

按照以下脚本执行,导出txt文件即可得到相应的hive字段映射。 select concat('`', column_name, '`') colname, case when NUMERIC_PRECISION is not null and (data_type = 'decimal' or d ...

按照以下脚本执行,导出txt文件即可得到相应的hive字段映射。

select concat(`, column_name, `) colname,
       case
         when NUMERIC_PRECISION is not null and
              (data_type = decimal or data_type = numeric) then
          concat(decimal(, NUMERIC_PRECISION, ,, NUMERIC_SCALE, ))
         when (CHARACTER_MAXIMUM_LENGTH is not null or
              data_type = uniqueidentifier) and
              data_type not like %text% then
          string
         when data_type = datetime then
          timestamp
         when data_type = money then
          decimal(9,2)
         when data_type = tinyint then
          int
         else
          data_type
       end as data_type,
       concat(comment,  \‘‘,COLUMN_COMMENT, ‘‘) as comment,
        , as splitCharacter
  from information_schema.columns
 where table_name = xxxxxxxxxx

 

mysql表结构转hive表结构,字段映射脚本

原文:https://www.cnblogs.com/lianshan/p/12463980.html


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶