如何使用python创建hive ddl

时间:2017-12-08 03:20:12

标签: python json hadoop hive

我最近开始学习蜂巢。我有一个python列表,其中包含以下值

list=['hello:struct', 'env:string', 'element:struct','AppId:string','processId:string'] 

因此,使用上面的值我需要创建一个hive DDL。与此类似。

create table demo

{

hello :struct

<

   env:string,

    element:struct

      <

       AppId:string,

       processId:string

      >

>

formatted b\y..

location..

1 个答案:

答案 0 :(得分:0)

我建议你使用JSON serde。见https://community.hortonworks.com/repos/30883/hive-json-serde.html

你所追求的DDL

CREATE TABLE demo
(
    hello struct 
    <
       env:string,
        element:struct
             <
               AppId:string,
               processId:string
             >
    >
)
ROW FORMAT SERDE 'org.openx.data.jsonserde.JsonSerDe'
LOCATION '/user/hive/demo';