0

I have a Hive table:

CREATE EXTERNAL TABLE IF NOT EXISTS t1 (
    column1 string,
    column2 string
) PARTITIONED BY (datestamp string) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t'
LOCATION '/path';

In Hive I can list partitions of this table with: show partitions t1 In Hive I can add partitions to this table with: add partition...

How can I do these 2 commands in Pig (Grunt)? (show Hive partitions and Add Hive partition)

I could not find these 2 commands (list partitions, add partitions) for Pig in org.apache.hcatalog.pig.HCatLoader()

Is there any working example for Pig to do these 2 commands?

Balduz
  • 3,560
  • 19
  • 35
Joe
  • 11,983
  • 31
  • 109
  • 183

1 Answers1

0

In grunt you can run shell commands using sh .

So try this

grunt> sh hive -e "SHOW databases"
grunt> sh hive -e "USE database;ALTER TABLE table_name PARTITION partition_spec RENAME TO PARTITION partition_spec;"
Karthik
  • 1,801
  • 1
  • 13
  • 21
  • This works but is launching new instance of Hive in order to do that.. I was hoping it can do much faster than launching new Hive every time.. Something like 'short circuit' access in order to show/add partitions.. – Joe Aug 31 '15 at 15:23
  • there is no other way, you can do ls on table location to see partitions, but its not suggested, Sometimes partitions might not be added to metadata. – Karthik Aug 31 '15 at 15:42
  • Is there a way to have Hive shell always open and launch external requests to Hive (from external scripts - e.g. from Pig or Shell scripts)? Currently it takes over 20sec to open new Hive session every time until it loads all libraries.. – Joe Aug 31 '15 at 16:29
  • i dont think so, you dont have anyother option i guess. – Karthik Aug 31 '15 at 19:57