tajo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hyun...@apache.org
Subject [01/13] TAJO-353: Add Database support to Tajo. (hyunsik)
Date Tue, 25 Mar 2014 01:36:16 GMT
Repository: tajo
Updated Branches:
  refs/heads/master 7283c586a -> 3ba262412


http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestCreateTable/create_table_various_types_for_hcatalog.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestCreateTable/create_table_various_types_for_hcatalog.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestCreateTable/create_table_various_types_for_hcatalog.sql
new file mode 100644
index 0000000..3eda994
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestCreateTable/create_table_various_types_for_hcatalog.sql
@@ -0,0 +1,50 @@
+-- Some types were commented out due to Hive meta test.
+
+create table various_types (
+--  col0 bit,
+--  col1 BIT(10),
+--  col2 bit varying,
+--  col3 bit VARYING(10),
+  col4 tinyint,
+  col5 smallInt,
+  col6 integer,
+  col7 biginT,
+  col8 real,
+  col9 float,
+  col10 float(53),
+  col11 double,
+  col12 doublE precision,
+--  col13 numeric,
+--  col14 numeric(10),
+--  col15 numeric(10,2),
+--  col16 decimal,
+--  col17 decimal(10),
+--  col18 decimal(10,2),
+--  col19 char,
+--  col20 character,
+--  col21 chaR(10),
+--  col22 character(10),
+--  col23 varchar,
+--  col24 character varying,
+--  col25 varchar(255),
+--  col26 character varying (255),
+--  col27 nchar,
+--  col28 nchar(255),
+--  col29 national character,
+--  col30 national character(255),
+--  col31 nvarchar,
+--  col32 nvarchar(255),
+--  col33 natIonal character varying,
+--  col34 national character varying (255),
+--  col35 date,
+--  col36 time,
+--  col37 timetz,
+--  col38 time With time zone,
+--  col39 timesTamptz,
+--  col40 timestamp with time zone,
+  col41 binary,
+--  col42 binary(10),
+--  col43 varbinary(10),
+--  col44 binary Varying(10),
+  col45 blOb
+);
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk1.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk1.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk1.sql
index 910138f..5451b4a 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk1.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk1.sql
@@ -1 +1 @@
-select region.*, customer.* from region, customer;
\ No newline at end of file
+select region.*, customer.* from region, customer order by r_regionkey,r_name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk2.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk2.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk2.sql
index a68e40a..e9dac51 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk2.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk2.sql
@@ -1 +1 @@
-select region.*, customer.* from customer, region;
\ No newline at end of file
+select region.*, customer.* from customer, region order by r_regionkey,r_name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk3.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk3.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk3.sql
index f75c8dc..c98e19f 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk3.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk3.sql
@@ -1 +1 @@
-select * from customer, region;
\ No newline at end of file
+select * from customer, region order by c_custkey,c_name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk4.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk4.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk4.sql
index 100be80..7130def 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk4.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testCrossJoinWithAsterisk4.sql
@@ -1 +1 @@
-select length(r_comment), *, c_custkey*10 from customer, region;
\ No newline at end of file
+select length(r_comment) as len, *, c_custkey*10 from customer, region order by len,r_regionkey,r_name;
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testJoinOnMultipleDatabases.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testJoinOnMultipleDatabases.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testJoinOnMultipleDatabases.sql
new file mode 100644
index 0000000..4598dd8
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestJoinQuery/testJoinOnMultipleDatabases.sql
@@ -0,0 +1,25 @@
+select
+	s_acctbal,
+	s_name,
+	n_name,
+	p_partkey,
+	p_mfgr,
+	s_address,
+	s_phone,
+	s_comment
+from
+	JOINS.part_,
+	JOINS.supplier_,
+	partsupp,
+	nation,
+	region
+where
+	p_partkey = ps_partkey
+	and s_suppkey = ps_suppkey
+	and s_nationkey = n_nationkey
+	and n_regionkey = r_regionkey
+order by
+  s_acctbal,
+  s_name,
+  n_name,
+  p_partkey;

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table1_ddl.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table1_ddl.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table1_ddl.sql
index 45df638..c3ee88e 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table1_ddl.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table1_ddl.sql
@@ -1,4 +1,4 @@
 -- It is used in TestNetTypes
 
-create external table table1 (id int, name text, score float, type text, addr inet4) using csv
+create external table IF NOT EXISTS table1 (id int, name text, score float, type text, addr inet4) using csv
 with ('csvfile.delimiter'='|', 'csvfile.null'='NULL') location ${table.path};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table2_ddl.sql
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table2_ddl.sql b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table2_ddl.sql
index 73fe19e..30bfafe 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table2_ddl.sql
+++ b/tajo-core/tajo-core-backend/src/test/resources/queries/TestNetTypes/table2_ddl.sql
@@ -1,4 +1,4 @@
 -- It is used in TestNetTypes
 
-create external table table2 (id int, name text, score float, type text, addr inet4) using csv
+create external table IF NOT EXISTS table2 (id int, name text, score float, type text, addr inet4) using csv
 with ('csvfile.delimiter'='|', 'csvfile.null'='NULL') location ${table.path};
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk3.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk3.result b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk3.result
index f4e8c88..9db83f0 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk3.result
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk3.result
@@ -1,27 +1,27 @@
-r_regionkey,r_name,r_comment,c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment
+c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment,r_regionkey,r_name,r_comment
 -------------------------------
-0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
-0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
-0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov
-0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou
-0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor
-1,AMERICA,hs use ironic, even requests. s,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
-1,AMERICA,hs use ironic, even requests. s,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
-1,AMERICA,hs use ironic, even requests. s,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov
-1,AMERICA,hs use ironic, even requests. s,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou
-1,AMERICA,hs use ironic, even requests. s,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor
-2,ASIA,ges. thinly even pinto beans ca,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
-2,ASIA,ges. thinly even pinto beans ca,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
-2,ASIA,ges. thinly even pinto beans ca,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov
-2,ASIA,ges. thinly even pinto beans ca,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou
-2,ASIA,ges. thinly even pinto beans ca,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor
-3,EUROPE,ly final courts cajole furiously final excuse,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
-3,EUROPE,ly final courts cajole furiously final excuse,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
-3,EUROPE,ly final courts cajole furiously final excuse,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov
-3,EUROPE,ly final courts cajole furiously final excuse,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou
-3,EUROPE,ly final courts cajole furiously final excuse,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor
-4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e
-4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref
-4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov
-4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou
-4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor
\ No newline at end of file
+1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 
+1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,1,AMERICA,hs use ironic, even requests. s
+1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,2,ASIA,ges. thinly even pinto beans ca
+1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,3,EUROPE,ly final courts cajole furiously final excuse
+1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl
+2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 
+2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,1,AMERICA,hs use ironic, even requests. s
+2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,2,ASIA,ges. thinly even pinto beans ca
+2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,3,EUROPE,ly final courts cajole furiously final excuse
+2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl
+3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 
+3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,1,AMERICA,hs use ironic, even requests. s
+3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,2,ASIA,ges. thinly even pinto beans ca
+3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,3,EUROPE,ly final courts cajole furiously final excuse
+3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl
+4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 
+4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,1,AMERICA,hs use ironic, even requests. s
+4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,2,ASIA,ges. thinly even pinto beans ca
+4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,3,EUROPE,ly final courts cajole furiously final excuse
+4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl
+5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to 
+5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,1,AMERICA,hs use ironic, even requests. s
+5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,2,ASIA,ges. thinly even pinto beans ca
+5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,3,EUROPE,ly final courts cajole furiously final excuse
+5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk4.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk4.result b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk4.result
index 95b5bc3..23d985e 100644
--- a/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk4.result
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testCrossJoinWithAsterisk4.result
@@ -1,27 +1,27 @@
-?length,r_regionkey,r_name,r_comment,c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment,?multiply_1
+len,c_custkey,c_name,c_address,c_nationkey,c_phone,c_acctbal,c_mktsegment,c_comment,r_regionkey,r_name,r_comment,?multiply
 -------------------------------
-115,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,10
-115,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,20
-115,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,30
-115,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,40
-115,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,50
-31,1,AMERICA,hs use ironic, even requests. s,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,10
-31,1,AMERICA,hs use ironic, even requests. s,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,20
-31,1,AMERICA,hs use ironic, even requests. s,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,30
-31,1,AMERICA,hs use ironic, even requests. s,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,40
-31,1,AMERICA,hs use ironic, even requests. s,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,50
-31,2,ASIA,ges. thinly even pinto beans ca,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,10
-31,2,ASIA,ges. thinly even pinto beans ca,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,20
-31,2,ASIA,ges. thinly even pinto beans ca,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,30
-31,2,ASIA,ges. thinly even pinto beans ca,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,40
-31,2,ASIA,ges. thinly even pinto beans ca,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,50
-45,3,EUROPE,ly final courts cajole furiously final excuse,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,10
-45,3,EUROPE,ly final courts cajole furiously final excuse,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,20
-45,3,EUROPE,ly final courts cajole furiously final excuse,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,30
-45,3,EUROPE,ly final courts cajole furiously final excuse,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,40
-45,3,EUROPE,ly final courts cajole furiously final excuse,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,50
-108,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,10
-108,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,20
-108,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,30
-108,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,40
-108,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,50
\ No newline at end of file
+31,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,1,AMERICA,hs use ironic, even requests. s,10
+31,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,1,AMERICA,hs use ironic, even requests. s,20
+31,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,1,AMERICA,hs use ironic, even requests. s,30
+31,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,1,AMERICA,hs use ironic, even requests. s,40
+31,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,1,AMERICA,hs use ironic, even requests. s,50
+31,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,2,ASIA,ges. thinly even pinto beans ca,10
+31,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,2,ASIA,ges. thinly even pinto beans ca,20
+31,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,2,ASIA,ges. thinly even pinto beans ca,30
+31,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,2,ASIA,ges. thinly even pinto beans ca,40
+31,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,2,ASIA,ges. thinly even pinto beans ca,50
+45,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,3,EUROPE,ly final courts cajole furiously final excuse,10
+45,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,3,EUROPE,ly final courts cajole furiously final excuse,20
+45,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,3,EUROPE,ly final courts cajole furiously final excuse,30
+45,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,3,EUROPE,ly final courts cajole furiously final excuse,40
+45,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,3,EUROPE,ly final courts cajole furiously final excuse,50
+108,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,10
+108,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,20
+108,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,30
+108,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,40
+108,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,4,MIDDLE EAST,uickly special accounts cajole carefully blithely close requests. carefully final asymptotes haggle furiousl,50
+115,1,Customer#000000001,IVhzIApeRb ot,c,E,15,25-989-741-2988,711.56,BUILDING,to the even, regular platelets. regular, ironic epitaphs nag e,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,10
+115,2,Customer#000000002,XSTf4,NCwDVaWNe6tEgvwfmRchLXak,13,23-768-687-3665,121.65,AUTOMOBILE,l accounts. blithely ironic theodolites integrate boldly: caref,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,20
+115,3,Customer#000000003,MG9kdTD2WBHm,1,11-719-748-3364,7498.12,AUTOMOBILE, deposits eat slyly ironic, even instructions. express foxes detect slyly. blithely even accounts abov,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,30
+115,4,Customer#000000004,XxVSJsLAGtn,4,14-128-190-5944,2866.83,MACHINERY, requests. final, regular ideas sleep final accou,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,40
+115,5,Customer#000000005,KvpyuHCplrB84WgAiGV6sYpZq7Tj,3,13-750-942-6364,794.47,HOUSEHOLD,n accounts will have to unwind. foxes cajole accor,0,AFRICA,lar deposits. blithely final packages cajole. regular waters are final requests. regular accounts are according to ,50
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testJoinOnMultipleDatabases.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testJoinOnMultipleDatabases.result b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testJoinOnMultipleDatabases.result
new file mode 100644
index 0000000..dc0968f
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestJoinQuery/testJoinOnMultipleDatabases.result
@@ -0,0 +1,5 @@
+s_acctbal,s_name,n_name,p_partkey,p_mfgr,s_address,s_phone,s_comment
+-------------------------------
+4032.68,Supplier#000000002,ETHIOPIA,1,Manufacturer#1,89eJ5ksX3ImxJQBvxObC,,15-679-861-2259, slyly bold instructions. idle dependen
+4192.4,Supplier#000000003,ARGENTINA,2,Manufacturer#1,q1,G3Pj6OjIuUYfUoH18BFTKP5aU9bEV3,11-383-516-1199,blithely silent requests after the express dependencies are sl
+4641.08,Supplier#000000004,MOROCCO,3,Manufacturer#4,Bk7ah4CK8SYQTepEmvMkkgMwg,25-843-787-7479,riously even requests above the exp
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables1.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables1.result b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables1.result
new file mode 100644
index 0000000..88df9a8
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables1.result
@@ -0,0 +1,4 @@
+table_cat,table_schem,table_name,table_type,remarks
+-------------------------------
+jdbc_test1,public,table1,TABLE,
+jdbc_test1,public,table2,TABLE,
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables2.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables2.result b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables2.result
new file mode 100644
index 0000000..06afed2
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/TestTajoJdbc/getTables2.result
@@ -0,0 +1,4 @@
+table_cat,table_schem,table_name,table_type,remarks
+-------------------------------
+jdbc_test2,public,table3,TABLE,
+jdbc_test2,public,table4,TABLE,
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDL.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDL.result b/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDL.result
deleted file mode 100644
index a16119f..0000000
--- a/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDL.result
+++ /dev/null
@@ -1,5 +0,0 @@
---
--- Name: table1; Type: TABLE; Storage: CSV
--- Path: /table1
---
-CREATE EXTERNAL TABLE table1 (name BLOB, addr TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|') PARTITION BY COLUMN(key INT4, key2 TEXT) LOCATION '/table1';
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForBaseTable.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForBaseTable.result b/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForBaseTable.result
new file mode 100644
index 0000000..bd59e2d
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForBaseTable.result
@@ -0,0 +1,5 @@
+--
+-- Name: db1.table2; Type: TABLE; Storage: CSV
+-- Path: /table1
+--
+CREATE TABLE db1.table2 (name BLOB, addr TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|');
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForExternalTable.result
----------------------------------------------------------------------
diff --git a/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForExternalTable.result b/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForExternalTable.result
new file mode 100644
index 0000000..78c64ff
--- /dev/null
+++ b/tajo-core/tajo-core-backend/src/test/resources/results/testBuildDDLForExternalTable.result
@@ -0,0 +1,5 @@
+--
+-- Name: db1.table1; Type: TABLE; Storage: CSV
+-- Path: /table1
+--
+CREATE EXTERNAL TABLE db1.table1 (name BLOB, addr TEXT) USING CSV WITH ('compression.codec'='org.apache.hadoop.io.compress.GzipCodec', 'csvfile.delimiter'='|') PARTITION BY COLUMN(key INT4, key2 TEXT) LOCATION '/table1';
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-docs/src/main/sphinx/cli.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/cli.rst b/tajo-docs/src/main/sphinx/cli.rst
index 6c91d2f..fa3f4a7 100644
--- a/tajo-docs/src/main/sphinx/cli.rst
+++ b/tajo-docs/src/main/sphinx/cli.rst
@@ -8,8 +8,9 @@ Synopsis
 
 .. code-block:: bash
 
-  bin/tsql [options]
+  bin/tsql [options] [database name]
 
+If a *database_name* is given, tsql connects to the database at startup time. Otherwise, tsql connects to ``default`` database.
 
 Options
 
@@ -26,13 +27,15 @@ If the hostname and the port num are not given, tsql will try to connect the Taj
 
   bin/tsql
 
-  tajo>
+  default>
 
 If you want to connect a specified TajoMaster, you should use '-h' and (or) 'p' options as follows: ::
 
   bin/tsql -h localhost -p 9004
 
-  tajo> 
+  default> 
+
+The prompt indicates the current database.
 
 ===================
  Meta Commands
@@ -42,7 +45,7 @@ In tsql, anything command that begins with an unquoted backslash ('\') is a tsql
 
 In the current implementation, there are meta commands as follows: ::
 
-  tajo> \?
+  default> \?
 
   General
     \copyright  show Apache License 2.0
@@ -52,25 +55,44 @@ In the current implementation, there are meta commands as follows: ::
 
 
   Informational
-    \d         list tables
-    \d  NAME   describe table
+    \l           list databases
+    \c           show current database
+    \c [DBNAME]  connect to new database
+    \d           list tables
+    \d [TBNAME]  describe table
+    \df          list functions
+    \df NAME     describe function
+
+
+  Variables
+    \set [[NAME] [VALUE]  set session variable or list session variables
+    \unset NAME           unset session variable
 
 
   Documentations
-    tsql guide        http://wiki.apache.org/tajo/tsql
-    Query language    http://wiki.apache.org/tajo/QueryLanguage
-    Functions         http://wiki.apache.org/tajo/Functions
-    Backup & restore  http://wiki.apache.org/tajo/BackupAndRestore
-    Configuration     http://wiki.apache.org/tajo/Configuration
+    tsql guide        http://tajo.incubator.apache.org/docs/0.8.0/cli.html
+    Query language    http://tajo.incubator.apache.org/docs/0.8.0/sql_language.html
+    Functions         http://tajo.incubator.apache.org/docs/0.8.0/functions.html
+    Backup & restore  http://tajo.incubator.apache.org/docs/0.8.0/backup_and_restore.html
+    Configuration     http://tajo.incubator.apache.org/docs/0.8.0/configuration.html
+
+-----------------------------------------------
+Basic usages
+-----------------------------------------------
+
+``\l`` command shows a list of all databases.
 
+.. code-block:: sql
 
-================
-Examples
-================
+  default> \l
+  default
+  tpch
+  work1
+  default> 
 
-If you want to list all table names, use '\d' meta command as follows: ::
+``\d`` command shows a list of tables in the current database as follows: ..
 
-  tajo> \d
+  default> \d
   customer
   lineitem
   nation
@@ -80,9 +102,9 @@ If you want to list all table names, use '\d' meta command as follows: ::
   region
   supplier
 
-Now look at the table description: ::
+``\d [table name]`` command also shows a table description.
 
-  tajo> \d orders
+  default> \d orders
 
   table name: orders
   table path: hdfs:/xxx/xxx/tpch/orders
@@ -98,4 +120,40 @@ Now look at the table description: ::
   o_orderpriority TEXT
   o_clerk TEXT
   o_shippriority  INT4
-  o_comment       TEXT
\ No newline at end of file
+  o_comment       TEXT
+
+The prompt ``default>`` indicates the current database. Basically, all SQL statements and meta commands work in the current database. Also, you can change the current database with ``\c`` command.
+
+.. code-block:: sql
+
+  default> \c work1
+  You are now connected to database "test" as user "hyunsik".
+  work1>
+
+-----------------------------------------------
+Session Variables
+-----------------------------------------------
+
+Each client connection to TajoMaster creates a unique session, and the client and TajoMaster uses the session until disconnect. A session provides session variables which are used for various configs per session.
+
+``tsql`` provides the meta command ``\set`` to manipulate session variables. Just ``\set`` command shows all session variables. ::
+
+  default> \set
+  'name1'='val1'
+  'name2'='val2'
+  'name3'='val3'
+       ...
+
+``\set key val`` will set the session variable named *key* with the value *val*. ::
+
+  default> \set
+  'CURRENT_DATABASE'='default'
+  
+  default> \set key1 val1
+
+  default> \set
+  'CURRENT_DATABASE'='default'
+  'key1'='val1'
+
+
+Also, ``\unset key`` will unset the session variable named *key*.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-docs/src/main/sphinx/configuration/catalog_configuration.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/configuration/catalog_configuration.rst b/tajo-docs/src/main/sphinx/configuration/catalog_configuration.rst
index 86899ba..80abd57 100644
--- a/tajo-docs/src/main/sphinx/configuration/catalog_configuration.rst
+++ b/tajo-docs/src/main/sphinx/configuration/catalog_configuration.rst
@@ -25,9 +25,21 @@ If you want to customize the catalog service, copy ``$TAJO_HOME/conf/catalog-sit
 MySQLStore Configuration
 =========================
 
-If you want to use MySQLStore, you must create database and user on mysql for tajo. 
+In order to use MySQLStore, you need to create database and user on MySQL for Tajo.
 
-And then, you need to prepare mysql jdbc driver on host which can be ran TajoMaster. If you do, you should set ``TAJO_CLASSPATH`` variable in ``conf/tajo-env.sh`` with it as follows:
+.. code-block:: sh
+  
+  mysql> create user 'tajo'@'localhost' identified by 'xxxxxx';
+  Query OK, 0 rows affected (0.00 sec)
+
+  mysql> create database tajo;
+  Query OK, 1 row affected (0.00 sec)  
+
+  mysql> grant all on tajo.* to 'tajo'@'localhost';
+  Query OK, 0 rows affected (0.01 sec)
+
+
+And then, you need to prepare MySQL JDBC driver on the machine which can be ran TajoMaster. If you do, you should set ``TAJO_CLASSPATH`` variable in ``conf/tajo-env.sh`` with it as follows:
 
 .. code-block:: sh
 

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-docs/src/main/sphinx/configuration/cluster_setup.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/configuration/cluster_setup.rst b/tajo-docs/src/main/sphinx/configuration/cluster_setup.rst
index e9715f3..89db12c 100644
--- a/tajo-docs/src/main/sphinx/configuration/cluster_setup.rst
+++ b/tajo-docs/src/main/sphinx/configuration/cluster_setup.rst
@@ -1,5 +1,5 @@
 *******************************************
-Custer Setup
+Cluster Setup
 *******************************************
 
 Fully Distributed Mode

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-docs/src/main/sphinx/sql_language/ddl.rst
----------------------------------------------------------------------
diff --git a/tajo-docs/src/main/sphinx/sql_language/ddl.rst b/tajo-docs/src/main/sphinx/sql_language/ddl.rst
index 2f0e9d4..e2e64f6 100644
--- a/tajo-docs/src/main/sphinx/sql_language/ddl.rst
+++ b/tajo-docs/src/main/sphinx/sql_language/ddl.rst
@@ -2,6 +2,29 @@
 Data Definition Language
 ************************
 
+========================
+CREATE DATABASE
+========================
+
+*Synopsis*
+
+.. code-block:: sql
+
+  CREATE DATABASE [IF NOT EXISTS] <database_name> 
+
+``IF NOT EXISTS`` allows ``CREATE DATABASE`` statement to avoid an error which occurs when the database exists.
+
+========================
+DROP DATABASE
+========================
+
+*Synopsis*
+
+.. code-block:: sql
+
+  DROP DATABASE [IF EXISTS] <database_name>
+
+``IF EXISTS`` allows ``DROP DATABASE`` statement to avoid an error which occurs when the database does not exist.
 
 ========================
 CREATE TABLE
@@ -11,15 +34,13 @@ CREATE TABLE
 
 .. code-block:: sql
 
-  CREATE TABLE <table_name> [(<column_name> <data_type>, ... )]
+  CREATE TABLE [IF NOT EXISTS] <table_name> [(<column_name> <data_type>, ... )]
   [using <storage_type> [with (<key> = <value>, ...)]] [AS <select_statement>]
 
-  CREATE EXTERNAL TABLE
-
-  CREATE EXTERNAL TABLE <table_name> (<column_name> <data_type>, ... )
+  CREATE EXTERNAL TABLE [IF NOT EXISTS] <table_name> (<column_name> <data_type>, ... )
   using <storage_type> [with (<key> = <value>, ...)] LOCATION '<path>'
 
-
+``IF NOT EXISTS`` allows ``CREATE [EXTERNAL] TABLE`` statement to avoid an error which occurs when the table does not exist.
 
 ------------------------
  Compression
@@ -48,6 +69,10 @@ If you want to add an external table that contains compressed data, you should g
  DROP TABLE
 ========================
 
+*Synopsis*
+
 .. code-block:: sql
 
-  DROP TABLE <table_name>
\ No newline at end of file
+  DROP TABLE [IF EXISTS] <table_name> [PURGE]
+
+``IF EXISTS`` allows ``DROP DATABASE`` statement to avoid an error which occurs when the database does not exist. ``DROP TABLE`` statement removes a table from Tajo catalog, but it does not remove the contents. If ``PURGE`` option is given, ``DROP TABLE`` statement will eliminate the entry in the catalog as well as the contents.
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoConnection.java
----------------------------------------------------------------------
diff --git a/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoConnection.java b/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoConnection.java
index b751d5d..5d967e8 100644
--- a/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoConnection.java
+++ b/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoConnection.java
@@ -1,4 +1,4 @@
-package org.apache.tajo.jdbc; /**
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -16,71 +16,83 @@ package org.apache.tajo.jdbc; /**
  * limitations under the License.
  */
 
+package org.apache.tajo.jdbc;
+
+import com.google.protobuf.ServiceException;
+import org.apache.tajo.TajoConstants;
 import org.apache.tajo.client.TajoClient;
 import org.apache.tajo.conf.TajoConf;
+import org.jboss.netty.handler.codec.http.QueryStringDecoder;
 
+import java.net.URI;
 import java.sql.*;
+import java.util.List;
 import java.util.Map;
 import java.util.Properties;
 import java.util.concurrent.Executor;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 public class TajoConnection implements Connection {
-  private TajoClient tajoClient;
-
-  private String databaseName;
-
-  private AtomicBoolean closed = new AtomicBoolean(true);
-
-  private String uri;
-
-  public TajoConnection(String uri, Properties properties) throws SQLException {
-    if (!uri.startsWith(TajoDriver.TAJO_JDBC_URL_PREFIX)) {
-      throw new SQLException("Invalid URL: " + uri, "TAJO-001");
-    }
-
-    this.uri = uri;
+  private final TajoClient tajoClient;
+  private final AtomicBoolean closed = new AtomicBoolean(true);
+  private final String rawURI;
+  private final Properties properties;
+
+  private final URI uri;
+  private final String hostName;
+  private final int port;
+  private final String databaseName;
+  @SuppressWarnings("unused")
+  /** it will be used soon. */
+  private final Map<String, List<String>> params;
+
+  public TajoConnection(String rawURI, Properties properties) throws SQLException {
+    this.rawURI = rawURI;
+    this.properties = properties;
 
-    // remove prefix
-    uri = uri.substring(TajoDriver.TAJO_JDBC_URL_PREFIX.length());
+    try {
+      if (!rawURI.startsWith(TajoDriver.TAJO_JDBC_URL_PREFIX)) {
+        throw new SQLException("Invalid URL: " + rawURI, "TAJO-001");
+      }
 
+      // URI form: jdbc:tajo://hostname:port/databasename
+      int startIdx = rawURI.indexOf(":");
+      if (startIdx < 0) {
+        throw new SQLException("Invalid URL: " + rawURI, "TAJO-001");
+      }
 
-    if (uri.isEmpty()) {
-      throw new SQLException("Invalid URL: " + uri, "TAJO-001");
-    }
+      String uri = rawURI.substring(startIdx+1, rawURI.length());
+      try {
+        this.uri = URI.create(uri);
+      } catch (IllegalArgumentException iae) {
+        throw new SQLException("Invalid URL: " + rawURI, "TAJO-001");
+      }
 
-    // parse uri
-    // form: hostname:port/databasename
-    String[] parts = uri.split("/");
-    if(parts.length == 0 || parts[0].trim().isEmpty()) {
-      throw new SQLException("Invalid URL(No tajo master's host:port): " + uri, "TAJO-001");
-    }
-    String[] hostAndPort = parts[0].trim().split(":");
-    String host = hostAndPort[0];
-    int port = 0;
-    try {
-      port = Integer.parseInt(hostAndPort[1]);
-    } catch (Exception e) {
-      throw new SQLException("Invalid URL(Wrong tajo master's host:port): " + uri, "TAJO-001");
-    }
+      hostName = this.uri.getHost();
+      if(hostName == null) {
+        throw new SQLException("Invalid JDBC URI: " + rawURI, "TAJO-001");
+      }
+      if (this.uri.getPort() < 1) {
+        port = 26002;
+      } else {
+        port = this.uri.getPort();
+      }
 
-    if(parts.length > 1) {
-      String[] tokens = parts[1].split("\\?");
-      databaseName = tokens[0].trim();
-      if(tokens.length > 1) {
-        String[] extraParamTokens = tokens[1].split("&");
-        for(String eachExtraParam: extraParamTokens) {
-          String[] paramTokens = eachExtraParam.split("=");
-          String extraParamKey = paramTokens[0];
-          String extraParamValue = paramTokens[1];
-        }
+      if (this.uri.getPath() == null) { // if no database is given, set default.
+        databaseName = TajoConstants.DEFAULT_DATABASE_NAME;
+      } else {
+        // getPath() will return '/database'.
+        databaseName = this.uri.getPath().split("/")[1];
       }
+
+      params = new QueryStringDecoder(rawURI).getParameters();
+    } catch (SQLException se) {
+      throw se;
+    } catch (Throwable t) { // for unexpected exceptions like ArrayIndexOutOfBoundsException.
+      throw new SQLException("Invalid JDBC URI: " + rawURI, "TAJO-001");
     }
 
     TajoConf tajoConf = new TajoConf();
-
-    tajoConf.setVar(TajoConf.ConfVars.TAJO_MASTER_CLIENT_RPC_ADDRESS, host + ":" + port);
-
     if(properties != null) {
       for(Map.Entry<Object, Object> entry: properties.entrySet()) {
         tajoConf.set(entry.getKey().toString(), entry.getValue().toString());
@@ -88,15 +100,15 @@ public class TajoConnection implements Connection {
     }
 
     try {
-      tajoClient = new TajoClient(tajoConf);
+      tajoClient = new TajoClient(hostName, port, databaseName);
     } catch (Exception e) {
-      throw new SQLException("Can't create tajo client:" + e.getMessage(), "TAJO-002");
+      throw new SQLException("Cannot create TajoClient instance:" + e.getMessage(), "TAJO-002");
     }
     closed.set(false);
   }
 
   public String getUri() {
-    return uri;
+    return this.rawURI;
   }
 
   public TajoClient getTajoClient() {
@@ -181,7 +193,11 @@ public class TajoConnection implements Connection {
 
   @Override
   public String getCatalog() throws SQLException {
-    return "";
+    try {
+      return tajoClient.getCurrentDatabase();
+    } catch (ServiceException e) {
+      throw new SQLException(e);
+    }
   }
 
   @Override
@@ -231,7 +247,8 @@ public class TajoConnection implements Connection {
 
   @Override
   public boolean isValid(int timeout) throws SQLException {
-    throw new SQLFeatureNotSupportedException("isValid");
+    // TODO - It should be changed to submit a simple query.
+    return tajoClient.isConnected();
   }
 
   @Override
@@ -313,7 +330,11 @@ public class TajoConnection implements Connection {
 
   @Override
   public void setCatalog(String catalog) throws SQLException {
-    throw new SQLFeatureNotSupportedException("setCatalog");
+    try {
+      tajoClient.selectDatabase(catalog);
+    } catch (ServiceException e) {
+      throw new SQLException(e);
+    }
   }
 
   @Override
@@ -373,12 +394,12 @@ public class TajoConnection implements Connection {
 
   public void abort(Executor executor) throws SQLException {
     // JDK 1.7
-    throw new SQLFeatureNotSupportedException("abort not supported");
+    throw new SQLFeatureNotSupportedException("abort is not supported");
   }
 
   public int getNetworkTimeout() throws SQLException {
     // JDK 1.7
-    throw new SQLFeatureNotSupportedException("getNetworkTimeout not supported");
+    throw new SQLFeatureNotSupportedException("getNetworkTimeout is not supported");
   }
 
   public void setNetworkTimeout(Executor executor, int milliseconds) throws SQLException {
@@ -387,12 +408,10 @@ public class TajoConnection implements Connection {
   }
 
   public String getSchema() throws SQLException {
-    // JDK 1.7
-    throw new SQLFeatureNotSupportedException("getSchema not supported");
+    return TajoConstants.DEFAULT_SCHEMA_NAME;
   }
 
   public void setSchema(String schema) throws SQLException {
-    // JDK 1.7
-    throw new SQLFeatureNotSupportedException("setSchema not supported");
+    throw new SQLFeatureNotSupportedException("setSchema() is not supported yet");
   }
 }

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoDatabaseMetaData.java b/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoDatabaseMetaData.java
index b3e67bc..f70b762 100644
--- a/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoDatabaseMetaData.java
+++ b/tajo-jdbc/src/main/java/org/apache/tajo/jdbc/TajoDatabaseMetaData.java
@@ -1,4 +1,4 @@
-package org.apache.tajo.jdbc; /**
+/**
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -15,8 +15,11 @@ package org.apache.tajo.jdbc; /**
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+package org.apache.tajo.jdbc;
 
+import com.google.protobuf.ServiceException;
 import org.apache.tajo.TajoConstants;
+import org.apache.tajo.annotation.Nullable;
 import org.apache.tajo.catalog.Column;
 import org.apache.tajo.catalog.TableDesc;
 import org.apache.tajo.client.ResultSetUtil;
@@ -28,6 +31,8 @@ import org.apache.tajo.datum.TextDatum;
 import java.sql.*;
 import java.util.*;
 
+import static org.apache.tajo.TajoConstants.DEFAULT_SCHEMA_NAME;
+
 /**
  * TajoDatabaseMetaData.
  */
@@ -375,7 +380,7 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
   }
 
   @Override
-  public ResultSet getTables(String catalog, String schemaPattern, String tableNamePattern, String[] types)
+  public ResultSet getTables(@Nullable String catalog, String schemaPattern, String tableNamePattern, String [] types)
       throws SQLException {
     try {
       final List<MetaDataTuple> resultTables = new ArrayList<MetaDataTuple>();
@@ -389,17 +394,17 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
       String regtableNamePattern = convertPattern(tableNamePattern);
       try {
         TajoClient tajoClient = conn.getTajoClient();
-        List<String> tableNames = tajoClient.getTableList();
+        List<String> tableNames = tajoClient.getTableList(resultCatalog);
         for (String eachTableName: tableNames) {
           if (eachTableName.matches(regtableNamePattern)) {
             MetaDataTuple tuple = new MetaDataTuple(5);
 
             int index = 0;
-            tuple.put(index++, new TextDatum(resultCatalog));  //TABLE_CAT
-            tuple.put(index++, NullDatum.get());   //TABLE_SCHEM
-            tuple.put(index++, new TextDatum(eachTableName));
-            tuple.put(index++, new TextDatum("TABLE"));   //TABLE_TYPE
-            tuple.put(index++, NullDatum.get());   //REMARKS
+            tuple.put(index++, new TextDatum(resultCatalog));         // TABLE_CAT
+            tuple.put(index++, new TextDatum(DEFAULT_SCHEMA_NAME));   // TABLE_SCHEM
+            tuple.put(index++, new TextDatum(eachTableName));         // TABLE_NAME
+            tuple.put(index++, new TextDatum("TABLE"));               // TABLE_TYPE
+            tuple.put(index++, NullDatum.get());                      // REMARKS
 
             resultTables.add(tuple);
           }
@@ -427,25 +432,44 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
   }
 
   @Override
-  public ResultSet getSchemas()
-      throws SQLException {
-    return getSchemas(null, null);
+  public ResultSet getSchemas() throws SQLException {
+    String databaseName;
+    try {
+      databaseName = conn.getTajoClient().getCurrentDatabase();
+    } catch (ServiceException e) {
+      throw new SQLException(e);
+    }
+
+    MetaDataTuple tuple = new MetaDataTuple(1);
+    tuple.put(0, new TextDatum(DEFAULT_SCHEMA_NAME));
+    tuple.put(1, new TextDatum(databaseName));
+
+    return new TajoMetaDataResultSet(
+        Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG"),
+        Arrays.asList(Type.VARCHAR, Type.VARCHAR),
+        Arrays.asList(tuple));
   }
 
   @Override
-  public ResultSet getCatalogs()
-      throws SQLException {
-    List<MetaDataTuple> columns = new ArrayList<MetaDataTuple>();
-    MetaDataTuple tuple = new MetaDataTuple(1);
-    tuple.put(0, new TextDatum("default"));
-    columns.add(tuple);
+  public ResultSet getCatalogs() throws SQLException {
+    Collection<String> databaseNames;
+    try {
+      databaseNames = conn.getTajoClient().getAllDatabaseNames();
+    } catch (ServiceException e) {
+      throw new SQLException(e);
+    }
 
-    ResultSet result = new TajoMetaDataResultSet(
-        Arrays.asList("TABLE_CAT")
-        , Arrays.asList(Type.VARCHAR)
-        , columns);
+    List<MetaDataTuple> tuples = new ArrayList<MetaDataTuple>();
+    for (String databaseName : databaseNames) {
+      MetaDataTuple tuple = new MetaDataTuple(1);
+      tuple.put(0, new TextDatum(databaseName));
+      tuples.add(tuple);
+    }
 
-    return result;
+    return new TajoMetaDataResultSet(
+        Arrays.asList("TABLE_CAT"),
+        Arrays.asList(Type.VARCHAR) ,
+        tuples);
   }
 
   @Override
@@ -482,13 +506,13 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
     List<MetaDataTuple> columns = new ArrayList<MetaDataTuple>();
     try {
       if (catalog == null) {
-        catalog = "default";
+        catalog = TajoConstants.DEFAULT_DATABASE_NAME;
       }
 
       String regtableNamePattern = convertPattern(tableNamePattern);
       String regcolumnNamePattern = convertPattern(columnNamePattern);
 
-      List<String> tables = conn.getTajoClient().getTableList();
+      List<String> tables = conn.getTajoClient().getTableList(catalog);
       for (String table: tables) {
         if (table.matches(regtableNamePattern)) {
           TableDesc tableDesc = conn.getTajoClient().getTableDesc(table);
@@ -499,7 +523,7 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
 
               int index = 0;
               tuple.put(index++, new TextDatum(catalog));  //TABLE_CAT
-              tuple.put(index++, NullDatum.get());  //TABLE_SCHEM
+              tuple.put(index++, new TextDatum(catalog));  //TABLE_SCHEM
               tuple.put(index++, new TextDatum(table));  //TABLE_NAME
               tuple.put(index++, new TextDatum(column.getSimpleName()));  //COLUMN_NAME
               // TODO - DATA_TYPE
@@ -685,12 +709,22 @@ public class TajoDatabaseMetaData implements DatabaseMetaData {
   }
 
   @Override
-  public ResultSet getSchemas(String catalog, String schemaPattern)
-      throws SQLException {
+  public ResultSet getSchemas(String catalog, String schemaPattern) throws SQLException {
+    String databaseName;
+    try {
+      databaseName = conn.getTajoClient().getCurrentDatabase();
+    } catch (ServiceException e) {
+      throw new SQLException(e);
+    }
+
+    MetaDataTuple tuple = new MetaDataTuple(1);
+    tuple.put(0, new TextDatum(DEFAULT_SCHEMA_NAME));
+    tuple.put(1, new TextDatum(databaseName));
+
     return new TajoMetaDataResultSet(
         Arrays.asList("TABLE_SCHEM", "TABLE_CATALOG"),
         Arrays.asList(Type.VARCHAR, Type.VARCHAR),
-        null);
+        Arrays.asList(tuple));
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/tajo/blob/3ba26241/tajo-project/pom.xml
----------------------------------------------------------------------
diff --git a/tajo-project/pom.xml b/tajo-project/pom.xml
index 59628a9..cae8602 100644
--- a/tajo-project/pom.xml
+++ b/tajo-project/pom.xml
@@ -770,7 +770,7 @@
       <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
-        <version>4.10</version>
+        <version>4.11</version>
         <type>jar</type>
         <scope>compile</scope>
       </dependency>


Mime
View raw message