Search code examples
hiveprestotrino

How to specify SERDEPROPERTIES and TBLPROPERTIES when creating Hive table via prestosql


I'm trying to follow the examples of Hive connector to create hive table. I can write HQL to create a table via beeline. But wonder how to make it via prestosql.

Given table

CREATE TABLE hive.web.request_logs (
  request_time varchar,
  url varchar,
  ip varchar,
  user_agent varchar,
  dt varchar
)
WITH (
  format = 'CSV',
  partitioned_by = ARRAY['dt'],
  external_location = 's3://my-bucket/data/logs/'
)
  1. How to specify SERDEPROPERTIES like separatorChar and quoteChar?
  2. How to specify TBLPROPERTIES like skip.header.line.count?

Solution

  • In Presto you do this like this:

    CREATE TABLE table_name( ... columns ... )
    WITH (format='CSV', csv_separator='|', skip_header_line_count=1);
    

    You can list all supported table properties in Presto with

    SELECT * FROM system.metadata.table_properties;