Search code examples
hadoophivecreate-tablehiveddl

Input text file whitout header


I don't know which table properties I have to use for input text file without header. My text file only has one column.

I have this example:

STORED AS INPUTFORMAT
    'org.apache.hadoop.mapred.TextInputFormat'
OUTPUTFORMAT
    'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
LOCATION
    '/grusers/Fin/Ext/M/_Do'
TBLPROPERTIES (
    "skip.header.line.count"="1"

Solution

  • If there is no header, then remove this property: "skip.header.line.count"="1"

    Also instead of

    STORED AS INPUTFORMAT 'org.apache.hadoop.mapred.TextInputFormat'
    OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat'
    

    you can specify STORED AS TEXTFILE.

    Finally your code will look like this:

     CREATE EXTERNAL TABLE table_name (
       col_name string 
     )
     STORED AS TEXTFILE
     LOCATION '/grusers/Fin/Ext/M/_Do'