EXPORT … INTO
Sources (Table/Query)
EXPORT TABLE employee
INTO FILE PATH '/export/employee.csv'
EXPORT QUERY
(
SELECT id, manager_id, first_name, last_name, salary, hire_date
FROM employee
WHERE dept_id = 2
)
INTO FILE PATH '/export/employee_dept2.csv'
Data Sinks (File/Table/DML)
EXPORT TABLE employee
INTO FILE PATH '/data/employee.csv'
WITH OPTIONS (DATASINK_NAME = 's3_dsink')
EXPORT TABLE employee
INTO REMOTE TABLE 'example.remote_employee'
WITH OPTIONS (DATASINK_NAME = 'jdbc_dsink')
EXPORT TABLE employee
INTO REMOTE QUERY 'INSERT INTO example.remote_employee VALUES (?, ?, ?, ?, ?, ?, ?)'
WITH OPTIONS (DATASINK_NAME = 'jdbc_dsink')
EXPORT TABLE ts_source
INTO REMOTE TABLE 'ts'
WITH OPTIONS
(
DATASINK_NAME = 'jdbc_dsink',
JDBC_SESSION_INIT_STATEMENT = 'SET TIMEZONE=''EST''',
JDBC_CONNECTION_INIT_STATEMENT = 'CREATE TABLE ts (ts DATETIME)'
)
Delimited Text Options
EXPORT TABLE product
INTO FILE PATH '/export/products.csv'
EXPORT TABLE product
INTO FILE PATH '/export/products_text.dat'
FORMAT TEXT
EXPORT TABLE product
INTO FILE PATH '/export/products.csv'
FORMAT TEXT (INCLUDES HEADER = FALSE)
EXPORT TABLE product
INTO FILE PATH '/export/products_name.csv'
WITH OPTIONS (FIELDS MAPPED BY NAME(id, name, stock))
EXPORT TABLE product
INTO FILE PATH '/export/products_pos.csv'
WITH OPTIONS (FIELDS IGNORED BY POSITION(2, 4))
EXPORT TABLE product
INTO FILE PATH '/export/products.ssv'
FORMAT TEXT
(
DELIMITER = ';',
INCLUDES HEADER = TRUE,
NULL = '<null>'
)
EXPORT TABLE product
INTO FILE PATH '/export/products.csv.gz'
WITH OPTIONS (COMPRESSION_TYPE = 'gzip')
Parquet Files
EXPORT TABLE product
INTO FILE PATH '/export/products_par.dat'
FORMAT PARQUET
EXPORT TABLE product
INTO FILE PATH '/export/products_name.parquet'
FORMAT PARQUET
WITH OPTIONS (FIELDS MAPPED BY NAME(id, name, stock))
EXPORT TABLE product
INTO FILE PATH '/export/products_pos.parquet'
FORMAT PARQUET
WITH OPTIONS (FIELDS IGNORED BY POSITION(category, description))
EXPORT TABLE product
INTO FILE PATH '/export/products.parquet'
EXPORT TABLE product
INTO FILE PATH '/export/products.gz.parquet'
WITH OPTIONS (COMPRESSION_TYPE = 'gzip')
Naming Options
-- Creates a file with a name like:
-- export/product.csv
EXPORT TABLE product
INTO FILE PATH '/export/product.csv'
WITH OPTIONS (SINGLE_FILE = 'overwrite')
-- Creates a file with a name like:
-- export/product_611460000.csv
EXPORT TABLE product
INTO FILE PATH '/export/product.csv'
-- Creates a set of files with names like:
-- * export/product_611641000.csv
-- * export/product_611642000.csv
EXPORT TABLE product
INTO FILE PATH '/export/product.csv'
WITH OPTIONS (SINGLE_FILE = false)
Sizing Options
EXPORT TABLE product
INTO FILE PATH '/export/products_exp.csv'
WITH OPTIONS (BATCH SIZE = 20000)
EXPORT TABLE product
INTO REMOTE TABLE 'product_exp'
WITH OPTIONS
(
DATASINK_NAME = 'jdbc_dsink',
BATCH SIZE = 20000
)