蜂巢中的爆炸功能

explode function in hive

我有以下样本数据,我正试图在配置单元中分解它。我使用了拆分,但我知道我遗漏了一些东西。

["[[-80.742426,35.23248],[-80.740424,35.23184],[-80.739583,35.231562],[-80.735935,35.23041],[-80.728624,35.228069],[-80.727753,35.227836],[-80.727294,35.227741],[-80.726762,35.227647],[-80.726321,35.227594],[-80.725687,35.227544],[-80.725134,35.227535],[-80.721502,35.227615],[-80.691298,35.216202],[-80.688009,35.215396],[-80.686516,35.215016],[-80.598433,35.234307]]"]

我使用了以下查询

select 从样本 2 中分解(拆分(col,','));
结果是这样

        ["[[-80.742426
        35.23248]
        [-80.740424
        35.23184]
        [-80.739583
        35.231562]
        [-80.735935
        35.23041]
        [-80.728624
        35.228069]
        [-80.727753
        35.227836]
        [-80.71143
        35.227831]
        [-80.711007
        35.227795]
        [-80.710638
        35.227741]
        [-80.673884
        35.21014]
        [-80.672358
        35.209481]
        [-80.672036
        35.209356]
        [-80.671686
        35.209234]
        [-80.67124
        35.209099]
        [-80.670815
        35.209006]
        [-80.670267
        35.208906]
        [-80.669612
        35.208833]
        [-80.668924
        35.208806]
        [-80.598433
        35.234307]]"]

我需要以下格式

    [-80.742426,35.23248]
    [-80.740424,35.23184]
    [-80.739583,35.231562]
    [-80.735935,35.23041]
    [-80.728624,35.228069]
    [-80.727753,35.227836]
    [-80.727294,35.227741]
    [-80.726762,35.227647]
    [-80.726321,35.227594]
    [-80.725687,35.227544]
    [-80.725134,35.227535]
    [-80.721502,35.227615]
    [-80.691298,35.216202]
    [-80.688009,35.215396]
    [-80.686516,35.215016]
    [-80.684281,35.214466]
    [-80.68396,35.214395]
    [-80.683375,35.214231]
    [-80.682908,35.214079]
    [-80.682444,35.213905]
    [-80.682045,35.213733]
    [-80.68062,35.213112]
    [-80.678078,35.211983]
    [-80.676836,35.211447]
    [-80.598433,35.234307]

这里有什么帮助吗?

您的数据集为数组的数组,并且只想在第一级分解数据,因此使用 LATERAL VIEW explode(colname) 在第一级分解。

下面是 SELECT 查询 explode():

SELECT col1 FROM sample2 LATERAL VIEW EXPLODE(col) explodeVal AS col1;

从您的输入数据集生成的输出如下:

[-80.742426,35.23248]  
[-80.740424,35.23184]  
[-80.739583,35.231562]  
[-80.735935,35.23041]  
[-80.728624,35.228069]  
[-80.727753,35.227836]  
[-80.727294,35.227741]  
[-80.726762,35.227647]  
[-80.726321,35.227594]  
[-80.725687,35.227544]  
[-80.725134,35.227535]  
[-80.721502,35.227615]  
[-80.691298,35.216202]  
[-80.688009,35.215396]  
[-80.686516,35.215016]  
[-80.684281,35.214466]  
[-80.68396,35.214395]  
[-80.683375,35.214231]  
[-80.682908,35.214079]  
[-80.682444,35.213905]  
[-80.682045,35.213733]  
[-80.68062,35.213112]  
[-80.678078,35.211983]  
[-80.676836,35.211447]  
[-80.598433,35.234307]