2

我有一个名为 exampleTable 的两列字符串数组的表。

Array<string> col1  Array<string> col2
["a", "b" , "c" ]       ["x","y","z"]
["aa", "bb" , "cc" ]       ["xx","yy","zz"]

我的目标是制作一张这样的表格

col1                   col2
"a"                     "x"
"b"                     "y"
"c"                     "z"
"aa"                     "xx"
"bb"                     "yy"
"cc"                     "zz"

我想过像这样使用 LATERL VIEW:

SELECT myCol1, myCol2  FROM exampleTable
         LATERAL VIEW explode(col1) myTable1 AS myCol1
         LATERAL VIEW explode(col2) myTable2 AS myCol2;

但这会产生这个

col1                   col2
"a"                     "x"
"a"                     "y"
"a"                     "z"
"a"                     "xx"
"a"                     "yy"
"a"                     "zz"
"b"                     "x"
"b"                     "y"
"b"                     "z"
"b"                     "xx"
"b"                     "yy"
"b"                     "zz"
"c"                     "x"
"c"                     "y"
"c"                     "z"
"c"                     "xx"
"c"                     "yy"
"c"                     "zz"
"aa"                     "x"
"aa"                     "y"
"aa"                     "z"
"aa"                     "xx"
"aa"                     "yy"
"aa"                     "zz"
"bb"                     "x"
"bb"                     "y"
"bb"                     "z"
"bb"                     "xx"
"bb"                     "yy"
"bb"                     "zz"
"cc"                     "x"
"cc"                     "y"
"cc"                     "z"
"cc"                     "xx"
"cc"                     "yy"
"cc"                     "zz"

我该如何解决这个问题?提前致谢。

4

1 回答 1

1

您可以使用explode UDTF 或explode2 UDTF 作为基础来编写UDTF。

请参阅此处了解如何使用 explode2 底座。

于 2013-03-23T14:27:50.563 回答