Search code examples
hivegcloudavrocreate-tableexternal-tables

How can I create external tables with Hive?


This is the script I run on Hive:

CREATE EXTERNAL TABLE 'people'(
    'name' string,
    'surname' string,
    'age' string)
ROW FORMAT SERDE
    'org.apache.hadoop.hive.serde2.avro.AvroSerDe'
STORED AS INPUTFORMAT
    'org.apache.hadoop.hive.ql.io.avro.AvroContainerInputFormat'
OUTPUTFORMAT
    'org.apache.hadoop.hive.ql.io.avro.AvroContainerOutputFormat'
LOCATION
    'gs://directory/subdirectory/'
TBLPROPERTIES (
    'avro.schema.url'='gs://directory/schema.avsc',
    'transient_lastDdlTime'='1644235388');

I get this error: Error while compiling statement:

FAILED: ParseException line 1:22 cannot recognize input near ''people'' '(' ''nam'' in table name


Solution

  • could you pls enclose them with backtick( `)

    CREATE EXTERNAL TABLE `people`(
        `name` string,
        `surname` string,
        `age` string)
    ...