Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/15.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
配置单元为JSON创建表-结构错误_Json_Hadoop_Hive - Fatal编程技术网

配置单元为JSON创建表-结构错误

配置单元为JSON创建表-结构错误,json,hadoop,hive,Json,Hadoop,Hive,我正在尝试将JSON数据加载到配置单元。我正在使用配置单元中的默认服务器。我在创建表的过程中遇到错误。需要帮助 JSON数据: {"widget": { "debug": "on", "window": { "title": "Sample Konfabulator Widget", "name": "main_window", "width": 500, "height": 500 }, "imag

我正在尝试将JSON数据加载到配置单元。我正在使用配置单元中的默认服务器。我在创建表的过程中遇到错误。需要帮助

JSON数据:

{"widget": {
    "debug": "on",
    "window": {
        "title": "Sample Konfabulator Widget",
        "name": "main_window",
        "width": 500,
        "height": 500
    },
    "image": { 
        "src": "Images/Sun.png",
        "name": "sun1",
        "hOffset": 250,
        "vOffset": 250,
        "alignment": "center"
    }
}}
CREATE TABLE complex_json(
widget struct<window:struct< title:string,name:string,width:int,height:int>,
debug:string,
image:struct< src:string,name:string,hOffset:int,vOffset:int,alignment:string > >
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe';
创建语句:

{"widget": {
    "debug": "on",
    "window": {
        "title": "Sample Konfabulator Widget",
        "name": "main_window",
        "width": 500,
        "height": 500
    },
    "image": { 
        "src": "Images/Sun.png",
        "name": "sun1",
        "hOffset": 250,
        "vOffset": 250,
        "alignment": "center"
    }
}}
CREATE TABLE complex_json(
widget struct<window:struct< title:string,name:string,width:int,height:int>,
debug:string,
image:struct< src:string,name:string,hOffset:int,vOffset:int,alignment:string > >
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe';
CREATE TABLE complex\u json(
控件结构,
调试:字符串,
图像:struct>
)
行格式SERDE'org.apache.hive.hcatalog.data.JsonSerDe';
我得到了错误信息

ParseException行2:27无法识别列规范中“窗口”:“结构”附近的输入


窗口是配置单元中的保留关键字,不能直接将保留作为列的一部分使用

这里有两个选项:

1.)不要将任何保留键用作列的一部分。尝试从窗口中重命名对象名称,将其命名为窗口1,它将起作用

2.)如果您想使用关键字,请像这样使用`window`、后引号和列(关键字) 因此,您的创建表将如下所示:

CREATE TABLE complex_json(
widget struct< `window` :struct< title:string,name:string,width:int,height:int>,
debug:string,
image:struct< src:string,name:string,hOffset:int,vOffset:int,alignment:string > >
)
ROW FORMAT SERDE 'org.apache.hive.hcatalog.data.JsonSerDe';
CREATE TABLE complex\u json(
窗口小部件结构<`window`:struct<标题:字符串,名称:字符串,宽度:int,高度:int>,
调试:字符串,
图像:struct>
)
行格式SERDE'org.apache.hive.hcatalog.data.JsonSerDe';
还要确保JSON是单行的。所有这些Serde都无法识别正确格式的JSON

希望对你有帮助