Files
impala/testdata/workloads/functional-query/queries/QueryTest/create-database.test
Csaba Ringhofer 76f9b75c8b IMPALA-10172: Support Hive metastore managed locations for databases
This change lets the user set the managed location path in new
databases, e.g.
CREATE DATABASE db MANAGEDLOCATION 'some url';

This property sets the location where the database's tables with
table property 'transactional'='true' will be placed.

The change also adds managedlocation to DESCRIBE DATABASE's output.
Example:
DESCRIBE DATABASE db;
+------------------+-----------------------------------------+---------+
| name             | location                                | comment |
+------------------+-----------------------------------------+---------+
| db               | hdfs://localhost:20500/test-warehouse/a |         |
| managedlocation: | hdfs://localhost:20500/test-warehouse/b |         |
+------------------+-----------------------------------------+---------+
DESCRIBE DATABASE EXTENDED db6;
+------------------+-----------------------------------------+---------+
| name             | location                                | comment |
+------------------+-----------------------------------------+---------+
| db               | hdfs://localhost:20500/test-warehouse/a |         |
| managedlocation: | hdfs://localhost:20500/test-warehouse/b |         |
| Owner:           |                                         |         |
|                  | csringhofer                             | USER    |
+------------------+-----------------------------------------+---------+

Note that Impala's output for DESCRIBE DATABASE (EXTENDED) is
different than Hive's, where a new column was added for each extra
piece of information, while Impala adds a new row to keep the 3 column
format. Changing to Hive's format would be preferable in my opinion,
but is a potentially breaking change.
See IMPALA-6686 for further discussion.

Testing:
- added FE and EE tests
- ran relevant tests

Change-Id: I925632a43ff224f762031e89981896722e453399
Reviewed-on: http://gerrit.cloudera.org:8080/16529
Reviewed-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
Tested-by: Impala Public Jenkins <impala-public-jenkins@cloudera.com>
2020-10-07 18:32:51 +00:00

231 lines
6.4 KiB
Plaintext

====
---- QUERY
create database $DATABASE_2 comment "For testing"
---- RESULTS
'Database has been created.'
====
---- QUERY
show databases like "$DATABASE_2"
---- RESULTS
'$DATABASE_2','For testing'
---- TYPES
STRING, STRING
====
---- QUERY
# Test that DESCRIBE shows the proper database location
# for a newly created database (regression test for IMPALA-7439)
describe database $DATABASE_2
---- RESULTS
'$DATABASE_2','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/$DATABASE_2.db','For testing'
---- TYPES
string, string, string
====
---- QUERY
# Test that DESCRIBE EXTENDED also has all of the necessary info.
describe database extended $DATABASE_2
---- RESULTS
'$DATABASE_2','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/$DATABASE_2.db','For testing'
'Owner: ','',''
'','$USER','USER'
---- TYPES
string, string, 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 $DATABASE_2
---- RESULTS
'Database already exists.'
====
---- QUERY
# Test dropping the database.
drop database $DATABASE_2
---- RESULTS
'Database has been dropped.'
====
---- QUERY
show databases like "$DATABASE_2"
---- RESULTS
---- TYPES
STRING, STRING
====
---- QUERY
# Dropping a non-existent databases is ok with IF EXISTS
drop database if exists $DATABASE_2
---- RESULTS
'Database does not exist.'
====
---- QUERY
# Test CREATE DATABASE ... LOCATION
create database if not exists $DATABASE_loc comment "For testing"
location '$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location'
---- RESULTS
'Database has been created.'
====
---- QUERY
# Test that DESCRIBE shows the proper database location
# for a newly created database with location
describe database $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location','For testing'
---- TYPES
string, string, string
====
---- QUERY
# Test that DESCRIBE EXTENDED also has all of the necessary info.
describe database extended $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location','For testing'
'Owner: ','',''
'','$USER','USER'
---- TYPES
string, string, string
====
---- QUERY
# Test dropping the database.
drop database $DATABASE_loc
---- RESULTS
'Database has been dropped.'
====
---- QUERY
# Test DROP DATABASE ... CASCADE
create database if not exists $DATABASE_cascade
====
---- QUERY
create table if not exists $DATABASE_cascade.t1 (i int);
create table if not exists $DATABASE_cascade.t2 (i int)
partitioned by (year smallint, month smallint);
insert into $DATABASE_cascade.t2 partition (year=2015, month=8) values(1);
create external table if not exists $DATABASE_cascade.t3 like functional.alltypes
location '$FILESYSTEM_PREFIX/test-warehouse/alltypes_external';
create view if not exists $DATABASE_cascade.v1 as
select int_col from functional.alltypes;
create function if not exists $DATABASE_cascade.f1() returns string
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdfs.so' symbol='NoArgs';
create aggregate function if not exists $DATABASE_cascade.f2(int, string) RETURNS int
location '$FILESYSTEM_PREFIX/test-warehouse/libTestUdas.so' UPDATE_FN='TwoArgUpdate'
---- RESULTS
'Function has been created.'
====
---- QUERY
show tables in $DATABASE_cascade
---- RESULTS
't1'
't2'
't3'
'v1'
---- TYPES
STRING
====
---- QUERY
show functions in $DATABASE_cascade
---- RESULTS
'STRING','f1()','NATIVE','true'
---- TYPES
STRING, STRING, STRING, STRING
====
---- QUERY
show aggregate functions in $DATABASE_cascade
---- RESULTS
'INT','f2(INT, STRING)','NATIVE','true'
---- TYPES
STRING, STRING, STRING, STRING
====
---- QUERY
# Should drop all tables, functions, and aggregate functions, as well
# as the database itself.
drop database $DATABASE_cascade cascade
---- RESULTS
'Database has been dropped.'
====
---- QUERY
show databases like '$DATABASE_cascade'
---- RESULTS
====
---- QUERY
# Test that DROP DATABASE ... RESTRICT executes ok.
create database if not exists $DATABASE_restrict
====
---- QUERY
show databases like '$DATABASE_restrict'
---- RESULTS
'$DATABASE_restrict',''
---- TYPES
STRING,STRING
====
---- QUERY
drop database $DATABASE_restrict restrict
---- RESULTS
'Database has been dropped.'
====
---- QUERY
show databases like '$DATABASE_restrict'
---- RESULTS
====
---- QUERY
# Test CREATE DATABASE ... MANAGEDLOCATION
create database if not exists $DATABASE_loc comment "For testing"
managedlocation '$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation'
---- RESULTS
'Database has been created.'
====
---- QUERY
# Test that DESCRIBE shows the proper database location and managedlocation
# for a newly created database with location
describe database $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/$DATABASE_loc.db','For testing'
'managedlocation:','$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation',''
---- TYPES
string, string, string
====
---- QUERY
# Test that DESCRIBE EXTENDED also has all of the necessary info.
describe database extended $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/$DATABASE_loc.db','For testing'
'managedlocation:','$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation',''
'Owner: ','',''
'','$USER','USER'
---- TYPES
string, string, string
====
---- QUERY
drop database $DATABASE_loc
---- RESULTS
'Database has been dropped.'
====
---- QUERY
# Test CREATE DATABASE ... LOCATION ... MANAGEDLOCATION
create database if not exists $DATABASE_loc comment "For testing"
location '$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location'
managedlocation '$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation'
---- RESULTS
'Database has been created.'
====
---- QUERY
# Test that DESCRIBE shows the proper database location and managedlocation
# for a newly created database with location
describe database $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location','For testing'
'managedlocation:','$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation',''
---- TYPES
string, string, string
====
---- QUERY
# Test that DESCRIBE EXTENDED also has all of the necessary info.
describe database extended $DATABASE_loc
---- RESULTS
'$DATABASE_loc','$NAMENODE/$EXTERNAL_WAREHOUSE_DIR/specified_location','For testing'
'managedlocation:','$NAMENODE/$MANAGED_WAREHOUSE_DIR/specified_managedlocation',''
'Owner: ','',''
'','$USER','USER'
---- TYPES
string, string, string
====
---- QUERY
drop database $DATABASE_loc
---- RESULTS
'Database has been dropped.'
====