Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Yulei-Yang committed Sep 30, 2024
1 parent 4a58a0d commit 0bb8654
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 43 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,6 @@ TABLET: 'TABLET';
TABLETS: 'TABLETS';
TASK: 'TASK';
TASKS: 'TASKS';
TEMP: 'TEMP';
TEMPORARY: 'TEMPORARY';
TERMINATED: 'TERMINATED';
TEXT: 'TEXT';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ supportedCreateStatement
| CREATE (EXTERNAL)? TABLE (IF NOT EXISTS)? name=multipartIdentifier
LIKE existedTable=multipartIdentifier
(WITH ROLLUP (rollupNames=identifierList)?)? #createTableLike
| CREATE (TEMP | TEMPORARY)? TABLE (IF NOT EXISTS)? name=multipartIdentifier
| CREATE (TEMPORARY)? TABLE (IF NOT EXISTS)? name=multipartIdentifier
LIKE existedTable=multipartIdentifier
(WITH ROLLUP (rollupNames=identifierList)?)? #createTableLike
| CREATE ROW POLICY (IF NOT EXISTS)? name=identifier
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,6 @@ public void analyze(Analyzer analyzer) throws UserException {
DatabaseIf db = catalog.getDbOrAnalysisException(dbName);
dbId = db.getId();
table = db.getTableOrAnalysisException(tblName);

isAllColumns = columnNames == null;
check();
}
Expand All @@ -146,9 +145,6 @@ public void check() throws AnalysisException {
if (table instanceof View) {
throw new AnalysisException("Analyze view is not allowed");
}
//if (table.getType() == TableType.TEMP) {
// throw new AnalysisException("Analyze temporary table is not supported");
//}
checkAnalyzePriv(tableName.getCtl(), tableName.getDb(), tableName.getTbl());
if (columnNames == null) {
columnNames = table.getSchemaAllIndexes(false).stream()
Expand Down
2 changes: 1 addition & 1 deletion fe/fe-core/src/main/java/org/apache/doris/catalog/Env.java
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ public void cleanPhantomTempTable() {
getInternalCatalog().dropTableWithoutCheck(getInternalCatalog().getDb(table.getDBName()).get(),
table, true);
} catch (DdlException e) {
LOG.error("drop temp table error: db: {}, table: {}", table.getDBName(), table.getName(), e);
LOG.error("drop temporary table error: db: {}, table: {}", table.getDBName(), table.getName(), e);
}
}
phantomTempTableList.clear();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.apache.doris.catalog.Env;
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.cloud.qe.ComputeGroupException;
import org.apache.doris.cloud.system.CloudSystemInfoService;
import org.apache.doris.common.AnalysisException;
Expand All @@ -48,6 +49,7 @@
import org.apache.doris.common.util.LogKey;
import org.apache.doris.common.util.SqlParserUtils;
import org.apache.doris.common.util.TimeUtils;
import org.apache.doris.common.util.Util;
import org.apache.doris.load.RoutineLoadDesc;
import org.apache.doris.load.loadv2.LoadTask;
import org.apache.doris.load.routineload.kafka.KafkaConfiguration;
Expand Down Expand Up @@ -1351,6 +1353,10 @@ protected static void checkMeta(OlapTable olapTable, RoutineLoadDesc routineLoad
return;
}

if (olapTable.getType() == TableType.TEMP) {
throw new DdlException("Cannot create routine load for temporary table "
+ Util.getTempTableOuterName(olapTable.getName()));
}
// check partitions
olapTable.readLock();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@
import org.apache.doris.catalog.OlapTable;
import org.apache.doris.catalog.PartitionInfo;
import org.apache.doris.catalog.Table;
import org.apache.doris.catalog.TableIf.TableType;
import org.apache.doris.cluster.ClusterNamespace;
import org.apache.doris.common.AnalysisException;
import org.apache.doris.common.DdlException;
import org.apache.doris.common.UserException;
import org.apache.doris.common.io.Text;
import org.apache.doris.common.io.Writable;
import org.apache.doris.common.util.Util;
import org.apache.doris.datasource.InternalCatalog;
import org.apache.doris.persist.gson.GsonUtils;
import org.apache.doris.qe.ShowResultSet;
Expand Down Expand Up @@ -183,12 +185,16 @@ public void dropPolicy(DropPolicyStmt stmt) throws DdlException, AnalysisExcepti
for (Table table : tables) {
if (table instanceof OlapTable) {
OlapTable olapTable = (OlapTable) table;
String tableName = table.getName();
if (table.getType() == TableType.TEMP) {
tableName = Util.getTempTableOuterName(tableName);
}
PartitionInfo partitionInfo = olapTable.getPartitionInfo();
for (Long partitionId : olapTable.getPartitionIds()) {
String policyName = partitionInfo.getDataProperty(partitionId).getStoragePolicy();
if (policyName.equals(dropPolicyLog.getPolicyName())) {
throw new DdlException("the policy " + policyName + " is used by table: "
+ table.getName());
+ tableName);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ protected void deleteTempTable() {
Env.getCurrentEnv().getInternalCatalog()
.dropTableWithoutCheck(db, db.getTable(tableName).get(), true);
} catch (DdlException e) {
LOG.error("drop temp table error: db: {}, table: {}", dbName, tableName, e);
LOG.error("drop temporary table error: db: {}, table: {}", dbName, tableName, e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
----------PhysicalOlapScan[test]
--PhysicalResultSink
----hashJoin[INNER_JOIN] hashCondition=((m1.k1 = m2.k1)) otherCondition=()
------filter((temp1.k1 = 1))
------filter((temp.k1 = 1))
--------PhysicalCteConsumer ( cteId=CTEId#0 )
------filter((m2.k1 = 1))
--------PhysicalCteConsumer ( cteId=CTEId#0 )
Expand All @@ -22,7 +22,7 @@ PhysicalCteAnchor ( cteId=CTEId#0 )
----------PhysicalOlapScan[test]
--PhysicalResultSink
----hashJoin[INNER_JOIN] hashCondition=((m1.k1 = m2.k1)) otherCondition=()
------filter((temp1.k1 = 1))
------filter((temp.k1 = 1))
--------PhysicalCteConsumer ( cteId=CTEId#0 )
------filter((m2.k1 = 1))
--------PhysicalCteConsumer ( cteId=CTEId#0 )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ LOAD LABEL ${loadLabel} (
DATA INFILE("s3://${s3BucketName}/regression/ssb/sf100/date.tbl.gz")
INTO TABLE date
COLUMNS TERMINATED BY "|"
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp1)
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp)
)
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ suite("create_table_use_policy") {
// storage policy is disabled on mow table
assertEquals(create_temp_table_use_created_policy.size(), 1);

sql """
DROP TABLE IF EXISTS create_temp_table_use_created_policy
"""
sql """
DROP TABLE IF EXISTS create_table_use_created_policy
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,7 @@ suite("test_domain_connection_and_ak_sk_correction", "load_p0") {
DATA INFILE("s3://${getS3BucketName()}/regression/tpch/sf1/part.tbl")
INTO TABLE ${tableName}
COLUMNS TERMINATED BY "|"
(p_partkey, p_name, p_mfgr, p_brand, p_type, p_size, p_container, p_retailprice, p_comment, temp
)
(p_partkey, p_name, p_mfgr, p_brand, p_type, p_size, p_container, p_retailprice, p_comment, temp)
)
WITH S3
(
Expand Down
2 changes: 1 addition & 1 deletion regression-test/suites/ssb_sf100_p2/ddl/date_load.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ LOAD LABEL ${loadLabel} (
DATA INFILE("s3://${s3BucketName}/regression/ssb/sf100/date.tbl.gz")
INTO TABLE date
COLUMNS TERMINATED BY "|"
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp1)
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp)
)
27 changes: 0 additions & 27 deletions regression-test/suites/table_p0/test_temp_table.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -321,33 +321,6 @@ suite("test_temp_table") {
select_result3 = sql "select * from t_test_temp_table2"
assertEquals(select_result3.size(), 0)

// test stream load
streamLoad {
table 't_test_temp_table2'
set 'column_separator', ','
file 'temp_table_data.csv'
}
sql "sync"
select_result3 = sql "select * from t_test_temp_table2"
assertEquals(select_result3.size(), 3)

// truncate
sql "truncate table t_test_temp_table2"
select_result3 = sql "select * from t_test_temp_table2"
assertEquals(select_result3.size(), 0)

// test mysql load
def filepath = getLoalFilePath "temp_table_data.csv"
sql """
LOAD DATA LOCAL
INFILE '${filepath}'
INTO TABLE t_test_temp_table2
COLUMNS TERMINATED BY ','
"""
sql "sync"
select_result3 = sql "select * from t_test_temp_table2"
assertEquals(select_result3.size(), 3)

// alter
try {
sql "alter table t_test_temp_table2 rename t_test_temp_table2_new"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ LOAD LABEL ${loadLabel} (
DATA INFILE("s3://${s3BucketName}/regression/ssb/sf100/date.tbl.gz")
INTO TABLE date
COLUMNS TERMINATED BY "|"
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp1)
(d_datekey,d_date,d_dayofweek,d_month,d_year,d_yearmonthnum,d_yearmonth, d_daynuminweek,d_daynuminmonth,d_daynuminyear,d_monthnuminyear,d_weeknuminyear, d_sellingseason,d_lastdayinweekfl,d_lastdayinmonthfl,d_holidayfl,d_weekdayfl,temp)
)

0 comments on commit 0bb8654

Please sign in to comment.