You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafodion.apache.org by an...@apache.org on 2016/12/17 00:33:19 UTC
[3/7] incubator-trafodion git commit: TRAFODION-1586 Add support for
external Traf tables mappedd to HBase tables
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/EXPECTED022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED022 b/core/sql/regress/seabase/EXPECTED022
index bc10f77..fa3a3af 100644
--- a/core/sql/regress/seabase/EXPECTED022
+++ b/core/sql/regress/seabase/EXPECTED022
@@ -426,7 +426,7 @@ ROW_ID (EXPR)
>>invoke hbase."_CELL_".t022hbt2;
-- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current Thu Feb 25 09:47:53 2016
+-- Definition current Mon Dec 12 23:03:22 2016
(
ROW_ID VARCHAR(100) CHARACTER SET ISO88591
@@ -445,7 +445,7 @@ ROW_ID (EXPR)
>>invoke hbase."_ROW_".t022hbt2;
-- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current Thu Feb 25 09:47:53 2016
+-- Definition current Mon Dec 12 23:03:23 2016
(
ROW_ID VARCHAR(100) CHARACTER SET ISO88591
@@ -465,7 +465,7 @@ ROW_ID (EXPR)
>>invoke hbase."_CELL_".t022hbt2;
-- Definition of Trafodion table HBASE."_CELL_".T022HBT2
--- Definition current Thu Feb 25 09:47:53 2016
+-- Definition current Mon Dec 12 23:03:23 2016
(
ROW_ID VARCHAR(100) CHARACTER SET ISO88591
@@ -484,7 +484,7 @@ ROW_ID (EXPR)
>>invoke hbase."_ROW_".t022hbt2;
-- Definition of Trafodion table HBASE."_ROW_".T022HBT2
--- Definition current Thu Feb 25 09:47:53 2016
+-- Definition current Mon Dec 12 23:03:24 2016
(
ROW_ID VARCHAR(100) CHARACTER SET ISO88591
@@ -568,15 +568,871 @@ ROW_ID (EXPR)
--- 2 row(s) selected.
>>
->>?section cleanup
->>drop hbase table t022hbt1;
+>>
+>>-- tests to map hbase tables to relational traf tables
+>>cqd traf_hbase_mapped_tables 'ON';
+
+--- SQL operation complete.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1',
++> column_create(('cf:B', '100 ')));
+
+--- 1 row(s) inserted.
+>>insert into hbase."_ROW_".t022hbm1 values ('a2', column_create(('cf:A', 'a2')));
+
+--- 1 row(s) inserted.
+>>
+>>drop table if exists t022hbm1 cascade;
+
+--- SQL operation complete.
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b char(4))
++> primary key (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:03:37 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>-- if no schema is specified, table is looked in regular and then mapped schema
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:03:38 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>create table t022hbm1 (a int);
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion table TRAFODION.SCH.T022HBM1
+-- Definition current Mon Dec 12 23:03:40 2016
+
+ (
+ SYSKEY LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE
+ , A INT DEFAULT NULL
+ )
+
+--- SQL operation complete.
+>>drop table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:03:49 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>prepare s from select * from t022hbm1;
+
+--- SQL command prepared.
+>>execute s;
+
+A B
+---- ----
+
+a1 100
+a2 ?
+
+--- 2 row(s) selected.
+>>select * from t022hbm1 where a = 'a1';
+
+A B
+---- ----
+
+a1 100
+
+--- 1 row(s) selected.
+>>select a, cast(b as int) from t022hbm1;
+
+A (EXPR)
+---- -----------
+
+a1 100
+a2 ?
+
+--- 2 row(s) selected.
+>>
+>>alter table t022hbm1 add column "cf".c int;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:03:53 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT DEFAULT NULL
+ , "cf".C INT DEFAULT NULL /*added_col*/
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>-- create a traf table like a mapped table
+>>cqd schema reset;
+
+--- SQL operation complete.
+>>create table t022hbm1_like like t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1_like;
+
+-- Definition of Trafodion table TRAFODION.SCH.T022HBM1_LIKE
+-- Definition current Mon Dec 12 23:03:58 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT DEFAULT NULL
+ , "cf".C INT DEFAULT NULL
+ )
+ PRIMARY KEY (A ASC)
+
+--- SQL operation complete.
+>>
+>>insert into t022hbm1_like select * from t022hbm1;
+
+--- 2 row(s) inserted.
+>>select * from t022hbm1_like;
+
+A B C
+---- ---- -----------
+
+a1 100 ?
+a2 ? ?
+
+--- 2 row(s) selected.
+>>
+>>create table t022hbm1_ctas as select * from t022hbm1;
+
+--- 2 row(s) inserted.
+>>select * from t022hbm1_ctas;
+
+A B C
+---- ---- -----------
+
+a1 100 ?
+a2 ? ?
+
+--- 2 row(s) selected.
+>>
+>>-- create view on mapped table
+>>create view t022v1 as select * from t022hbm1;
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1 cascade;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+*** ERROR[4082] Object TRAFODION.SCH.T022HBM1 does not exist or is inaccessible.
+
+--- SQL operation failed with errors.
+>>create external table t022hbm1 ("cf".a varchar(4) not null,
++> b int)
++> primary key (a)
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:14 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>alter table t022hbm1 drop column b;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:17 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>alter table t022hbm1 add column "cf".b int;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:20 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL /*added_col*/
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>-- IUD operations on mapped tables
+>>cqd traf_hbase_mapped_tables_iud 'ON';
+
+--- SQL operation complete.
+>>
+>>cqd schema reset;
+
+--- SQL operation complete.
+>>delete from hbase."_ROW_".t022hbm1;
+
+--- 2 row(s) deleted.
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1
++> data format native;
+
+--- SQL operation complete.
+>>
+>>insert into t022hbm1 values ('a', 1);
+
+--- 1 row(s) inserted.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+a 1
+
+--- 1 row(s) selected.
+>>update t022hbm1 set b = b + 1;
+
+--- 1 row(s) updated.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+a 2
+
+--- 1 row(s) selected.
+>>insert into t022hbm1 values ('a', 1);
+
+*** ERROR[8102] The operation is prevented by a unique constraint.
+
+--- 0 row(s) inserted.
+>> -- should fail
+>>insert into t022hbm1 values ('b', null);
+
+--- 1 row(s) inserted.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+a 2
+b ?
+
+--- 2 row(s) selected.
+>>delete from t022hbm1 where a = 'a';
+
+--- 1 row(s) deleted.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+b ?
+
+--- 1 row(s) selected.
+>>update t022hbm1 set b = 10;
+
+--- 1 row(s) updated.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+b 10
+
+--- 1 row(s) selected.
+>>update t022hbm1 set b = null;
+
+--- 1 row(s) updated.
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+b ?
+
+--- 1 row(s) selected.
+>>delete from t022hbm1;
+
+--- 1 row(s) deleted.
+>>select * from t022hbm1;
+
+--- 0 row(s) selected.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a int not null, b int not null, c int)
++> primary key (a, b)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1
++> data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:35 2016
+
+ (
+ "cf".A INT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".C INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC, B ASC)
--- SQL operation complete.
->>drop hbase table t022hbt2;
+>>insert into t022hbm1 values (1,2,3);
+
+--- 1 row(s) inserted.
+>>insert into t022hbm1 values (1,2,3);
+
+*** ERROR[8102] The operation is prevented by a unique constraint.
+
+--- 0 row(s) inserted.
+>>insert into t022hbm1 values (1, 1, 1);
+
+--- 1 row(s) inserted.
+>>insert into t022hbm1 values (-1, -2, -3);
+
+--- 1 row(s) inserted.
+>>select * from t022hbm1;
+
+A B C
+----------- ----------- -----------
+
+ 1 1 1
+ 1 2 3
+ -1 -2 -3
+
+--- 3 row(s) selected.
+>>upsert into t022hbm1 values (1,2,4);
+
+--- 1 row(s) inserted.
+>>select * from t022hbm1;
+
+A B C
+----------- ----------- -----------
+
+ 1 1 1
+ 1 2 4
+ -1 -2 -3
+
+--- 3 row(s) selected.
+>>
+>>-- various serialization options
+>>drop external table t022hbm1;
--- SQL operation complete.
->>drop table t022t1;
+>>create external table t022hbm1 (a varchar(4) not null, primary key not serialized (a), b int)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:41 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a char(4) not null, primary key serialized (a), b int)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1
++> data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:49 2016
+
+ (
+ "cf".A CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, primary key(a), b int)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:54 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null primary key, b int)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:04:58 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key not serialized (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:05:03 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a char(4) not null, b int)
++> primary key serialized (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1
++> data format native;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:05:07 2016
+
+ (
+ "cf".A CHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop external table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:05:15 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1', column_create(('cf:B', '10')));
+
+--- 1 row(s) inserted.
+>>
+>>-- multi column families in mapped table
+>>drop external table if exists t022hbm2;
+
+--- SQL operation complete.
+>>drop hbase table t022hbm2;
+
+--- SQL operation complete.
+>>create hbase table t022hbm2 (column family 'cf1', column family 'cf2');
+
+--- SQL operation complete.
+>>create external table t022hbm2 ("cf1".A int, "cf2".B int,
++> "cf1".Z varchar(4) not null primary key)
++> map to hbase table t022hbm2;
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm2 values ('a11',
++> column_create(('cf1:A', '10'), ('cf2:B', '20')));
+
+--- 1 row(s) inserted.
+>>invoke t022hbm2;
+
+-- Definition of Trafodion HBase mapped table T022HBM2
+-- Definition current Mon Dec 12 23:05:29 2016
+
+ (
+ "cf1".A INT DEFAULT NULL
+ , "cf2".B INT DEFAULT NULL
+ , "cf1".Z VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ )
+ PRIMARY KEY NOT SERIALIZED (Z ASC)
+
+--- SQL operation complete.
+>>select * from t022hbm2;
+
+A B Z
+----------- ----------- ----
+
+ 10 20 a11
+
+--- 1 row(s) selected.
+>>
+>>-- error cases
+>>
+>>-- primary key cannot be missing
+>>select * from t022hbm1;
+
+A B
+---- -----------
+
+a1 10
+
+--- 1 row(s) selected.
+>>
+>>-- operations not allowed
+>>alter table t022hbm1 alter column "cf".b largeint;
+
+*** ERROR[3242] This statement is not supported. Reason: This feature not available for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>invoke t022hbm1;
+
+-- Definition of Trafodion HBase mapped table T022HBM1
+-- Definition current Mon Dec 12 23:05:32 2016
+
+ (
+ "cf".A VARCHAR(4) CHARACTER SET ISO88591 COLLATE
+ DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE
+ , "cf".B INT DEFAULT NULL
+ )
+ PRIMARY KEY NOT SERIALIZED (A ASC)
+
+--- SQL operation complete.
+>>
+>>set schema trafodion."_HB_MAP_";
+
+--- SQL operation complete.
+>>
+>>-- cannot invoke using map schema name
+>>invoke "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>-- cannot use "_HB_MAP_" in a table name
+>>prepare s from select * from t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>prepare s from select * from "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+*** ERROR[8822] The statement was not prepared.
+
+>>
+>>drop table "_HB_MAP_".t022hbm1;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+--- SQL operation failed with errors.
+>>alter table trafodion."_HB_MAP_".t022hbm1 drop column b;
+
+*** ERROR[4261] The schema name _HB_MAP_ is reserved for HBase mapped tables and cannot be explicitly specified.
+
+--- SQL operation failed with errors.
+>>
+>>set schema trafodion.sch;
+
+--- SQL operation complete.
+>>
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>
+>>-- cannot specify serialized option
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key serialized (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: SERIALIZED option cannot be specified for primary key of this table.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot be aligned format
+>>create external table t022hbm1 (a varchar(4) not null primary key)
++> attribute aligned format map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Aligned format cannot be specified for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>-- must specify pkey
+>>create external table t022hbm1 (a char(4)) map to hbase table t022hbm1;
+
+*** ERROR[4259] Primary Key clause must be specified for an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>-- external and hbase table names must be the same
+>>create external table t022hbm11 (a char(4) not null primary key)
++> map to hbase table t022hbm1;
+
+*** ERROR[1180] Trying to create an external HBASE table with a different schema or table name (T022HBM11) than the source table (T022HBM1). The external schema and table name must be the same as the source.
+
+--- SQL operation failed with errors.
+>>
+>>-- all non-pkey columns must be nullable
+>>create external table t022hbm1 (a varchar(4) not null primary key,
++> b int not null)
++> map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Non-key columns of an HBase mapped table must be nullable with default value of NULL.
+
+--- SQL operation failed with errors.
+>>
+>>-- all non-pkey columns must have default value of null
+>>create external table t022hbm1 (a varchar(4) not null primary key,
++> b int default 10)
++> map to hbase table t022hbm1;
+
+*** ERROR[3242] This statement is not supported. Reason: Non-key columns of an HBase mapped table must be nullable with default value of NULL.
+
+--- SQL operation failed with errors.
+>>
+>>-- mapped table already exist
+>>create external table t022hbm1 (a varchar(4) not null primary key)
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null primary key)
++> map to hbase table t022hbm1;
+
+*** ERROR[1390] Object TRAFODION."_HB_MAP_".T022HBM1 already exists in Trafodion.
+
+--- SQL operation failed with errors.
+>>
+>>-- hbase table doesn't exist
+>>create external table t022hbm11 (a char(4) not null primary key)
++> map to hbase table t022hbm11;
+
+*** ERROR[4260] HBase table(T022HBM11) to be mapped as an external table does not exist.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot create view in HB_MAP schema
+>>create view "_HB_MAP_".v as select * from t022hbm1;
+
+*** ERROR[1118] Creating object TRAFODION."_HB_MAP_".V is not allowed in a reserved system schema.
+
+--- SQL operation failed with errors.
+>>
+>>-- cannot create index on an hbase external table
+>>create index ti on t022hbm1 (a);
+
+*** ERROR[3242] This statement is not supported. Reason: Cannot create index on an HBase mapped table.
+
+--- SQL operation failed with errors.
+>>
+>>drop external table if exists t022hbm1;
+
+--- SQL operation complete.
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>create external table t022hbm1 (a varchar(4) not null, b int)
++> primary key (a)
++> attribute default column family 'cf'
++> map to hbase table t022hbm1;
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1',
++> column_create(('cf:A', '10')));
+
+--- 1 row(s) inserted.
+>>-- rowID must match pkey col contents
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1. Details: HBase rowID content must match the primary key column content.
+
+--- 0 row(s) selected.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1234567',
++> column_create(('cf:B', '10')));
+
+--- 1 row(s) inserted.
+>>-- primary key col length must be big enough to hold rowID
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1. Details: retrieved rowID of length 8 is larger than the specified key size of 4.
+
+--- 0 row(s) selected.
+>>
+>>drop hbase table t022hbm1;
+
+--- SQL operation complete.
+>>create hbase table t022hbm1 (column family 'cf');
+
+--- SQL operation complete.
+>>insert into hbase."_ROW_".t022hbm1 values ('a1',
++> column_create(('cf:B', '1000000')));
+
+--- 1 row(s) inserted.
+>>-- buffer to retrieve column value must be big enough
+>>cqd hbase_max_column_val_length '5';
+
+--- SQL operation complete.
+>>select * from t022hbm1;
+
+*** ERROR[8556] An error occurred while accessing HBase table T022HBM1. Details: actual column value length of 7 is greater than the expected max buffer size of 5.
+
+--- 0 row(s) selected.
>>
>>log;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/EXPECTED027
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/EXPECTED027 b/core/sql/regress/seabase/EXPECTED027
index 9cde4f7..1de53cc 100644
--- a/core/sql/regress/seabase/EXPECTED027
+++ b/core/sql/regress/seabase/EXPECTED027
@@ -1239,7 +1239,7 @@ SCH027.T027V1
--- SQL operation failed with errors.
>>alter table t027v1 alter column a smallint;
-*** ERROR[1146] Object TRAFODION.SCH027.T027V1 could not be altered because it either does not exist or is not a table.
+*** ERROR[1127] The specified table TRAFODION.SCH027.T027V1 does not exist, is inaccessible or is not a base table. Please verify that the correct table was specified.
--- SQL operation failed with errors.
>>get all views on table t027t7;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/seabase/TEST022
----------------------------------------------------------------------
diff --git a/core/sql/regress/seabase/TEST022 b/core/sql/regress/seabase/TEST022
index 58339b4..80fdaa0 100644
--- a/core/sql/regress/seabase/TEST022
+++ b/core/sql/regress/seabase/TEST022
@@ -20,7 +20,11 @@
-- under the License.
--
-- @@@ END COPYRIGHT @@@
+
+obey TEST022(clean_up);
+
cqd hbase_delete_costing 'off';
+
log LOG022 clear;
cqd hbase_native_iud 'ON';
@@ -184,9 +188,285 @@ select char_length(column_details) from hbase."_ROW_".t022hbt2;
select left(row_id, 10) row_id, left(column_display(column_details), 40)
from hbase."_ROW_".t022hbt2;
-?section cleanup
+
+-- tests to map hbase tables to relational traf tables
+cqd traf_hbase_mapped_tables 'ON';
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1',
+ column_create(('cf:B', '100 ')));
+insert into hbase."_ROW_".t022hbm1 values ('a2', column_create(('cf:A', 'a2')));
+
+drop table if exists t022hbm1 cascade;
+drop external table if exists t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b char(4))
+ primary key (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+-- if no schema is specified, table is looked in regular and then mapped schema
+invoke t022hbm1;
+create table t022hbm1 (a int);
+invoke t022hbm1;
+drop table t022hbm1;
+invoke t022hbm1;
+
+prepare s from select * from t022hbm1;
+execute s;
+select * from t022hbm1 where a = 'a1';
+select a, cast(b as int) from t022hbm1;
+
+alter table t022hbm1 add column "cf".c int;
+invoke t022hbm1;
+
+-- create a traf table like a mapped table
+cqd schema reset;
+create table t022hbm1_like like t022hbm1;
+invoke t022hbm1_like;
+
+insert into t022hbm1_like select * from t022hbm1;
+select * from t022hbm1_like;
+
+create table t022hbm1_ctas as select * from t022hbm1;
+select * from t022hbm1_ctas;
+
+-- create view on mapped table
+create view t022v1 as select * from t022hbm1;
+
+drop external table t022hbm1 cascade;
+invoke t022hbm1;
+create external table t022hbm1 ("cf".a varchar(4) not null,
+ b int)
+ primary key (a)
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+alter table t022hbm1 drop column b;
+invoke t022hbm1;
+
+alter table t022hbm1 add column "cf".b int;
+invoke t022hbm1;
+
+-- IUD operations on mapped tables
+cqd traf_hbase_mapped_tables_iud 'ON';
+
+cqd schema reset;
+delete from hbase."_ROW_".t022hbm1;
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1
+ data format native;
+
+insert into t022hbm1 values ('a', 1);
+select * from t022hbm1;
+update t022hbm1 set b = b + 1;
+select * from t022hbm1;
+insert into t022hbm1 values ('a', 1); -- should fail
+insert into t022hbm1 values ('b', null);
+select * from t022hbm1;
+delete from t022hbm1 where a = 'a';
+select * from t022hbm1;
+update t022hbm1 set b = 10;
+select * from t022hbm1;
+update t022hbm1 set b = null;
+select * from t022hbm1;
+delete from t022hbm1;
+select * from t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a int not null, b int not null, c int)
+ primary key (a, b)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1
+ data format native;
+invoke t022hbm1;
+insert into t022hbm1 values (1,2,3);
+insert into t022hbm1 values (1,2,3);
+insert into t022hbm1 values (1, 1, 1);
+insert into t022hbm1 values (-1, -2, -3);
+select * from t022hbm1;
+upsert into t022hbm1 values (1,2,4);
+select * from t022hbm1;
+
+-- various serialization options
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, primary key not serialized (a), b int)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a char(4) not null, primary key serialized (a), b int)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1
+ data format native;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, primary key(a), b int)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null primary key, b int)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key not serialized (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a char(4) not null, b int)
+ primary key serialized (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1
+ data format native;
+invoke t022hbm1;
+
+drop external table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+invoke t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+drop external table if exists t022hbm1;
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+insert into hbase."_ROW_".t022hbm1 values ('a1', column_create(('cf:B', '10')));
+
+-- multi column families in mapped table
+drop external table if exists t022hbm2;
+drop hbase table t022hbm2;
+create hbase table t022hbm2 (column family 'cf1', column family 'cf2');
+create external table t022hbm2 ("cf1".A int, "cf2".B int,
+ "cf1".Z varchar(4) not null primary key)
+ map to hbase table t022hbm2;
+insert into hbase."_ROW_".t022hbm2 values ('a11',
+ column_create(('cf1:A', '10'), ('cf2:B', '20')));
+invoke t022hbm2;
+select * from t022hbm2;
+
+-- error cases
+
+-- primary key cannot be missing
+select * from t022hbm1;
+
+-- operations not allowed
+alter table t022hbm1 alter column "cf".b largeint;
+invoke t022hbm1;
+
+set schema trafodion."_HB_MAP_";
+
+-- cannot invoke using map schema name
+invoke "_HB_MAP_".t022hbm1;
+
+-- cannot use "_HB_MAP_" in a table name
+prepare s from select * from t022hbm1;
+prepare s from select * from "_HB_MAP_".t022hbm1;
+
+drop table "_HB_MAP_".t022hbm1;
+alter table trafodion."_HB_MAP_".t022hbm1 drop column b;
+
+set schema trafodion.sch;
+
+drop external table if exists t022hbm1;
+
+-- cannot specify serialized option
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key serialized (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+
+-- cannot be aligned format
+create external table t022hbm1 (a varchar(4) not null primary key)
+ attribute aligned format map to hbase table t022hbm1;
+
+-- must specify pkey
+create external table t022hbm1 (a char(4)) map to hbase table t022hbm1;
+
+-- external and hbase table names must be the same
+create external table t022hbm11 (a char(4) not null primary key)
+ map to hbase table t022hbm1;
+
+-- all non-pkey columns must be nullable
+create external table t022hbm1 (a varchar(4) not null primary key,
+ b int not null)
+ map to hbase table t022hbm1;
+
+-- all non-pkey columns must have default value of null
+create external table t022hbm1 (a varchar(4) not null primary key,
+ b int default 10)
+ map to hbase table t022hbm1;
+
+-- mapped table already exist
+create external table t022hbm1 (a varchar(4) not null primary key)
+ map to hbase table t022hbm1;
+create external table t022hbm1 (a varchar(4) not null primary key)
+ map to hbase table t022hbm1;
+
+-- hbase table doesn't exist
+create external table t022hbm11 (a char(4) not null primary key)
+ map to hbase table t022hbm11;
+
+-- cannot create view in HB_MAP schema
+create view "_HB_MAP_".v as select * from t022hbm1;
+
+-- cannot create index on an hbase external table
+create index ti on t022hbm1 (a);
+
+drop external table if exists t022hbm1;
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+create external table t022hbm1 (a varchar(4) not null, b int)
+ primary key (a)
+ attribute default column family 'cf'
+ map to hbase table t022hbm1;
+insert into hbase."_ROW_".t022hbm1 values ('a1',
+ column_create(('cf:A', '10')));
+-- rowID must match pkey col contents
+select * from t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1234567',
+ column_create(('cf:B', '10')));
+-- primary key col length must be big enough to hold rowID
+select * from t022hbm1;
+
+drop hbase table t022hbm1;
+create hbase table t022hbm1 (column family 'cf');
+insert into hbase."_ROW_".t022hbm1 values ('a1',
+ column_create(('cf:B', '1000000')));
+-- buffer to retrieve column value must be big enough
+cqd hbase_max_column_val_length '5';
+select * from t022hbm1;
+
+log;
+
+?section clean_up
+cqd schema reset;
+drop view t022v1;
drop hbase table t022hbt1;
drop hbase table t022hbt2;
+drop hbase table t022hbm1;
+drop hbase table t022hbm11;
+drop table t022hbm1_like;
+drop table t022hbm1_ctas;
drop table t022t1;
+drop table t022hbm1 cascade;
-log;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/regress/tools/regress-filter-linux
----------------------------------------------------------------------
diff --git a/core/sql/regress/tools/regress-filter-linux b/core/sql/regress/tools/regress-filter-linux
index addb947..15ce771 100755
--- a/core/sql/regress/tools/regress-filter-linux
+++ b/core/sql/regress/tools/regress-filter-linux
@@ -280,8 +280,8 @@ s/\(EXTERNAL PATH\) '[^']*'/\1 '@path@'/
# For SHOWLABEL COMPRESSION
s/\\(ATTRIBUTES \\([^,][^,]*, \\)\\{0,1\\}\\)[ NO]*COMPRESSION/\1@compress@/g
-s/ SERIALIZED//
-s/ NOT SERIALIZED//
+#s/ SERIALIZED//
+#s/ NOT SERIALIZED//
# For error 11205 (Java class not found)
/ERROR\[11205\]/s/\(external path\) '[^']*'/\1 '@path@'/
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/smdio/CmUtil.cpp
----------------------------------------------------------------------
diff --git a/core/sql/smdio/CmUtil.cpp b/core/sql/smdio/CmUtil.cpp
index aa2acbb..7a0c96d 100644
--- a/core/sql/smdio/CmUtil.cpp
+++ b/core/sql/smdio/CmUtil.cpp
@@ -140,7 +140,6 @@ defXLateFuncs(CmGetComAccPathTypeAsAccessPathType, CmGetComAccPathTypeAsLit, Com
const literalAndEnumStruct RowFormatXlateArray [] =
{
{COM_ALIGNED_FORMAT_TYPE, COM_ALIGNED_FORMAT_LIT},
- {COM_PACKED_FORMAT_TYPE, COM_PACKED_FORMAT_LIT},
{COM_UNKNOWN_FORMAT_TYPE, COM_UNKNOWN_FORMAT_LIT}
};
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcat/TrafDDLdesc.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcat/TrafDDLdesc.h b/core/sql/sqlcat/TrafDDLdesc.h
index 34c1d2f..601ad96 100644
--- a/core/sql/sqlcat/TrafDDLdesc.h
+++ b/core/sql/sqlcat/TrafDDLdesc.h
@@ -363,13 +363,18 @@ public:
enum ConstrntsDescFlags
{
- ENFORCED = 0x0001
+ ENFORCED = 0x0001,
+ NOT_SERIALIZED = 0x0002
};
void setEnforced(NABoolean v)
{(v ? constrntsDescFlags |= ENFORCED : constrntsDescFlags &= ~ENFORCED); };
NABoolean isEnforced() { return (constrntsDescFlags & ENFORCED) != 0; };
+ void setNotSerialized(NABoolean v)
+ {(v ? constrntsDescFlags |= NOT_SERIALIZED : constrntsDescFlags &= ~NOT_SERIALIZED); };
+ NABoolean notSerialized() { return (constrntsDescFlags & NOT_SERIALIZED) != 0; };
+
char* constrntname;
char* tablename;
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcat/desc.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcat/desc.h b/core/sql/sqlcat/desc.h
deleted file mode 100644
index 0575b73..0000000
--- a/core/sql/sqlcat/desc.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/**********************************************************************
-// @@@ START COPYRIGHT @@@
-//
-// 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
-// regarding copyright ownership. The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License. You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied. See the License for the
-// specific language governing permissions and limitations
-// under the License.
-//
-// @@@ END COPYRIGHT @@@
-//
-**********************************************************************/
-#ifndef DESC_H
-#define DESC_H
-
-obsolete file, should not be included. Will give syntax error if it is.
-
-#endif
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpDescribe.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpDescribe.cpp b/core/sql/sqlcomp/CmpDescribe.cpp
index a8337ee..32fdd27 100644
--- a/core/sql/sqlcomp/CmpDescribe.cpp
+++ b/core/sql/sqlcomp/CmpDescribe.cpp
@@ -191,26 +191,27 @@ short CmpDescribeHiveTable (
CollHeap *heap);
short CmpDescribeSeabaseTable (
- const CorrName &dtName,
- short type, // 1, invoke. 2, showddl. 3, createLike
- char* &outbuf,
- ULng32 &outbuflen,
- CollHeap *heap,
- const char * pkeyStr = NULL,
- NABoolean withPartns = FALSE,
- NABoolean withoutSalt = FALSE,
- NABoolean withoutDivisioning = FALSE,
- UInt32 columnLengthLimit = UINT_MAX,
- NABoolean noTrailingSemi = FALSE,
-
- // used to add,rem,alter column definition from col list.
- // valid for 'createLike' mode.
- // Used for 'alter add/drop/alter col'.
- char * colName = NULL,
- short ada = 0, // 0,add. 1,drop. 2,alter
- const NAColumn * nacol = NULL,
- const NAType * natype = NULL,
- Space *inSpace = NULL);
+ const CorrName &dtName,
+ short type, // 1, invoke. 2, showddl. 3, createLike
+ char* &outbuf,
+ ULng32 &outbuflen,
+ CollHeap *heap,
+ const char * pkeyStr = NULL,
+ NABoolean withPartns = FALSE,
+ NABoolean withoutSalt = FALSE,
+ NABoolean withoutDivisioning = FALSE,
+ NABoolean withoutRowFormat = FALSE,
+ UInt32 columnLengthLimit = UINT_MAX,
+ NABoolean noTrailingSemi = FALSE,
+
+ // used to add,rem,alter column definition from col list.
+ // valid for 'createLike' mode.
+ // Used for 'alter add/drop/alter col'.
+ char * colName = NULL,
+ short ada = 0, // 0,add. 1,drop. 2,alter
+ const NAColumn * nacol = NULL,
+ const NAType * natype = NULL,
+ Space *inSpace = NULL);
short CmpDescribeSequence (
const CorrName &dtName,
@@ -2354,7 +2355,8 @@ short CmpDescribeHiveTable (
type,
dummyBuf, dummyLen, heap,
NULL,
- TRUE, FALSE, FALSE, UINT_MAX, TRUE,
+ TRUE, FALSE, FALSE, FALSE,
+ UINT_MAX, TRUE,
NULL, 0, NULL, NULL, &space);
outputShortLine(space, ";");
@@ -2404,14 +2406,24 @@ short cmpDisplayColumn(const NAColumn *nac,
colFam = "";
else if (nac->getNATable() && nac->getNATable()->isSeabaseTable())
{
- int index = 0;
- CmpSeabaseDDL::extractTrafColFam(nac->getHbaseColFam(), index);
-
- if (index >= naTable->allColFams().entries())
- return -1;
+ const char * col_fam = NULL;
+ if (nac->getNATable()->isHbaseMapTable())
+ {
+ col_fam = nac->getHbaseColFam().data();
+ }
+ else
+ {
+ int index = 0;
+ CmpSeabaseDDL::extractTrafColFam(nac->getHbaseColFam(), index);
+
+ if (index >= naTable->allColFams().entries())
+ return -1;
- colFam = ANSI_ID(naTable->allColFams()[index].data());
+ col_fam = naTable->allColFams()[index].data();
+ }
+ colFam = ANSI_ID(col_fam);
+
colFam += ".";
}
@@ -2722,6 +2734,7 @@ short CmpDescribeSeabaseTable (
NABoolean withPartns,
NABoolean withoutSalt,
NABoolean withoutDivisioning,
+ NABoolean withoutRowFormat,
UInt32 columnLengthLimit,
NABoolean noTrailingSemi,
char * colName,
@@ -2745,8 +2758,9 @@ short CmpDescribeSeabaseTable (
// set isExternalTable to allow Hive External tables to be described
BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
- bindWA.setAllowExternalTables (TRUE);
- NATable *naTable = bindWA.getNATable((CorrName&)dtName);
+
+ NATable *naTable = bindWA.getNATableInternal((CorrName&)dtName);
+
TableDesc *tdesc = NULL;
if (naTable == NULL || bindWA.errStatus())
return -1;
@@ -2766,6 +2780,7 @@ short CmpDescribeSeabaseTable (
NABoolean isVolatile = naTable->isVolatileTable();
NABoolean isExternalTable = naTable->isExternalTable();
+ NABoolean isHbaseMapTable = naTable->isHbaseMapTable();
NABoolean isExternalHbaseTable = FALSE;
NABoolean isExternalHiveTable = FALSE;
@@ -2924,16 +2939,28 @@ short CmpDescribeSeabaseTable (
else
sprintf(buf, "-- Definition of Trafodion%stable %s\n"
"-- Definition current %s",
- (isVolatile ? " volatile " : isExternalTable ? " external " : " "),
- tableName.data(),
+ (isVolatile ? " volatile " :
+ (isHbaseMapTable ? " HBase mapped " :
+ (isExternalTable ? " external " : " "))),
+ (isHbaseMapTable ? objectName.data() :
+ tableName.data()),
ctime(&tp));
outputShortLine(*space, buf);
}
else if (type == 2)
{
- sprintf(buf, "CREATE%sTABLE %s",
- (isVolatile ? " VOLATILE " : isExternalTable ? " EXTERNAL " : " "),
- (isExternalTable ? objectName.data() : tableName.data()));
+ NAString tabType;
+ if (isVolatile)
+ tabType = " VOLATILE ";
+ else if (isExternalTable)
+ tabType = " EXTERNAL ";
+ else
+ tabType = " ";
+
+ sprintf(
+ buf, "CREATE%sTABLE %s",
+ tabType.data(),
+ (isExternalTable ? objectName.data() : tableName.data()));
outputShortLine(*space, buf);
}
@@ -2942,7 +2969,8 @@ short CmpDescribeSeabaseTable (
NAList<const NAColumn *> truncatedColumnList(heap);
if ((NOT isExternalTable) ||
((isExternalTable) &&
- ((isExternalHbaseTable && (type == 1)) ||
+ ((isExternalHbaseTable && ((type == 1) || (type == 3))) ||
+ (isExternalHbaseTable && naTable->isHbaseMapTable() && (type == 2)) ||
(isExternalHiveTable && (type != 2)) ||
(isExternalHiveTable && (type == 2) && (naTable->hiveExtColAttrs())))))
{
@@ -2952,7 +2980,8 @@ short CmpDescribeSeabaseTable (
displaySystemCols,
FALSE,
identityColPos,
- isExternalTable, naTable->isSQLMXAlignedTable(),
+ (isExternalTable && (NOT isHbaseMapTable)),
+ naTable->isSQLMXAlignedTable(),
colName, ada, nacol, natype,
columnLengthLimit,
&truncatedColumnList);
@@ -3045,6 +3074,22 @@ short CmpDescribeSeabaseTable (
else
sprintf(buf, " , PRIMARY KEY ");
+ // if all primary key columns are 'not serialized primary key',
+ // then display that.
+ NABoolean serialized = FALSE;
+ for (Int32 jj = 0;
+ ((NOT serialized) && (jj < naf->getIndexKeyColumns().entries())); jj++)
+ {
+ NAColumn * nac = (naf->getIndexKeyColumns())[jj];
+ if (NOT nac->isPrimaryKeyNotSerialized())
+ serialized = TRUE;
+ }
+
+ if (((type == 1) || (type == 2)) && (NOT serialized))
+ {
+ strcat(&buf[strlen(buf)], "NOT SERIALIZED ");
+ }
+
cmpDisplayPrimaryKey(naf->getIndexKeyColumns(),
naf->getIndexKeyColumns().entries(),
displaySystemCols,
@@ -3171,17 +3216,30 @@ short CmpDescribeSeabaseTable (
}
NABoolean attributesSet = FALSE;
- if ((((NOT isAudited) || (isAligned))) ||
+ NABoolean formatSet = FALSE;
+ char attrs[2000];
+ if ((type == 3/*create like*/) && (NOT withoutRowFormat))
+ {
+ strcpy(attrs, " ATTRIBUTES ");
+ if (isAligned)
+ strcat(attrs, "ALIGNED FORMAT ");
+ else
+ strcat(attrs, "HBASE FORMAT ");
+ attributesSet = TRUE;
+ formatSet = TRUE;
+ }
+
+ if (((NOT isAudited) || (isAligned)) ||
((sqlmxRegr) && (type == 3) && ((NOT isAudited) || (isAligned))) ||
((NOT naTable->defaultColFam().isNull()) &&
(naTable->defaultColFam() != SEABASE_DEFAULT_COL_FAMILY)))
{
- char attrs[2000];
- strcpy(attrs, " ATTRIBUTES ");
+ if (NOT attributesSet)
+ strcpy(attrs, " ATTRIBUTES ");
if (NOT isAudited)
strcat(attrs, "NO AUDIT ");
- if (isAligned)
+ if ((NOT formatSet) && isAligned)
strcat(attrs, "ALIGNED FORMAT ");
if ((NOT naTable->defaultColFam().isNull()) &&
(naTable->defaultColFam() != SEABASE_DEFAULT_COL_FAMILY))
@@ -3190,9 +3248,13 @@ short CmpDescribeSeabaseTable (
strcat(attrs, naTable->defaultColFam());
strcat(attrs, "'");
}
- outputShortLine(*space, attrs);
+
+ attributesSet = TRUE;
}
+ if (attributesSet)
+ outputShortLine(*space, attrs);
+
if (!isView && (naTable->hbaseCreateOptions()) &&
(naTable->hbaseCreateOptions()->entries() > 0))
{
@@ -3215,12 +3277,21 @@ short CmpDescribeSeabaseTable (
}
if ((isExternalTable) &&
+ (NOT isHbaseMapTable) &&
(type == 2))
{
sprintf(buf, " FOR %s", extName.data());
outputShortLine(*space, buf);
}
+ if ((isHbaseMapTable) && (type != 3))
+ {
+ sprintf(buf, " MAP TO HBASE TABLE %s DATA FORMAT %s",
+ dtName.getQualifiedNameObj().getObjectName().data(),
+ (naTable->isHbaseDataFormatString() ? "VARCHAR" : "NATIVE"));
+ outputShortLine(*space, buf);
+ }
+
if (NOT noTrailingSemi)
outputShortLine(*space, ";");
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDL.h
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDL.h b/core/sql/sqlcomp/CmpSeabaseDDL.h
index ae5a31f..d18b0c2 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDL.h
+++ b/core/sql/sqlcomp/CmpSeabaseDDL.h
@@ -443,6 +443,10 @@ class CmpSeabaseDDL
READ_OBJECT_DESC = 0x0008
};
+ enum
+ {
+ MD_TABLE_CONSTRAINTS_PKEY_NOT_SERIALIZED_FLG = 0x0001
+ };
protected:
void setFlags(ULng32 &flags, ULng32 flagbits)
@@ -973,8 +977,23 @@ protected:
const NAString &schName,
const NAString &objName,
const ComObjectType objectType,
- NABoolean dontForceCleanup);
+ NABoolean ddlXns);
+ short setupAndErrorChecks(NAString &tabName, QualifiedName &origTableName,
+ NAString &currCatName, NAString &currSchName,
+ NAString &catalogNamePart,
+ NAString &schemaNamePart,
+ NAString &objectNamePart,
+ NAString &extTableName, NAString &extNameForHbase,
+ CorrName &cn,
+ NATable* *naTable,
+ NABoolean volTabSupported,
+ NABoolean hbaseMapSupported,
+ ExeCliInterface *cliInterface,
+ const ComObjectType objectType = COM_BASE_TABLE_OBJECT,
+ SQLOperation operation = SQLOperation::ALTER_TABLE,
+ NABoolean isExternal = FALSE);
+
void purgedataObjectAfterError(
ExeCliInterface &cliInterface,
const NAString &catName,
@@ -1005,11 +1024,13 @@ protected:
const NAString &likeTabName,
NABoolean withPartns = FALSE,
NABoolean withoutSalt = FALSE,
- NABoolean withoutDivision = FALSE);
+ NABoolean withoutDivision = FALSE,
+ NABoolean withoutRowFormat = FALSE);
void createSeabaseTableLike(
- StmtDDLCreateTable * createTableNode,
- NAString &currCatName, NAString &currSchName);
+ ExeCliInterface *cliInterface,
+ StmtDDLCreateTable * createTableNode,
+ NAString &currCatName, NAString &currSchName);
short createSeabaseTableExternal(
ExeCliInterface &cliInterface,
@@ -1494,6 +1515,13 @@ protected:
NAString& hco); // out
+ short lookForTableInMD(
+ ExeCliInterface *cliInterface,
+ NAString &catNamePart, NAString &schNamePart, NAString &objNamePart,
+ NABoolean schNameSpecified, NABoolean isHbaseMapSpecified,
+ ComObjectName &tableName, NAString &tabName, NAString &extTableName,
+ const ComObjectType objectType = COM_BASE_TABLE_OBJECT);
+
private:
enum
{
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
index a2afca3..47c18b9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcleanup.cpp
@@ -1099,7 +1099,8 @@ short CmpSeabaseMDcleanup::cleanupOrphanObjectsEntries(ExeCliInterface *cliInter
char query[1000];
NABoolean errorSeen = FALSE;
- // find out all entries which do not have corresponsing hbase objects
+ // find out all entries which do not have corresponding hbase objects.
+ // Do not include metadata, repository and external tables.
str_sprintf(query, "select object_uid, trim(catalog_name) || '.' || trim(schema_name) || '.' || trim(object_name) from %s.\"%s\".%s where catalog_name = '%s' and schema_name not in ( '_MD_', '_REPOS_', '_PRIVMGR_MD_') and schema_name not like '|_HV|_%%|_' escape '|' and schema_name not like '|_HB|_%%|_' escape '|' and (object_type = 'BT' or object_type = 'IX') ",
getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_OBJECTS,
getSystemCatalog());
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
index af4d287..8d28d38 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp
@@ -4840,6 +4840,8 @@ short CmpSeabaseDDL::updateSeabaseMDTable(
isAudited = tableInfo->isAudited;
if (tableInfo->rowFormat == COM_ALIGNED_FORMAT_TYPE)
strcpy(rowFormat, COM_ALIGNED_FORMAT_LIT);
+ else if (tableInfo->rowFormat == COM_HBASE_STR_FORMAT_TYPE)
+ strcpy(rowFormat, COM_HBASE_STR_FORMAT_LIT);
numSaltPartns = tableInfo->numSaltPartns;
hbaseCreateOptions = tableInfo->hbaseCreateOptions;
}
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp b/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
index 6f0ecd0..d0cabd9 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLindex.cpp
@@ -407,6 +407,10 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
NAString extTableName = tableName.getExternalName(TRUE);
NAString extTableNameForHbase =
btCatalogNamePart + "." + btSchemaNamePart + "." + btObjectNamePart;
+ NAString tabName = (NAString&)createIndexNode->getTableName();
+
+ NABoolean schNameSpecified =
+ (NOT createIndexNode->getOrigTableNameAsQualifiedName().getSchemaName().isNull());
ComObjectName indexName(createIndexNode->getIndexName());
indexName.applyDefaults(btCatalogNamePart, btSchemaNamePart);
@@ -421,7 +425,8 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
if (ehi == NULL)
return;
- if ((isSeabaseReservedSchema(indexName)) &&
+ if (((isSeabaseReservedSchema(indexName)) ||
+ (ComIsTrafodionExternalSchemaName(schemaNamePart))) &&
(!Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)))
{
*CmpCommon::diags() << DgSqlCode(-1118)
@@ -503,12 +508,10 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
}
- retcode = existsInSeabaseMDTable(&cliInterface,
- btCatalogNamePart, btSchemaNamePart, btObjectNamePart,
- COM_BASE_TABLE_OBJECT,
- (Get_SqlParser_Flags(INTERNAL_QUERY_FROM_EXEUTIL)
- ? FALSE : TRUE),
- TRUE, TRUE);
+ retcode = lookForTableInMD(&cliInterface,
+ btCatalogNamePart, btSchemaNamePart, btObjectNamePart,
+ schNameSpecified, FALSE,
+ tableName, tabName, extTableName);
if (retcode < 0)
{
processReturn();
@@ -518,20 +521,13 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
ActiveSchemaDB()->getNATableDB()->useCache();
- // save the current parserflags setting
- ULng32 savedParserFlags = Get_SqlParser_Flags (0xFFFFFFFF);
- Set_SqlParser_Flags(ALLOW_VOLATILE_SCHEMA_IN_TABLE_NAME);
-
BindWA bindWA(ActiveSchemaDB(), CmpCommon::context(), FALSE/*inDDL*/);
CorrName cn(tableName.getObjectNamePart().getInternalName(),
STMTHEAP,
btSchemaNamePart,
btCatalogNamePart);
- NATable *naTable = bindWA.getNATable(cn);
-
- // Save parser flags settings so they can be restored later
- Set_SqlParser_Flags (savedParserFlags);
+ NATable *naTable = bindWA.getNATableInternal(cn);
if (naTable == NULL || bindWA.errStatus())
{
@@ -557,6 +553,18 @@ void CmpSeabaseDDL::createSeabaseIndex( StmtDDLCreateIndex * createIndexNode,
Int64 btObjUID = naTable->objectUid().castToInt64();
+ if (naTable->isHbaseMapTable())
+ {
+ // not supported
+ *CmpCommon::diags() << DgSqlCode(-3242)
+ << DgString0("Cannot create index on an HBase mapped table.");
+
+ deallocEHI(ehi);
+ processReturn();
+
+ return;
+ }
+
NAString &indexColFam = naTable->defaultColFam();
NAString trafColFam;
if (indexColFam != SEABASE_DEFAULT_COL_FAMILY)
http://git-wip-us.apache.org/repos/asf/incubator-trafodion/blob/ac1cdd7d/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
----------------------------------------------------------------------
diff --git a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
index 836ea47..e016768 100644
--- a/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
+++ b/core/sql/sqlcomp/CmpSeabaseDDLschema.cpp
@@ -1699,11 +1699,15 @@ ULng32 savedParserFlags = Get_SqlParser_Flags(0xFFFFFFFF);
}
// Restore parser flags settings to what they originally were
- Assign_SqlParser_Flags(savedParserFlags);
+ Assign_SqlParser_Flags(savedParserFlags);
if (cliRC < 0 && cliRC != -CAT_OBJECT_DOES_NOT_EXIST_IN_TRAFODION)
- someObjectsCouldNotBeDropped = true;
-
+ {
+ cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+
+ someObjectsCouldNotBeDropped = true;
+ }
+
// remove NATable entry for this table
CorrName cn(objectName,STMTHEAP,schemaName,catalogName);