hive

Export Data in Hive

Export feature in hive

Exporting data from employees table to /tmp/ca_employees

INSERT OVERWRITE LOCAL DIRECTORY ‘/tmp/ca_employees’ SELECT name, salary, address FROM employees WHERE se.state = ‘CA’;

Exporting data from employees table to multiple local directories based on specific condition

The below query shows how a single construct can be used to export data to multiple directories based on specific criteria

FROM employees se INSERT OVERWRITE DIRECTORY '/tmp/or_employees' SELECT * WHERE se.cty = 'US' and se.st = 'OR'
INSERT OVERWRITE DIRECTORY '/tmp/ca_employees' SELECT * WHERE se.cty = 'US' and se.st = 'CA'
INSERT OVERWRITE DIRECTORY '/tmp/il_employees' SELECT * WHERE se.cty = 'US' and se.st = 'IL';

This modified text is an extract of the original Stack Overflow Documentation created by the contributors and released under CC BY-SA 3.0 This website is not affiliated with Stack Overflow