如何查询以选择Impala中数据框内结构列数组的结构?

问题描述

我将如何查询选择在“数据包”列中的“细节”数组中的length(int)?希望所附图片能比我更好地解释!

我尝试了SELECT packets.details.length FROM test.ssh_data,该方法不起作用。

这给了我以下错误

illegal column/field reference 'packets.details.length' with intermediate collection 'details' of type 'ARRAY<STRUCT<datestamp:STRING,length:INT>>

提前谢谢!

description of test.test_data

解决方法

在Impala嵌套类型支持中,将数组和映射视为嵌套表。您需要在FROM子句中引用它们以取消嵌套。在这种情况下,您可以将数组添加到from子句中,请小心通过sd引用该数组,该数组是其内部表的别名。例如

SELECT d.length FROM test.ssh_data sd,sd.packets.details d