Skip to content

Instantly share code, notes, and snippets.

@zdepablo
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zdepablo/c241ef9b152cdb244db1 to your computer and use it in GitHub Desktop.
Save zdepablo/c241ef9b152cdb244db1 to your computer and use it in GitHub Desktop.
Hive receipts
# Overwrite non-partitioned table with their own contents
CREATE table xx_COPY LIKE xx;
INSERT OVERWRITE TABLE xx
SELECT * FROM xx
# Overwrite partitioned table with their own contents
CREATE table xx_COPY LIKE xx;
SHOW PARTITIONS ABC;
## for each partition:
INSERT OVERWRITE ABC_COPY PARTITION(partkey = "$partkey")
SELECT `(partkey)?+.+` FROM ABC WHERE partkey = "$partkey";
# Count rows
SELECT COUNT(*)
FROM xx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment