How to Query parquet data from Amazon Athena?

后端 未结 3 962
遥遥无期
遥遥无期 2021-02-08 22:51

Athena creates a temporary table using fields in S3 table. I have done this using JSON data. Could you help me on how to create table using parquet data?

I have tried fo

相关标签:
3条回答
  • 2021-02-08 23:34

    If your table definition is valid but not getting any rows, try this

    -- The MSCK REPAIR TABLE command will load all partitions into the table. -- This command can take a while to run depending on the number of partitions to be loaded.

    MSCK REPAIR TABLE {tablename}

    0 讨论(0)
  • 2021-02-08 23:37

    steps:
    1. create your my_table_json
    2. insert data into my_table_json (verify existence of the created json files in the table 'LOCATION')
    3. create my_table_parquet: same create statement as my_table_json except you need to add 'STORED AS PARQUET' clause.
    4. run: INSERT INTO my_table_parquet SELECT * FROM my_table_json

    0 讨论(0)
  • 2021-02-08 23:40

    If your data has been successfully stored in Parquet format, you would then create a table definition that references those files.

    Here is an example statement that uses Parquet files:

    CREATE EXTERNAL TABLE IF NOT EXISTS elb_logs_pq (
      request_timestamp string,
      elb_name string,
      request_ip string,
      request_port int,
      ...
      ssl_protocol string )
    PARTITIONED BY(year int, month int, day int) 
    STORED AS PARQUET
    LOCATION 's3://athena-examples/elb/parquet/'
    tblproperties ("parquet.compress"="SNAPPY");
    

    This example was taken from the AWS blog post Analyzing Data in S3 using Amazon Athena that does an excellent job of explaining the benefits of using compressed and partitioned data in Amazon Athena.

    0 讨论(0)
提交回复
热议问题