Hive FAILED: ParseException line 2:0 cannot recognize input near ''macaddress'' 'CHAR' '(' in column specification

后端 未结 1 1612
执念已碎
执念已碎 2021-01-18 15:17

I\'ve tried running hive -v -f sqlfile.sql

Here is the content of the file

CREATE TABLE UpStream         


        
相关标签:
1条回答
  • 2021-01-18 16:02

    First, the column name must be surrounded by ` (backticks), not ' (single quote).

    Therefore you have to replace 'macaddress' to `macaddress`, as well as all other column names.

    Second, the order of STORED AS and TBLPROPERTIES and PARTITIONED BY and LOCATION is wrong. The correct order is PARTITIONED BY, STORED AS, LOCATION, TBLPROPERTIES.

    See the hive language manual for detail. https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DDL#LanguageManualDDL-CreateTable

    So the correct code is

    CREATE TABLE UpStreamParam (
    `macaddress` CHAR(50),
    `datats` BIGINT,
    `cmtstimestamp` BIGINT,
    `modulation` INT,
    `chnlidx`   INT,
    `severity` BIGINT,
    `rxpower`  FLOAT,
    `sigqnoise` FLOAT,
    `noisedeviation`  FLOAT,
    `prefecber`  FLOAT,
    `postfecber`  FLOAT,
    `txpower`  FLOAT,
    `txpowerdrop` FLOAT,
    `nmter`  FLOAT,
    `premtter`  FLOAT,
    `postmtter`  FLOAT,
    `unerroreds`  BIGINT,
    `corrected`  BIGINT,
    `uncorrectables`  BIGINT)
    PARTITIONED BY (`cmtsid` CHAR(50), `date` INT)
    STORED AS ORC
    LOCATION '/usr/hive/warehouse/UpStreamParam'
    TBLPROPERTIES ("orc.compress"="SNAPPY","orc.bloom.filters.columns"="macaddress");
    
    0 讨论(0)
提交回复
热议问题