diff --git a/core/sql/regress/compGeneral/EXPECTED072 b/core/sql/regress/compGeneral/EXPECTED072 index 9a0fb3235b..1341dc0e94 100644 --- a/core/sql/regress/compGeneral/EXPECTED072 +++ b/core/sql/regress/compGeneral/EXPECTED072 @@ -6,6 +6,20 @@ >>drop schema IF EXISTS t072sch_comment cascade; --- SQL operation complete. +>>unregister hbase table if exists t072t1_comment; + +*** ERROR[3251] UNREGISTER operation could not be completed. Reason: Specified object T072T1_COMMENT does not exist. + +--- SQL operation failed with errors. +>>drop external table if exists t072t1_comment; + +--- SQL operation complete. +>>drop hbase table t072t1_comment; + +*** WARNING[1004] Object T072T1_COMMENT does not exist or object type is invalid for the current operation. + +--- SQL operation complete. +>> >> >>obey TEST072(compile_libs); >>-------------------------------------------------------------------------- @@ -78,6 +92,17 @@ +> --UNSIGNED INTEGER +>; +--- SQL operation complete. +>> +>>create hbase table t072t1_comment ( column family 'cf'); + +--- SQL operation complete. +>>create external table t072t1_comment ++> (row_id varchar(20) not null primary key, ++> row_value varchar (1000)) ++> attribute default column family 'cf' ++> map to hbase table t072t1_comment; + --- SQL operation complete. >> >> @@ -133,7 +158,15 @@ --- SQL operation complete. >> ->> +>>comment on table hbase."_CELL_".t072t1_comment is 'This is a new comment of hbase._CELL_.TABLE.这个是一个中文的table的注释。》》、……' ; + +--- SQL operation complete. +>>comment on table hbase."_ROW_".t072t1_comment is 'This is a new comment of hbase._ROW_.TABLE.这个是一个中文的table的注释。》》、……' ; + +--- SQL operation complete. +>>comment on table hbase."_MAP_".t072t1_comment is 'This is a new comment of hbase._MAP__.TABLE.这个是一个中文的table的注释。》》、……' ; + +--- SQL operation complete. >>obey TEST072(showcomment); >>-------------------------------------------------------------------------- >> @@ -315,7 +348,80 @@ COMMENT ON SEQUENCE TRAFODION.T072SCH_COMMENT.T072SEQ IS 'This is a new comment of SEQUENCE.' ; --- SQL operation complete. ->> +>>showddl hbase."_CELL_".t072t1_comment; + +/* +CREATE TABLE HBASE."_CELL_".T072T1_COMMENT + ( + ROW_ID VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_FAMILY VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_NAME VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_TIMESTAMP LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_VALUE VARCHAR(1000) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , PRIMARY KEY (ROW_ID ASC) + ) +; +*/ + +/* HBase DDL */ +CREATE HBASE TABLE T072T1_COMMENT ( COLUMN FAMILY '#1') + +REGISTER /*INTERNAL*/ HBASE TABLE T072T1_COMMENT; +/* ObjectUID = _nnnnnnnnnnnnnnnnnn */ + +COMMENT ON TABLE HBASE."_CELL_".T072T1_COMMENT IS + 'This is a new comment of hbase._CELL_.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. +>>showddl hbase."_ROW_".t072t1_comment; + +/* +CREATE TABLE HBASE."_ROW_".T072T1_COMMENT + ( + ROW_ID VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COLUMN_DETAILS VARCHAR(10000) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , PRIMARY KEY (ROW_ID ASC) + ) +; +*/ + +/* HBase DDL */ +CREATE HBASE TABLE T072T1_COMMENT ( COLUMN FAMILY '#1') + +REGISTER /*INTERNAL*/ HBASE TABLE T072T1_COMMENT; +/* ObjectUID = _nnnnnnnnnnnnnnnnnn */ + +COMMENT ON TABLE HBASE."_ROW_".T072T1_COMMENT IS + 'This is a new comment of hbase._ROW_.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. +>>showddl hbase."_MAP_".t072t1_comment; + +CREATE EXTERNAL TABLE T072T1_COMMENT + ( + "cf".ROW_ID VARCHAR(20) CHARACTER SET ISO88591 COLLATE + DEFAULT NO @eof@ NULL NOT DROPPABLE + , "cf".ROW_VALUE VARCHAR(1000) CHARACTER SET ISO88591 + COLLATE DEFAULT DEFAULT NULL + , PRIMARY KEY NOT SERIALIZED (ROW_ID ASC) + ) + ATTRIBUTES DEFAULT COLUMN FAMILY 'cf' + MAP TO HBASE TABLE T072T1_COMMENT DATA FORMAT VARCHAR +; + +COMMENT ON TABLE TRAFODION."_HB_MAP_".T072T1_COMMENT IS + 'This is a new comment of hbase._MAP__.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. >> >> >>obey TEST072(comment02); @@ -580,7 +686,80 @@ COMMENT ON SEQUENCE TRAFODION.T072SCH_COMMENT.T072SEQ IS 'This is a Modified comment: This is a comment of SEQUENCE.' ; --- SQL operation complete. ->> +>>showddl hbase."_CELL_".t072t1_comment; + +/* +CREATE TABLE HBASE."_CELL_".T072T1_COMMENT + ( + ROW_ID VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_FAMILY VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_NAME VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_TIMESTAMP LARGEINT NO DEFAULT NOT NULL NOT DROPPABLE + , COL_VALUE VARCHAR(1000) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , PRIMARY KEY (ROW_ID ASC) + ) +; +*/ + +/* HBase DDL */ +CREATE HBASE TABLE T072T1_COMMENT ( COLUMN FAMILY '#1') + +REGISTER /*INTERNAL*/ HBASE TABLE T072T1_COMMENT; +/* ObjectUID = _nnnnnnnnnnnnnnnnnn */ + +COMMENT ON TABLE HBASE."_CELL_".T072T1_COMMENT IS + 'This is a new comment of hbase._CELL_.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. +>>showddl hbase."_ROW_".t072t1_comment; + +/* +CREATE TABLE HBASE."_ROW_".T072T1_COMMENT + ( + ROW_ID VARCHAR(100) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , COLUMN_DETAILS VARCHAR(10000) CHARACTER SET ISO88591 + COLLATE DEFAULT NO DEFAULT NOT NULL NOT DROPPABLE + , PRIMARY KEY (ROW_ID ASC) + ) +; +*/ + +/* HBase DDL */ +CREATE HBASE TABLE T072T1_COMMENT ( COLUMN FAMILY '#1') + +REGISTER /*INTERNAL*/ HBASE TABLE T072T1_COMMENT; +/* ObjectUID = _nnnnnnnnnnnnnnnnnn */ + +COMMENT ON TABLE HBASE."_ROW_".T072T1_COMMENT IS + 'This is a new comment of hbase._ROW_.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. +>>showddl hbase."_MAP_".t072t1_comment; + +CREATE EXTERNAL TABLE T072T1_COMMENT + ( + "cf".ROW_ID VARCHAR(20) CHARACTER SET ISO88591 COLLATE + DEFAULT NO @eof@ NULL NOT DROPPABLE + , "cf".ROW_VALUE VARCHAR(1000) CHARACTER SET ISO88591 + COLLATE DEFAULT DEFAULT NULL + , PRIMARY KEY NOT SERIALIZED (ROW_ID ASC) + ) + ATTRIBUTES DEFAULT COLUMN FAMILY 'cf' + MAP TO HBASE TABLE T072T1_COMMENT DATA FORMAT VARCHAR +; + +COMMENT ON TABLE TRAFODION."_HB_MAP_".T072T1_COMMENT IS + 'This is a new comment of hbase._MAP__.TABLE.这个是一个中文的table的注释。》》、……' + ; + +--- SQL operation complete. >> >> >>obey TEST072(comment03); @@ -1137,6 +1316,16 @@ COMMENT ON SEQUENCE TRAFODION.T072SCH_COMMENT.T072SEQ IS >>drop schema IF EXISTS t072sch_comment cascade; --- SQL operation complete. +>>unregister hbase table if exists t072t1_comment; + +--- SQL operation complete. +>>drop external table if exists t072t1_comment; + +--- SQL operation complete. +>>drop hbase table t072t1_comment; + +--- SQL operation complete. +>> >> >>obey TEST072(showcomment); >>-------------------------------------------------------------------------- diff --git a/core/sql/regress/compGeneral/FILTER072 b/core/sql/regress/compGeneral/FILTER072 index 66c521de0d..b978827b14 100755 --- a/core/sql/regress/compGeneral/FILTER072 +++ b/core/sql/regress/compGeneral/FILTER072 @@ -14,4 +14,5 @@ fi sed " s/FILE '.*rundir\(.*\)'/FILE '\$rundir\1'/g +s/ObjectUID = [0-9]\{19\}/ObjectUID = _nnnnnnnnnnnnnnnnnn/g " $fil diff --git a/core/sql/regress/compGeneral/TEST072 b/core/sql/regress/compGeneral/TEST072 index 143104f158..1ae5cdff88 100644 --- a/core/sql/regress/compGeneral/TEST072 +++ b/core/sql/regress/compGeneral/TEST072 @@ -119,6 +119,13 @@ CREATE SEQUENCE t072sch_comment.t072seq --UNSIGNED INTEGER ; +create hbase table t072t1_comment ( column family 'cf'); +create external table t072t1_comment + (row_id varchar(20) not null primary key, + row_value varchar (1000)) + attribute default column family 'cf' + map to hbase table t072t1_comment; + ?section comment01 -------------------------------------------------------------------------- @@ -141,7 +148,9 @@ comment on column t072sch_comment.t072view1.col1 is 'This is a V0 comment on column t072sch_comment.t072view1.col2 is 'This is a V02 column new comment of view.' ; comment on column t072sch_comment.t072view1.col3 is 'This is a V03 column new comment of view.大家好。' ; - +comment on table hbase."_CELL_".t072t1_comment is 'This is a new comment of hbase._CELL_.TABLE.这个是一个中文的table的注释。》》、……' ; +comment on table hbase."_ROW_".t072t1_comment is 'This is a new comment of hbase._ROW_.TABLE.这个是一个中文的table的注释。》》、……' ; +comment on table hbase."_MAP_".t072t1_comment is 'This is a new comment of hbase._MAP__.TABLE.这个是一个中文的table的注释。》》、……' ; ?section comment02 -------------------------------------------------------------------------- @@ -240,7 +249,9 @@ showddl library t072sch_comment.t072jar; showddl function t072sch_comment.t072func; showddl procedure t072sch_comment.t072spj; showddl sequence t072sch_comment.t072seq; - +showddl hbase."_CELL_".t072t1_comment; +showddl hbase."_ROW_".t072t1_comment; +showddl hbase."_MAP_".t072t1_comment; ?section showddl2 -------------------------------------------------------------------------- @@ -259,4 +270,8 @@ showddl sequence t072sch_comment.t072seq; -- CLEANUP database drop schema IF EXISTS t072sch_comment cascade; +unregister hbase table if exists t072t1_comment; +drop external table if exists t072t1_comment; +drop hbase table t072t1_comment; + diff --git a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp index cc4b00e843..e69c84d9b2 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLcommentOn.cpp @@ -289,6 +289,31 @@ void CmpSeabaseDDL::doSeabaseCommentOn(StmtDDLCommentOn *commentOnNode, ExeCliInterface cliInterface(STMTHEAP, NULL, NULL, CmpCommon::context()->sqlSession()->getParentQid()); + //if comment on native HBASE first shoud register first + if (CmpSeabaseDDL::isHbase(catalogNamePart)) + { + // HBase."MAP" fromater should covert + if (ComIsHBaseMappedExtFormat(catalogNamePart, schemaNamePart)) + { + ComConvertHBaseMappedExtToInt(catalogNamePart, schemaNamePart, catalogNamePart, schemaNamePart); + } + else + { + //HBASE erternal table already register in create time no need to register again + NAString ddl = "REGISTER INTERNAL HBASE TABLE IF NOT REGISTERED "; + ddl.append(extObjName.data()); + + Lng32 cliRC = cliInterface.executeImmediate(ddl.data()); + // error code -8102 means the object already register + if (cliRC < 0 && cliRC != -8102) + { + cliInterface.retrieveSQLDiagnostics(CmpCommon::diags()); + processReturn(); + return; + } + } + + } Int64 objUID = 0; Int32 objectOwnerID = ROOT_USER_ID; Int32 schemaOwnerID = ROOT_USER_ID; diff --git a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp index 234d2d1064..fbd4caded7 100644 --- a/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp +++ b/core/sql/sqlcomp/CmpSeabaseDDLtable.cpp @@ -10558,7 +10558,12 @@ short CmpSeabaseDDL::unregisterNativeTable objectNamePart.data(), objType ); - + + // drop comment text + retcode = deleteFromTextTable(&cliInterface, + objUID, + ComTextType::COM_OBJECT_COMMENT_TEXT, + 0); return 0; }