我有以下示例数据,并且尝试在 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]]"]

我用下面的查询

从sample2中选择explode(split(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]

在这里有什么帮助吗?

最佳答案

您将数据集设置为array的数组,并且只想在第一级爆炸数据,因此请使用LATERAL VIEW explode(colname)在第一级爆炸。

以下是带有SELECTexplode()查询:

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]

09-11 12:25