gpt4 book ai didi

hadoop - pig-avro : how to customize the way, avrostorage 加载文件

转载 作者:可可西里 更新时间:2023-11-01 14:54:10 25 4
gpt4 key购买 nike

我有一个要求,我们需要自定义使用 avrostorage 在 pig 中加载文件的方式:

例如,我有一个具有以下架构的 avro 文件:

{"namespace": "avroColorCount",
"type": "record",
"name": "User2",
"fields": [
{"name": "name", "type": "string"},
{"name": "content", "type" : "bytes" }
]
}

现在如果我使用下面的命令它工作正常:

x = load 'sample.avro' USING AvroStorage() AS (name: chararray, content: bytearray);

但是,如果我只想加载“内容”(第二列),我该怎么做呢?

如果我给,

x = load 'sample.avro' USING AvroStorage() AS (content: bytearray);

它给我错误:

ERROR 1031: Incompatable schema: left is "content:bytearray", right is "name: chararray, content: bytearray"

我知道这可以通过 FILTER 完成。

但我们的要求是在一个步骤中单独获取第二列。

这可能吗?

提前致谢...

最佳答案

下面的代码解决了..

x = LOAD 'sample.avro' USING AvroStorage('{"type":"record","name":"User2","fields":[{"name":"content","type":"bytearray"}]}');

关于hadoop - pig-avro : how to customize the way, avrostorage 加载文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22325730/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com