Support table comment and column comment for view (#1799)

This commit is contained in:
Mingyu Chen
2019-09-18 09:45:28 +08:00
committed by ZHAO Chun
parent 3f63bde5cb
commit 714dca8699
27 changed files with 374 additions and 140 deletions

View File

@ -17,10 +17,9 @@
package org.apache.doris.analysis;
import org.apache.doris.catalog.Column;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.catalog.KeysType;
import org.apache.doris.catalog.PrimitiveType;
import org.apache.doris.catalog.ScalarType;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.UserException;
import org.apache.doris.mysql.privilege.MockedAuth;
@ -97,7 +96,7 @@ public class CreateTableStmtTest {
public void testNormal() throws UserException, AnalysisException {
CreateTableStmt stmt = new CreateTableStmt(false, false, tblName, cols, "olap",
new KeysDesc(KeysType.AGG_KEYS, colsName), null,
new HashDistributionDesc(10, Lists.newArrayList("col1")), null, null);
new HashDistributionDesc(10, Lists.newArrayList("col1")), null, null, "");
stmt.analyze(analyzer);
Assert.assertEquals("testCluster:db1", stmt.getDbName());
Assert.assertEquals("table1", stmt.getTableName());
@ -108,7 +107,7 @@ public class CreateTableStmtTest {
public void testDefaultDbNormal() throws UserException, AnalysisException {
CreateTableStmt stmt = new CreateTableStmt(false, false, tblNameNoDb, cols, "olap",
new KeysDesc(KeysType.AGG_KEYS, colsName), null,
new HashDistributionDesc(10, Lists.newArrayList("col1")), null, null);
new HashDistributionDesc(10, Lists.newArrayList("col1")), null, null, "");
stmt.analyze(analyzer);
Assert.assertEquals("testDb", stmt.getDbName());
Assert.assertEquals("table1", stmt.getTableName());
@ -125,7 +124,7 @@ public class CreateTableStmtTest {
EasyMock.replay(analyzer);
CreateTableStmt stmt = new CreateTableStmt(false, false, tblNameNoDb, cols, "olap",
new KeysDesc(KeysType.AGG_KEYS, colsName), null,
new RandomDistributionDesc(10), null, null);
new RandomDistributionDesc(10), null, null, "");
stmt.analyze(analyzer);
}
@ -135,7 +134,7 @@ public class CreateTableStmtTest {
List<ColumnDef> emptyCols = Lists.newArrayList();
CreateTableStmt stmt = new CreateTableStmt(false, false, tblNameNoDb, emptyCols, "olap",
new KeysDesc(), null,
new RandomDistributionDesc(10), null, null);
new RandomDistributionDesc(10), null, null, "");
stmt.analyze(analyzer);
}
@ -144,7 +143,7 @@ public class CreateTableStmtTest {
// make defalut db return empty;
CreateTableStmt stmt = new CreateTableStmt(false, false, tblNameNoDb, invalidCols, "olap",
new KeysDesc(KeysType.AGG_KEYS, invalidColsName), null,
new RandomDistributionDesc(10), null, null);
new RandomDistributionDesc(10), null, null, "");
stmt.analyze(analyzer);
}
}

View File

@ -204,7 +204,7 @@ public class ColocateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName1, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(numBucket, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(numBucket, Lists.newArrayList("key1")), properties, null, "");
stmt.analyze(analyzer);
catalog.createTable(stmt);
}
@ -253,7 +253,7 @@ public class ColocateTableTest {
properties.put(PropertyAnalyzer.PROPERTIES_COLOCATE_WITH, groupName1);
CreateTableStmt secondStmt = new CreateTableStmt(false, false, dbTableName2, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(numBucket, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(numBucket, Lists.newArrayList("key1")), properties, null, "");
secondStmt.analyze(analyzer);
catalog.createTable(secondStmt);
@ -308,7 +308,7 @@ public class ColocateTableTest {
int secondBucketNum = 2;
CreateTableStmt secondStmt = new CreateTableStmt(false, false, dbTableName2, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(secondBucketNum, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(secondBucketNum, Lists.newArrayList("key1")), properties, null, "");
secondStmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -327,7 +327,7 @@ public class ColocateTableTest {
properties.put(PropertyAnalyzer.PROPERTIES_REPLICATION_NUM, "2");
CreateTableStmt secondStmt = new CreateTableStmt(false, false, dbTableName2, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(bucketNum, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(bucketNum, Lists.newArrayList("key1")), properties, null, "");
secondStmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -344,7 +344,7 @@ public class ColocateTableTest {
properties.put(PropertyAnalyzer.PROPERTIES_COLOCATE_WITH, groupName1);
CreateTableStmt childStmt = new CreateTableStmt(false, false, dbTableName2, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(bucketNum, Lists.newArrayList("key1", "key2")), properties, null);
new HashDistributionDesc(bucketNum, Lists.newArrayList("key1", "key2")), properties, null, "");
childStmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -362,7 +362,7 @@ public class ColocateTableTest {
properties.put(PropertyAnalyzer.PROPERTIES_COLOCATE_WITH, groupName1);
CreateTableStmt childStmt = new CreateTableStmt(false, false, dbTableName2, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(bucketNum, Lists.newArrayList("key2")), properties, null);
new HashDistributionDesc(bucketNum, Lists.newArrayList("key2")), properties, null, "");
childStmt.analyze(analyzer);
expectedEx.expect(DdlException.class);

View File

@ -17,11 +17,6 @@
package org.apache.doris.catalog;
import com.google.common.collect.Lists;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Mock;
import mockit.MockUp;
import org.apache.doris.analysis.Analyzer;
import org.apache.doris.analysis.ColumnDef;
import org.apache.doris.analysis.CreateTableStmt;
@ -38,6 +33,9 @@ import org.apache.doris.persist.EditLog;
import org.apache.doris.qe.ConnectContext;
import org.apache.doris.system.SystemInfoService;
import org.apache.doris.task.AgentBatchTask;
import com.google.common.collect.Lists;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -49,6 +47,11 @@ import java.util.Map;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import mockit.Expectations;
import mockit.Injectable;
import mockit.Mock;
import mockit.MockUp;
public class CreateTableTest {
private TableName dbTableName;
@ -136,7 +139,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null, "");
stmt.analyze(analyzer);
catalog.createTable(stmt);
@ -155,7 +158,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null, "");
stmt.analyze(analyzer);
@ -191,7 +194,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), properties, null, "");
stmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -229,7 +232,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), properties, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), properties, null, "");
stmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -262,7 +265,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null, "");
stmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -299,7 +302,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null, "");
stmt.analyze(analyzer);
expectedEx.expect(DdlException.class);
@ -332,7 +335,7 @@ public class CreateTableTest {
CreateTableStmt stmt = new CreateTableStmt(false, false, dbTableName, columnDefs, "olap",
new KeysDesc(KeysType.AGG_KEYS, columnNames), null,
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null);
new HashDistributionDesc(1, Lists.newArrayList("key1")), null, null, "");
stmt.analyze(analyzer);
expectedEx.expect(DdlException.class);