Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在PIG中的JsonLoader中定义架构_Json_Hadoop_Schema_Apache Pig - Fatal编程技术网

在PIG中的JsonLoader中定义架构

在PIG中的JsonLoader中定义架构,json,hadoop,schema,apache-pig,Json,Hadoop,Schema,Apache Pig,在使用JsonLoader从JSON文件中使用Pig时,我试图输入数据集的模式 数据格式如下: { 'cat_a':'some_text', 'cat_b':{(attribute_name):(attribute_value)} } 我试图将模式描述为: LOAD 'filename' USING JsonLoader('cat_a:chararray, cat_b:(attribute_name:chararray,attribute_value:int)'); 我觉得我对cat

在使用JsonLoader从JSON文件中使用Pig时,我试图输入数据集的模式

数据格式如下:

{
  'cat_a':'some_text',
  'cat_b':{(attribute_name):(attribute_value)}
}
我试图将模式描述为:

LOAD 'filename' USING JsonLoader('cat_a:chararray, cat_b:(attribute_name:chararray,attribute_value:int)');
我觉得我对
cat\u b
的模式描述不正确

有人能帮忙吗?
提前感谢。

如果您的json格式为

{"recipe":"Tacos","ingredients":[{"name":"Beef"},{"name":"Lettuce"},{"name":"Cheese"}]}
将上述json存储在
test.json

运行下面的命令

a = LOAD '/home/abhijit/Desktop/test.json' USING JsonLoader('recipe:chararray,ingredients: {(name:chararray)}');

dump a;
您将有如下输出:

(Tacos,{(Beef),(Lettuce),(Cheese)},)
如果您的json格式如下所示

{"recipe":"Tacos","ingredients":[{"name":"Beef"},{"name":"Lettuce"},{"name":"Cheese"}],"inventor":{"name":"Alex","age":25}}

a = LOAD '/home/abhijit/Desktop/test.json' USING JsonLoader('recipe:chararray,ingredients: {(name:chararray)},inventor: (name:chararray, age:int)');


dump a;
产出将是

(Tacos,{(Beef),(Lettuce),(Cheese)},(Alex,25))

这回答了你的问题吗。。。?