mirror of
https://github.com/apache/impala.git
synced 2026-01-01 18:00:30 -05:00
276 lines
4.8 KiB
Plaintext
276 lines
4.8 KiB
Plaintext
====
|
|
---- QUERY
|
|
use default
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Make sure the database doesn't exist
|
|
show databases like 'ddl_test_db'
|
|
---- RESULTS
|
|
---- TYPES
|
|
string
|
|
---- SETUP
|
|
RELOAD
|
|
====
|
|
---- QUERY
|
|
create database ddl_test_db
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# It should show up now
|
|
show databases like 'ddl_test_db'
|
|
---- RESULTS
|
|
'ddl_test_db'
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
# Make sure creating a database with the same name doesn't throw an error when
|
|
# IF NOT EXISTS is specified.
|
|
create database if not exists ddl_test_db
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
show tables in ddl_test_db
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
create table ddl_test_db.testtbl(i int, s string COMMENT 'String col') STORED AS TEXTFILE
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Make sure creating a table with the same name doesn't throw an error when
|
|
# IF NOT EXISTS is specified.
|
|
create table if not exists ddl_test_db.testtbl(i int, s string) STORED AS TEXTFILE
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
show tables in ddl_test_db
|
|
---- RESULTS
|
|
'testtbl'
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
describe ddl_test_db.testtbl
|
|
---- RESULTS
|
|
'i','int',''
|
|
's','string','String col'
|
|
---- TYPES
|
|
string,string,string
|
|
====
|
|
---- QUERY
|
|
insert overwrite table ddl_test_db.testtbl SELECT 1, 'Hi'
|
|
from functional.alltypes limit 10
|
|
---- RESULTS
|
|
: 10
|
|
====
|
|
---- QUERY
|
|
select * from ddl_test_db.testtbl
|
|
---- RESULTS
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
---- TYPES
|
|
int,string
|
|
====
|
|
---- QUERY
|
|
create table ddl_test_db.testtbl_part(i int, s string) PARTITIONED BY (id int comment 'C')
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Partition columns are displayed as part of DESCRIBE <table>
|
|
describe ddl_test_db.testtbl_part
|
|
---- RESULTS
|
|
'i','int',''
|
|
's','string',''
|
|
'id','int','C'
|
|
---- TYPES
|
|
string,string,string
|
|
====
|
|
---- QUERY
|
|
insert overwrite table ddl_test_db.testtbl_part partition(id=1)
|
|
select 10, 'Ten' from functional.alltypes limit 1
|
|
---- RESULTS
|
|
id=1/: 1
|
|
====
|
|
---- QUERY
|
|
insert overwrite table ddl_test_db.testtbl_part partition(id=2)
|
|
select 20, 'Twenty' from functional.alltypes limit 2
|
|
---- RESULTS
|
|
id=2/: 2
|
|
====
|
|
---- QUERY
|
|
select * from ddl_test_db.testtbl_part
|
|
---- RESULTS
|
|
1,10,'Ten'
|
|
2,20,'Twenty'
|
|
2,20,'Twenty'
|
|
---- TYPES
|
|
int, int, string
|
|
====
|
|
---- QUERY
|
|
select * from ddl_test_db.testtbl_part where id = 1
|
|
---- RESULTS
|
|
1,10,'Ten'
|
|
---- TYPES
|
|
int, int, string
|
|
====
|
|
---- QUERY
|
|
use ddl_test_db
|
|
====
|
|
---- QUERY
|
|
show tables
|
|
---- RESULTS
|
|
'testtbl'
|
|
'testtbl_part'
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
# Make sure we create the table in the proper database after a "use"
|
|
create table testtbl2(f float, d double) ROW FORMAT DELIMITED FIELDS TERMINATED BY '|'
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
show tables
|
|
---- RESULTS
|
|
'testtbl'
|
|
'testtbl2'
|
|
'testtbl_part'
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
drop table testtbl2
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
show tables
|
|
---- RESULTS
|
|
'testtbl'
|
|
'testtbl_part'
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
# CREATE TABLE LIKE on partitioned table
|
|
create table alltypes_test like functional.alltypes
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Make sure no data exists for this table
|
|
select count(*) from alltypes_test
|
|
---- RESULTS
|
|
0
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
insert overwrite table alltypes_test
|
|
partition (year=2009, month=4)
|
|
select id, bool_col, tinyint_col, smallint_col, int_col, bigint_col,
|
|
float_col, double_col, date_string_col, string_col, timestamp_col
|
|
from functional.alltypes where year=2009 and month=4
|
|
---- RESULTS
|
|
year=2009/month=4/: 300
|
|
====
|
|
---- QUERY
|
|
# Make sure we can read the new data.
|
|
select count(*) from alltypes_test
|
|
---- RESULTS
|
|
300
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
# CREATE TABLE LIKE on unpartitioned table.
|
|
create table testtbl_like like testtbl
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Make sure the new table can be queried and no data exists for this table.
|
|
select count(*) from testtbl_like
|
|
---- RESULTS
|
|
0
|
|
---- TYPES
|
|
BIGINT
|
|
====
|
|
---- QUERY
|
|
# No error is thrown when IF NOT EXISTS is specified and the table already exists.
|
|
create table if not exists testtbl_like like testtbl
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# IF NOT EXISTS also applies when the src table is the same as the new table.
|
|
create table if not exists testtbl_like like testtbl_like
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
insert overwrite table testtbl_like
|
|
select * from testtbl limit 5
|
|
---- RESULTS
|
|
: 5
|
|
====
|
|
---- QUERY
|
|
# Make sure we can read the data.
|
|
select * from testtbl_like
|
|
---- RESULTS
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
1,'Hi'
|
|
---- TYPES
|
|
INT, STRING
|
|
====
|
|
---- QUERY
|
|
drop table testtbl
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
drop table testtbl_part
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
drop table alltypes_test
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
drop table testtbl_like
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
show tables
|
|
---- RESULTS
|
|
---- TYPES
|
|
string
|
|
====
|
|
---- QUERY
|
|
drop table if exists non_existent_db.tbl
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Need to switch databases before dropping
|
|
use default
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
drop database ddl_test_db
|
|
---- RESULTS
|
|
====
|
|
---- QUERY
|
|
# Should be gone now
|
|
show databases like 'ddl_test_db'
|
|
---- RESULTS
|
|
---- TYPES
|
|
string
|
|
====
|