Hive json数据爆炸选项不爆炸数组

时间:2017-04-03 09:12:17

标签: arrays json hadoop hive explode

我将Json数据插入Hive。这是格式 -

A1["product":[{"productsku":"p_dmf_qs:click: page load","v2productname":"Quality Score - click: page load","v2productcategory":"DMF","productvariant":"(not set)","productbrand":"xxxx","productrevenue":"1000","localproductrevenue":null,"productprice":"100","productquantity":"1","productrefundamount":null,"productlistname":"(not set)","dim1":[],"dim2":[]}]]

在from table子句中,我使用explode作为:

rake db:migrate

示例数据:

{{1}}

当我在select语句中调用t2和t3为prod_d1和prod_d2时,我在结果中得到一个结构,而不是数组。 请帮我。它是一个嵌套的结构。如果我没有第一个产品阵列,我可以轻松地将其称为A1.dim1和A1.dim2作为两个爆炸功能。请帮助我。

1 个答案:

答案 0 :(得分:0)

class MyTemplateAdmin(admin.ModelAdmin):
    list_display = ('name')
    search_fields = ['name']
    inlines = [some_other_inline]

    def get_inline_instances(self, request, obj=None):
        new_inlines = []
        for inline in (Template, Template2,Template3, ...): # I don't know how you want to get these.
            attrs = {
                'model': MyTemplate,
                # 'extra': 1, Add extra attributes
            }
            # Create a new uninstanciated inline class
            new_inlines.append(type('{}Inline'.format(inline), 
                                      (admin.TabularInline, ), attrs))

        # Add the dynamically created inlines along with the ordinary.
        self.inlines = self.inlines + new_inlines
        return super(CommunityAdmin, self).get_inline_instances(request, obj)