Impala-shell Import and Export data

Source: Internet
Author: User
Tags file upload hadoop fs
Impala-shell Import and Export

Parameter description:
-q Query (--query=query) executes queries from the command line without entering Impala-shell
-d default_db (--database=default_db) Specify database
-b (--delimited) to format the output
--output_delimiter=character specifying delimiters
--print_header Print column names
-f Query_file (--query_file=query_file) executes the query file, separated by semicolons
-o filename (--output_file filename) Results output to the specified file


1. Export

1.1 Exporting results to CSV
Impala-shell-q "Select Id,price,name,dtime from Config.price_test limit 3"-B--output_delimiter= ","--print_header-o/V Ar/testimpalaout.csv

1.2 Exporting results to excle
Impala-shell-q "Select Id,price,name,dtime from Config.price_test limit 3"-B--output_delimiter= "\ T"--print_header-o/ Var/testimpalaout.xlsx


2. Import

2.1 Hadoop Create Folder

Hadoop fs-mkdir/tmp/price_txternal


2.2 Local File Upload Hadoop

Hadoop fs-put/var/testimpalaout.csv/tmp/price_txternal


2.3 Creating temporary tables (no partitions, plain text tables)
Impala-shell, enter Impala-shell database, (delimiter, custom)


CREATE TABLE Config.price_test_ls (
ID INT,
Price DOUBLE,
Name VARCHAR (200),
Dtime TIMESTAMP
)
Row format delimited terminated by ', '
Location '/tmp/price_txternal ';

2.4 Importing a partitioned table
INSERT into Config.price_test PARTITION (day = 20170701, MINUTE = cast (' 0000 ' as char (4)))
SELECT
Id
Price
NAME,
Dtime
From
Config.price_test_ls

2.5 Deleting a temporary table
drop table Config.price_test_ls;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.