0
我有一个需要在配置单元中提取的xml。我正在使用配置单元来执行此操作。要求是将一列中的xml存储为字符串。但是,当我这样做时,属性被逆转,因为xpath从下到上填充。我试图让它显示完全和xml一样。似乎配置单元会自动按字母顺序排列属性。Hive Serde Xpath Extract
输入:
<example>
<context>
<field1 b_attribute ="first" a_attribute1 ="second" ></field1>
</context>
</example>
什么我现在越来越:
<example>
<context>
<field1 a_attribute1 ="second" b_attribute ="first" ></field1>
</context>
</example>
预期输出:
<example>
<context>
<field1 b_attribute ="first" a_attribute1 ="second" ></field1>
</context>
</example>
蜂巢SERDE创作:
create external table EXAMPLE (
example_xml string
)
ROW FORMAT SERDE 'com.ibm.spss.hive.serde2.xml.XmlSerDe'
WITH SERDEPROPERTIES (
"column.xpath.example_xml"="reverse(/context/*)"
)
STORED AS
INPUTFORMAT 'com.ibm.spss.hive.serde2.xml.XmlInputFormat'
OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.IgnoreKeyTextOutputFormat'
LOCATION 'mypathinhdfs'
TBLPROPERTIES (
"xmlinput.start"="<example>",
"xmlinput.end"="</example>"
);
我修改了示例XML条目复制的问题。似乎蜂巢按属性排序。 – Defcon