5

I used pyhive to connect hive to use Presto.

May I know the partitions of the hive tables before presto has executed the sql?

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
user3065606
  • 235
  • 1
  • 4
  • 13
  • It is presto is wrapper so it is not not possibel.. – sandeep rawat Mar 24 '17 at 04:40
  • Welcome to SO! Please take a tour [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and [How to create a Minimal, Complete, and Verifiable example](https://stackoverflow.com/help/mcve). – Olaia Mar 24 '17 at 08:03

3 Answers3

17

You can use the below presto query to get partitions.

presto> select * from db_name."table_name$partitions";
p_regionkey 
-------------
       1 
       2 
       3 

The result of SHOW PARTITIONS on hive is below.

hive> show partitions table_name;
p_regionkey=1
p_regionkey=2
p_regionkey=3

SHOW PARTITIONS on presto was removed on 0.209. https://trino.io/docs/current/release/release-0.209.html

ebyhr
  • 1,537
  • 9
  • 15
1

This might be what you are looking for

select "$path" from table
Raghu
  • 2,004
  • 1
  • 16
  • 18
1

Please try the SHOW PARTITIONS command: https://teradata.github.io/presto/docs/0.167-t/sql/show-partitions.html For example: SHOW PARTITIONS FROM table_name;

Oskar Austegard
  • 4,599
  • 4
  • 36
  • 50
  • Oddly there is no documentation of SHOW PARTITIONS in the official Presto docs - I replaced the 404ing link with one from Teradata, which for this case is the same generic Presto syntax. – Oskar Austegard Jan 29 '19 at 23:52
  • 6
    SHOW PARTITIONS was removed in version 0.202 (https://prestosql.io/docs/current/release/release-0.202.html) in favor of the synthetic "$partitions" tables. See the examples sections under https://prestosql.io/docs/current/connector/hive.html for how to do this now.
    – Martin Traverso Mar 07 '19 at 15:17