This is an automated email from the ASF dual-hosted git repository.
jackietien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 9ea12aacef6 Applied the new functional definition to tree to table view
9ea12aacef6 is described below
commit 9ea12aacef669bc019e2b8a24066a84bbf4d7b92
Author: Caideyipi <[email protected]>
AuthorDate: Thu May 15 09:30:19 2025 +0800
Applied the new functional definition to tree to table view
---
.../manual/enhanced/IoTDBPipeIdempotentIT.java | 16 ++---
.../view/old/IoTDBFilterBetweenTableViewIT.java | 2 +-
.../query/view/old/IoTDBFilterNullTableViewIT.java | 2 +-
.../it/query/view/old/IoTDBFilterTableViewIT.java | 8 +--
.../view/old/IoTDBNestedQueryTableViewIT.java | 6 +-
.../view/old/IoTDBSimpleQueryTableViewIT.java | 27 ++++---
.../IoTDBAlignByDeviceTableViewIT.java | 2 +-
.../IoTDBAlignByDeviceWithTemplateTableViewIT.java | 2 +-
...OrderByLimitOffsetAlignByDeviceTableViewIT.java | 4 +-
.../IoTDBOrderByWithAlignByDeviceTableViewIT.java | 6 +-
...IoTDBAlignedOffsetLimitPushDownTableViewIT.java | 2 +-
.../it/query/view/old/aligned/TableViewUtils.java | 2 +-
.../view/old/orderby/IoTDBOrderByTableViewIT.java | 2 +-
.../view/old/query/IoTDBArithmeticTableViewIT.java | 4 +-
.../view/old/query/IoTDBPaginationTableViewIT.java | 4 +-
.../view/recent/IoTDBColumnsMatchTableViewIT.java | 2 +-
.../view/recent/IoTDBComplexQueryTableViewIT.java | 4 +-
.../view/recent/IoTDBDistinctTagTableViewIT.java | 4 +-
.../it/query/view/recent/IoTDBFillTableViewIT.java | 6 +-
.../query/view/recent/IoTDBGapFillTableViewIT.java | 2 +-
.../view/recent/IoTDBNullIdQueryTableViewIT.java | 4 +-
.../view/recent/IoTDBNullValueTableViewIT.java | 2 +-
...oTDBTableViewAggregationFunctionDistinctIT.java | 2 +-
.../view/recent/IoTDBTableViewAggregationIT.java | 2 +-
.../IoTDBTableViewAggregationNonStreamIT.java | 2 +-
.../query/view/recent/IoTDBTableViewQueryIT.java | 6 +-
.../relational/it/schema/IoTDBDatabaseIT.java | 6 +-
.../iotdb/relational/it/schema/IoTDBTableIT.java | 52 ++++++++------
.../org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4 | 8 +--
.../persistence/schema/ClusterSchemaInfo.java | 4 +-
.../confignode/persistence/schema/ConfigMTree.java | 9 ++-
.../schema/TreeDeviceViewFieldDetector.java | 83 ++++++++++++++--------
...edureTest.java => CreateViewProcedureTest.java} | 2 +-
...edureTest.java => CreateViewProcedureTest.java} | 2 +-
.../execution/config/TableConfigTaskVisitor.java | 5 +-
.../metadata/relational/ShowCreateViewTask.java | 16 +++--
.../db/queryengine/plan/parser/ASTVisitor.java | 8 ++-
.../relational/analyzer/StatementAnalyzer.java | 5 +-
.../plan/relational/sql/ast/AstVisitor.java | 2 +-
.../ast/{CreateTableView.java => CreateView.java} | 12 ++--
.../sql/ast/DefaultTraversalVisitor.java | 2 +-
.../plan/relational/sql/parser/AstBuilder.java | 7 +-
.../plan/relational/sql/util/SqlFormatter.java | 12 ++--
.../metadata/view/CreateTableViewStatement.java | 12 ++--
...t.java => ViewFromTreeAdaptorOperatorTest.java} | 12 ++--
.../iotdb/commons/schema/table/TableType.java | 2 +-
.../db/relational/grammar/sql/RelationalSql.g4 | 10 +--
47 files changed, 215 insertions(+), 181 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeIdempotentIT.java
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeIdempotentIT.java
index 196d5a167e1..1e02ad9963c 100644
---
a/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeIdempotentIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/manual/enhanced/IoTDBPipeIdempotentIT.java
@@ -61,7 +61,7 @@ public class IoTDBPipeIdempotentIT extends
AbstractPipeTableModelDualManualIT {
@Test
public void testCreateTableViewIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.emptyList(), "create table view test(s1 field int32) as
root.a.** restrict");
+ Collections.emptyList(), "create view test(s1 field int32) restrict as
root.a.**");
}
@Test
@@ -73,7 +73,7 @@ public class IoTDBPipeIdempotentIT extends
AbstractPipeTableModelDualManualIT {
@Test
public void testAlterViewAddColumnIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList("create table view test(s1 field int32) as
root.a.** restrict"),
+ Collections.singletonList("create view test(s1 field int32) restrict
as root.a.**"),
"alter view test add column a tag");
}
@@ -87,7 +87,7 @@ public class IoTDBPipeIdempotentIT extends
AbstractPipeTableModelDualManualIT {
@Test
public void testAlterViewSetPropertiesIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList("create table view test(s1 field int32) as
root.a.** restrict"),
+ Collections.singletonList("create view test(s1 field int32) restrict
as root.a.**"),
"alter view test set properties ttl=100");
}
@@ -101,8 +101,7 @@ public class IoTDBPipeIdempotentIT extends
AbstractPipeTableModelDualManualIT {
@Test
public void testAlterViewDropColumnIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList(
- "create table view test(a tag, s1 field int32) as root.a.**
restrict"),
+ Collections.singletonList("create view test(a tag, s1 field int32)
restrict as root.a.**"),
"alter view test drop column a");
}
@@ -114,22 +113,21 @@ public class IoTDBPipeIdempotentIT extends
AbstractPipeTableModelDualManualIT {
@Test
public void testDropViewIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList("create table view test(s1 field int32) as
root.a.** restrict"),
+ Collections.singletonList("create view test(s1 field int32) restrict
as root.a.**"),
"drop view test");
}
@Test
public void testRenameViewColumnIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList(
- "create table view test(a tag, s1 field int32) as root.a.**
restrict"),
+ Collections.singletonList("create view test(a tag, s1 field int32)
restrict as root.a.**"),
"alter view test rename column a to b");
}
@Test
public void testRenameViewIdempotent() throws Exception {
testTableConfigIdempotent(
- Collections.singletonList("create table view test(s1 field int32) as
root.a.** restrict"),
+ Collections.singletonList("create view test(s1 field int32) restrict
as root.a.**"),
"alter view test rename to test1");
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterBetweenTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterBetweenTableViewIT.java
index 598303f1ca9..345cf0ed58f 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterBetweenTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterBetweenTableViewIT.java
@@ -94,7 +94,7 @@ public class IoTDBFilterBetweenTableViewIT {
SQLs.add("CREATE DATABASE " + DATABASE_NAME);
SQLs.add("USE " + DATABASE_NAME);
SQLs.add(
- "CREATE TABLE VIEW table1 (device STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 TEXT FIELD) as root.vehicle.**");
+ "CREATE VIEW table1 (device STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 TEXT FIELD) as root.vehicle.**");
}
@Test
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterNullTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterNullTableViewIT.java
index f6bed6f31c4..1302915e477 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterNullTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterNullTableViewIT.java
@@ -64,7 +64,7 @@ public class IoTDBFilterNullTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW testNullFilter(device STRING TAG, s1 INT32 FIELD,
s2 BOOLEAN FIELD, s3 DOUBLE FIELD) as root.testNullFilter.**",
+ "CREATE VIEW testNullFilter(device STRING TAG, s1 INT32 FIELD, s2
BOOLEAN FIELD, s3 DOUBLE FIELD) as root.testNullFilter.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterTableViewIT.java
index 18ebd801e6d..1f6bacf0971 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBFilterTableViewIT.java
@@ -131,13 +131,13 @@ public class IoTDBFilterTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW testNaN(device STRING TAG, n1 DOUBLE FIELD, n2
DOUBLE FIELD) as root.vehicle.testNaN.**");
+ "CREATE VIEW testNaN(device STRING TAG, n1 DOUBLE FIELD, n2 DOUBLE
FIELD) as root.vehicle.testNaN.**");
statement.execute(
- "CREATE TABLE VIEW testTimeSeries(device STRING TAG, s1 BOOLEAN
FIELD, s2 BOOLEAN FIELD) as root.vehicle.testTimeSeries.**");
+ "CREATE VIEW testTimeSeries(device STRING TAG, s1 BOOLEAN FIELD, s2
BOOLEAN FIELD) as root.vehicle.testTimeSeries.**");
statement.execute(
- "CREATE TABLE VIEW testUDTF(device STRING TAG, s1 TEXT FIELD, s2
DOUBLE FIELD) as root.vehicle.testUDTF.**");
+ "CREATE VIEW testUDTF(device STRING TAG, s1 TEXT FIELD, s2 DOUBLE
FIELD) as root.vehicle.testUDTF.**");
statement.execute(
- "CREATE TABLE VIEW sg1(device STRING TAG, s1 DOUBLE FIELD, s2 TEXT
FIELD) as root.sg1.**");
+ "CREATE VIEW sg1(device STRING TAG, s1 DOUBLE FIELD, s2 TEXT FIELD)
as root.sg1.**");
} catch (SQLException throwable) {
fail(throwable.getMessage());
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBNestedQueryTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBNestedQueryTableViewIT.java
index 94defc8cdf7..9e97a0b03ed 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBNestedQueryTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBNestedQueryTableViewIT.java
@@ -128,12 +128,12 @@ public class IoTDBNestedQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "create table view vehicle1(device_id STRING TAG, s1 INT32 FIELD, s2
INT32 FIELD, s3 TEXT FIELD, s4 STRING FIELD, s5 DATE FIELD, s6 TIMESTAMP FIELD)
as root.vehicle.**");
+ "create view vehicle1(device_id STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 TEXT FIELD, s4 STRING FIELD, s5 DATE FIELD, s6 TIMESTAMP FIELD) as
root.vehicle.**");
statement.execute(
- "create table view vehicle2(device_id STRING TAG, s1 FLOAT FIELD, s2
DOUBLE FIELD, empty DOUBLE FIELD) as root.vehicle2.**");
+ "create view vehicle2(device_id STRING TAG, s1 FLOAT FIELD, s2
DOUBLE FIELD, empty DOUBLE FIELD) as root.vehicle2.**");
statement.execute(
- "create table view likeTest(device_id STRING TAG, s1 TEXT FIELD, s2
STRING FIELD) as root.likeTest.**");
+ "create view likeTest(device_id STRING TAG, s1 TEXT FIELD, s2 STRING
FIELD) as root.likeTest.**");
} catch (SQLException throwable) {
fail(throwable.getMessage());
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBSimpleQueryTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBSimpleQueryTableViewIT.java
index 9cc8e273233..91f4998ac53 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBSimpleQueryTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/IoTDBSimpleQueryTableViewIT.java
@@ -84,8 +84,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.setFetchSize(5);
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
- statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s1 INT32 FIELD) as
root.sg1.**");
+ statement.execute("CREATE VIEW table1(device STRING TAG, s1 INT32 FIELD)
as root.sg1.**");
try (ResultSet resultSet = statement.executeQuery("describe table1")) {
if (resultSet.next()
@@ -123,7 +122,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s0 INT32 FIELD, s1
INT32 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s0 INT32 FIELD, s1 INT32
FIELD) as root.sg1.**");
statement.execute("flush");
String[] expectedHeader = new String[] {"time", "device", "s0", "s1"};
@@ -166,7 +165,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2
INT32 FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7
INT32 FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7 INT32
FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
int count = 0;
try (ResultSet resultSet = statement.executeQuery("describe table1")) {
@@ -208,7 +207,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2
INT32 FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7
INT32 FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7 INT32
FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
statement.execute("flush");
@@ -252,7 +251,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2
INT32 FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7
INT32 FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2 INT32
FIELD, s3 INT32 FIELD, s4 INT32 FIELD, s5 INT32 FIELD, s6 INT32 FIELD, s7 INT32
FIELD, s8 INT32 FIELD, s9 INT32 FIELD, s10 INT32 FIELD) as root.sg1.**");
statement.execute("flush");
@@ -301,8 +300,7 @@ public class IoTDBSimpleQueryTableViewIT {
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
- statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s0 INT32 FIELD) as
root.sg1.**");
+ statement.execute("CREATE VIEW table1(device STRING TAG, s0 INT32 FIELD)
as root.sg1.**");
long count = 0;
try (ResultSet resultSet = statement.executeQuery("select s0 from table1
where s0 > 18")) {
@@ -335,7 +333,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s0 INT32 FIELD, s1
INT32 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s0 INT32 FIELD, s1 INT32
FIELD) as root.sg1.**");
try (ResultSet resultSet = statement.executeQuery("select s0, s1 from
table1")) {
while (resultSet.next()) {
@@ -380,8 +378,7 @@ public class IoTDBSimpleQueryTableViewIT {
Statement statement = connection.createStatement()) {
statement.execute("CREATE DATABASE " + DATABASE_NAME);
statement.execute("USE " + DATABASE_NAME);
- statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s0 INT32 FIELD) as
root.sg1.**");
+ statement.execute("CREATE VIEW table1(device STRING TAG, s0 INT32 FIELD)
as root.sg1.**");
long count = 0;
@@ -415,7 +412,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE test");
statement.execute("USE " + DATABASE_NAME);
StringBuilder createTableBuilder = new StringBuilder();
- createTableBuilder.append("CREATE TABLE VIEW table1(device STRING TAG,");
+ createTableBuilder.append("CREATE VIEW table1(device STRING TAG,");
for (int i = 0; i < 1000; i++) {
String columnName = "s" + i;
createTableBuilder.append(columnName).append(" INT32 FIELD,");
@@ -454,7 +451,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE test");
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s0 INT64 FIELD, s1
INT64 FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s0 INT64 FIELD, s1 INT64
FIELD) as root.sg1.**");
List<ResultSet> resultSetList = new ArrayList<>();
@@ -496,7 +493,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE test");
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2
BOOLEAN FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s1 INT32 FIELD, s2 BOOLEAN
FIELD) as root.sg1.**");
ResultSet resultSet = statement.executeQuery("select time, s1, s2 from
table1");
ResultSetMetaData metaData = resultSet.getMetaData();
int[] types = {Types.TIMESTAMP, Types.INTEGER, Types.BOOLEAN};
@@ -534,7 +531,7 @@ public class IoTDBSimpleQueryTableViewIT {
statement.execute("CREATE DATABASE test");
statement.execute("USE " + DATABASE_NAME);
statement.execute(
- "CREATE TABLE VIEW table1(device STRING TAG, s4 DATE FIELD, s5
TIMESTAMP FIELD, s6 BLOB FIELD, s7 STRING FIELD) as root.sg1.**");
+ "CREATE VIEW table1(device STRING TAG, s4 DATE FIELD, s5 TIMESTAMP
FIELD, s6 BLOB FIELD, s7 STRING FIELD) as root.sg1.**");
try (ResultSet resultSet = statement.executeQuery("select * from
table1")) {
final ResultSetMetaData metaData = resultSet.getMetaData();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceTableViewIT.java
index aaca79b9899..4f33aa49a0d 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceTableViewIT.java
@@ -47,7 +47,7 @@ public class IoTDBAlignByDeviceTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "create table view vehicle(device_id STRING TAG, s0 INT32 FIELD, s1
INT64 FIELD, s2 FLOAT FIELD, s3 STRING FIELD, s4 BOOLEAN FIELD) as
root.vehicle.**"
+ "create view vehicle(device_id STRING TAG, s0 INT32 FIELD, s1 INT64
FIELD, s2 FLOAT FIELD, s3 STRING FIELD, s4 BOOLEAN FIELD) as root.vehicle.**"
};
private static final String[] sqls =
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableViewIT.java
index f089b92e863..668cd36a71a 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBAlignByDeviceWithTemplateTableViewIT.java
@@ -71,7 +71,7 @@ public class IoTDBAlignByDeviceWithTemplateTableViewIT {
new String[] {
"CREATE database " + DATABASE_NAME,
"use " + DATABASE_NAME,
- "create table view table1(device_id STRING TAG, s1 FLOAT FIELD, s2
BOOLEAN FIELD, s3 INT32 FIELD) as root.sg2.**",
+ "create view table1(device_id STRING TAG, s1 FLOAT FIELD, s2 BOOLEAN
FIELD, s3 INT32 FIELD) as root.sg2.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceTableViewIT.java
index bdbacb63be7..6d913a26d24 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByLimitOffsetAlignByDeviceTableViewIT.java
@@ -143,10 +143,10 @@ public class
IoTDBOrderByLimitOffsetAlignByDeviceTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "create table view table1(device_id STRING TAG, s1 INT32 FIELD) as
root.db.**",
+ "create view table1(device_id STRING TAG, s1 INT32 FIELD) as
root.db.**",
"CREATE DATABASE " + DATABASE_FILL_NAME,
"USE " + DATABASE_FILL_NAME,
- "create table view table1(device_id STRING TAG, s1 INT32 FIELD, s2
FLOAT FIELD) as root.fill1.**",
+ "create view table1(device_id STRING TAG, s1 INT32 FIELD, s2 FLOAT
FIELD) as root.fill1.**",
};
protected static void insertData3() {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByWithAlignByDeviceTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByWithAlignByDeviceTableViewIT.java
index 0d8df207c3f..d8bca2b4522 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByWithAlignByDeviceTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/alignbydevice/IoTDBOrderByWithAlignByDeviceTableViewIT.java
@@ -187,10 +187,10 @@ public class IoTDBOrderByWithAlignByDeviceTableViewIT {
statement.execute("use " + DATABASE_NAME);
statement.execute(
- "create table view weather(city STRING TAG, precipitation INT64
FIELD, temperature DOUBLE FIELD) as root.weather.**");
+ "create view weather(city STRING TAG, precipitation INT64 FIELD,
temperature DOUBLE FIELD) as root.weather.**");
statement.execute(
- "create table view optimize(plant_id STRING TAG, device_id STRING
TAG, temperature DOUBLE FIELD, status BOOLEAN FIELD, hardware STRING FIELD) as
root.ln.**");
+ "create view optimize(plant_id STRING TAG, device_id STRING TAG,
temperature DOUBLE FIELD, status BOOLEAN FIELD, hardware STRING FIELD) as
root.ln.**");
} catch (Exception e) {
e.printStackTrace();
@@ -223,7 +223,7 @@ public class IoTDBOrderByWithAlignByDeviceTableViewIT {
Statement statement = iotDBConnection.createStatement()) {
statement.execute("use " + DATABASE_NAME);
statement.execute(
- "create table view overflow(device_id STRING TAG, value INT32 FIELD)
as root.overflow.**");
+ "create view overflow(device_id STRING TAG, value INT32 FIELD) as
root.overflow.**");
} catch (Exception e) {
e.printStackTrace();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/IoTDBAlignedOffsetLimitPushDownTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/IoTDBAlignedOffsetLimitPushDownTableViewIT.java
index 5b84eaf3dfb..72cc9ebb4bb 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/IoTDBAlignedOffsetLimitPushDownTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/IoTDBAlignedOffsetLimitPushDownTableViewIT.java
@@ -73,7 +73,7 @@ public class IoTDBAlignedOffsetLimitPushDownTableViewIT {
statement.execute("CREATE DATABASE IF NOT EXISTS db");
statement.execute(USE_DB);
statement.execute(
- "CREATE TABLE VIEW table0 (device string tag, s1 double field, s2
double field) as root.db.**");
+ "CREATE VIEW table0 (device string tag, s1 double field, s2 double
field) as root.db.**");
} catch (Exception e) {
e.printStackTrace();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/TableViewUtils.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/TableViewUtils.java
index d32a082494b..656f1b24faf 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/TableViewUtils.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/aligned/TableViewUtils.java
@@ -141,7 +141,7 @@ public class TableViewUtils {
private static final String[] createTableViewSqls = {
"CREATE DATABASE db",
"USE db",
- "CREATE TABLE VIEW table0 (device string tag, s1 FLOAT field, s2 INT32
field, s3 INT64 field, s4 BOOLEAN field, s5 TEXT field) as root.sg1.**",
+ "CREATE VIEW table0 (device string tag, s1 FLOAT field, s2 INT32 field, s3
INT64 field, s4 BOOLEAN field, s5 TEXT field) as root.sg1.**",
};
public static void insertData() {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/orderby/IoTDBOrderByTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/orderby/IoTDBOrderByTableViewIT.java
index 98bcc143202..5f733be9b92 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/orderby/IoTDBOrderByTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/orderby/IoTDBOrderByTableViewIT.java
@@ -87,7 +87,7 @@ public class IoTDBOrderByTableViewIT {
private static final String[] createTableViewSql = {
"CREATE DATABASE db",
"USE db",
- "CREATE TABLE VIEW table0 (device string tag, num int32 field, bignum
int64 field, "
+ "CREATE VIEW table0 (device string tag, num int32 field, bignum int64
field, "
+ "floatnum double field, str TEXT field, bool BOOLEAN field) as
root.sg.**",
};
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBArithmeticTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBArithmeticTableViewIT.java
index c87b6e49c51..9a6091e516d 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBArithmeticTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBArithmeticTableViewIT.java
@@ -92,8 +92,8 @@ public class IoTDBArithmeticTableViewIT {
private static final String[] CREATE_TABLE_VIEW_SQLS = {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1 (device STRING TAG, s1 INT32 FIELD, s2 INT64
FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 DATE FIELD, s6 TIMESTAMP FIELD, s7
BOOLEAN FIELD, s8 TEXT FIELD) as root.sg.**",
- "CREATE TABLE VIEW table2 (device STRING TAG, date DATE FIELD) as
root.sg2.**",
+ "CREATE VIEW table1 (device STRING TAG, s1 INT32 FIELD, s2 INT64 FIELD, s3
FLOAT FIELD, s4 DOUBLE FIELD, s5 DATE FIELD, s6 TIMESTAMP FIELD, s7 BOOLEAN
FIELD, s8 TEXT FIELD) as root.sg.**",
+ "CREATE VIEW table2 (device STRING TAG, date DATE FIELD) as root.sg2.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBPaginationTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBPaginationTableViewIT.java
index 969db06df13..9214ee1e698 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBPaginationTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/old/query/IoTDBPaginationTableViewIT.java
@@ -104,8 +104,8 @@ public class IoTDBPaginationTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW vehicle(device STRING TAG, s0 INT32 FIELD, s1 INT64
FIELD, s2 FLOAT FIELD) as root.vehicle.**",
- "CREATE TABLE VIEW db(device STRING TAG, s1 INT32 FIELD) as
root.db.**",
+ "CREATE VIEW vehicle(device STRING TAG, s0 INT32 FIELD, s1 INT64
FIELD, s2 FLOAT FIELD) as root.vehicle.**",
+ "CREATE VIEW db(device STRING TAG, s1 INT32 FIELD) as root.db.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBColumnsMatchTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBColumnsMatchTableViewIT.java
index 6ebcb4bd8e4..91e3beb3dbf 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBColumnsMatchTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBColumnsMatchTableViewIT.java
@@ -54,7 +54,7 @@ public class IoTDBColumnsMatchTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2
INT64 FIELD) as root.test.**",
+ "CREATE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2 INT64
FIELD) as root.test.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBComplexQueryTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBComplexQueryTableViewIT.java
index f7ac56dfc92..96f0a9de596 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBComplexQueryTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBComplexQueryTableViewIT.java
@@ -69,8 +69,8 @@ public class IoTDBComplexQueryTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "create table view employees(department_id STRING TAG,name TEXT
FIELD,Gender TEXT FIELD,Status BOOLEAN FIELD,employee_id INT32 FIELD,salary
DOUBLE FIELD,date_of_birth DATE FIELD,Contac_info string FIELD) as
root.test.employees.**",
- "create table view departments(department_id STRING TAG,dep_name TEXT
FIELD,dep_phone TEXT FIELD,dep_status BOOLEAN FIELD,dep_member INT32
FIELD,employee_id INT32 FIELD) as root.test.departments.**",
+ "create view employees(department_id STRING TAG,name TEXT FIELD,Gender
TEXT FIELD,Status BOOLEAN FIELD,employee_id INT32 FIELD,salary DOUBLE
FIELD,date_of_birth DATE FIELD,Contac_info string FIELD) as
root.test.employees.**",
+ "create view departments(department_id STRING TAG,dep_name TEXT
FIELD,dep_phone TEXT FIELD,dep_status BOOLEAN FIELD,dep_member INT32
FIELD,employee_id INT32 FIELD) as root.test.departments.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBDistinctTagTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBDistinctTagTableViewIT.java
index aa3919427ee..c5fc8889275 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBDistinctTagTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBDistinctTagTableViewIT.java
@@ -80,8 +80,8 @@ public class IoTDBDistinctTagTableViewIT {
new String[] {
"CREATE DATABASE IF NOT EXISTS test",
"USE test",
- "CREATE TABLE VIEW t1(deviceId STRING TAG, s1 INT64 FIELD) as
root.test.t1.**",
- "CREATE TABLE VIEW t2(deviceId STRING TAG, s1 INT64 FIELD) as
root.test.t2.**",
+ "CREATE VIEW t1(deviceId STRING TAG, s1 INT64 FIELD) as
root.test.t1.**",
+ "CREATE VIEW t2(deviceId STRING TAG, s1 INT64 FIELD) as
root.test.t2.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBFillTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBFillTableViewIT.java
index e3b43f51e5a..68dfaf27176 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBFillTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBFillTableViewIT.java
@@ -92,9 +92,9 @@ public class IoTDBFillTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2
INT64 FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD,
s7 STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
- "CREATE TABLE VIEW table2(city STRING TAG, device_id STRING TAG, s1
INT32 FIELD, s2 INT64 FIELD) as root.test.table2.**",
- "CREATE TABLE VIEW table3(city STRING TAG, device_id STRING TAG, s1
INT32 FIELD, s2 INT64 FIELD) as root.test.table3.**",
+ "CREATE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2 INT64
FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD, s7
STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
+ "CREATE VIEW table2(city STRING TAG, device_id STRING TAG, s1 INT32
FIELD, s2 INT64 FIELD) as root.test.table2.**",
+ "CREATE VIEW table3(city STRING TAG, device_id STRING TAG, s1 INT32
FIELD, s2 INT64 FIELD) as root.test.table3.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBGapFillTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBGapFillTableViewIT.java
index b0ea4c4d26e..af2edb5e489 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBGapFillTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBGapFillTableViewIT.java
@@ -62,7 +62,7 @@ public class IoTDBGapFillTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE view table1(city STRING TAG, device_id STRING TAG, s1
DOUBLE FIELD, s2 INT64 FIELD) as root.table1.**",
+ "create view table1(city STRING TAG, device_id STRING TAG, s1 DOUBLE
FIELD, s2 INT64 FIELD) as root.table1.**",
};
private static final String MULTI_GAFILL_ERROR_MSG =
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullIdQueryTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullIdQueryTableViewIT.java
index 1639978c1eb..48b9f89e0c6 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullIdQueryTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullIdQueryTableViewIT.java
@@ -78,8 +78,8 @@ public class IoTDBNullIdQueryTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW testNullId(id1 STRING TAG, id2 STRING TAG, s1 INT32
FIELD, s2 BOOLEAN FIELD, s3 DOUBLE FIELD) as root.test.testNullId.**",
- "CREATE TABLE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2
BOOLEAN FIELD, s3 INT64 FIELD) as root.test.table1.**",
+ "CREATE VIEW testNullId(id1 STRING TAG, id2 STRING TAG, s1 INT32
FIELD, s2 BOOLEAN FIELD, s3 DOUBLE FIELD) as root.test.testNullId.**",
+ "CREATE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2 BOOLEAN
FIELD, s3 INT64 FIELD) as root.test.table1.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullValueTableViewIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullValueTableViewIT.java
index d48df1d70a0..073db94a9b8 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullValueTableViewIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBNullValueTableViewIT.java
@@ -54,7 +54,7 @@ public class IoTDBNullValueTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "create table view table1(id1 tag, s1 string) as root.test.table1.**",
+ "create view table1(id1 tag, s1 string) as root.test.table1.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationFunctionDistinctIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationFunctionDistinctIT.java
index dc54826deb5..2285bc9cf26 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationFunctionDistinctIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationFunctionDistinctIT.java
@@ -59,7 +59,7 @@ public class IoTDBTableViewAggregationFunctionDistinctIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2
INT64 FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD,
s7 STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
+ "CREATE VIEW table1(device_id STRING TAG, s1 INT32 FIELD, s2 INT64
FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD, s7
STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationIT.java
index d247d402c93..e3c01f5e6d4 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationIT.java
@@ -133,7 +133,7 @@ public class IoTDBTableViewAggregationIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1(province STRING TAG, city STRING TAG, region
STRING TAG, device_id STRING TAG, s1 INT32 FIELD, s2 INT64 FIELD, s3 FLOAT
FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD, s7 STRING FIELD, s8
BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as root.test.table1.**",
+ "CREATE VIEW table1(province STRING TAG, city STRING TAG, region
STRING TAG, device_id STRING TAG, s1 INT32 FIELD, s2 INT64 FIELD, s3 FLOAT
FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD, s7 STRING FIELD, s8
BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as root.test.table1.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationNonStreamIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationNonStreamIT.java
index 42750cce6f0..dbe22b168f1 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationNonStreamIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewAggregationNonStreamIT.java
@@ -133,7 +133,7 @@ public class IoTDBTableViewAggregationNonStreamIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW table1(province STRING FIELD, city STRING FIELD,
region STRING FIELD FROM region1, device_id STRING TAG, s1 INT32 FIELD, s2
INT64 FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD,
s7 STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
+ "CREATE VIEW table1(province STRING FIELD, city STRING FIELD, region
STRING FIELD FROM region1, device_id STRING TAG, s1 INT32 FIELD, s2 INT64
FIELD, s3 FLOAT FIELD, s4 DOUBLE FIELD, s5 BOOLEAN FIELD, s6 TEXT FIELD, s7
STRING FIELD, s8 BLOB FIELD, s9 TIMESTAMP FIELD, s10 DATE FIELD) as
root.test.table1.**",
};
@BeforeClass
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryIT.java
index 17daabbc601..17a5cf9ad00 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/query/view/recent/IoTDBTableViewQueryIT.java
@@ -104,9 +104,9 @@ public class IoTDBTableViewQueryIT {
protected static String[] createTableSqls = {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
- "CREATE TABLE VIEW view1 (battery TAG, voltage INT32 FIELD, current FLOAT
FIELD) as root.db.battery.**",
- "CREATE TABLE VIEW view2 (battery TAG, voltage INT32 FIELD FROM voltage,
current_rename FLOAT FIELD FROM current) as root.db.battery.**",
- "CREATE TABLE VIEW view3 (battery TAG, voltage INT32 FIELD FROM voltage,
current_rename FLOAT FIELD FROM current) as root.db.battery.** with (ttl=1)",
+ "CREATE VIEW view1 (battery TAG, voltage INT32 FIELD, current FLOAT FIELD)
as root.db.battery.**",
+ "CREATE VIEW view2 (battery TAG, voltage INT32 FIELD FROM voltage,
current_rename FLOAT FIELD FROM current) as root.db.battery.**",
+ "CREATE VIEW view3 (battery TAG, voltage INT32 FIELD FROM voltage,
current_rename FLOAT FIELD FROM current) with (ttl=1) as root.db.battery.**",
"CREATE TABLE table1 (battery TAG, voltage INT32 FIELD, current FLOAT
FIELD)",
"INSERT INTO table1 (time, battery, voltage, current) values (1, 'b1', 1,
1)",
"INSERT INTO table1 (time, battery, voltage, current) values (2, 'b1', 1,
1)",
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
index b19f1a1d869..a049bd5e7c3 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBDatabaseIT.java
@@ -532,7 +532,7 @@ public class IoTDBDatabaseIT {
statement.execute(
"create table test.test (a tag, b attribute, c int32 comment
'turbine') comment 'test'");
statement.execute(
- "CREATE TABLE VIEW test.view_table (tag1 STRING TAG,tag2 STRING
TAG,s11 INT32 FIELD,s3 INT32 FIELD FROM s2) AS root.a.** WITH (ttl=100)
RESTRICT");
+ "CREATE VIEW test.view_table (tag1 STRING TAG,tag2 STRING TAG,s11
INT32 FIELD,s3 INT32 FIELD FROM s2) RESTRICT WITH (ttl=100) AS root.a.**");
TestUtils.assertResultSetEqual(
statement.executeQuery("select * from databases"),
@@ -561,7 +561,7 @@ public class IoTDBDatabaseIT {
"information_schema,configurations,INF,USING,null,SYSTEM
VIEW,",
"information_schema,keywords,INF,USING,null,SYSTEM VIEW,",
"test,test,INF,USING,test,BASE TABLE,",
- "test,view_table,100,USING,null,TREE_TO_TABLE VIEW,")));
+ "test,view_table,100,USING,null,VIEW FROM TREE,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("count devices from tables where status =
'USING'"),
"count(devices),",
@@ -612,7 +612,7 @@ public class IoTDBDatabaseIT {
statement.executeQuery("select * from views"),
"database,table_name,view_definition,",
Collections.singleton(
- "test,view_table,CREATE TABLE VIEW \"view_table\" (\"tag1\"
STRING TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" INT32 FIELD FROM
\"s2\") AS root.a.** WITH (ttl=100) RESTRICT,"));
+ "test,view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" INT32 FIELD FROM \"s2\")
RESTRICT WITH (ttl=100) AS root.a.**,"));
TestUtils.assertResultSetEqual(
statement.executeQuery(
diff --git
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
index 3104a7cd932..cef3d3a754d 100644
---
a/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java
@@ -774,7 +774,7 @@ public class IoTDBTableIT {
final Statement statement = connection.createStatement()) {
statement.execute("create database tree_view_db");
statement.execute("use tree_view_db");
- statement.execute("create table view tree_table (tag1 tag, tag2 tag) as
root.a.**");
+ statement.execute("create view tree_table (tag1 tag, tag2 tag) as
root.a.**");
statement.execute("drop view tree_table");
}
@@ -791,7 +791,7 @@ public class IoTDBTableIT {
statement.execute("use tree_view_db");
try {
- statement.execute("create table view tree_table (tag1 tag, tag2 tag)
as root.a.**");
+ statement.execute("create view tree_table (tag1 tag, tag2 tag) as
root.a.**");
fail();
} catch (final SQLException e) {
final Set<String> result =
@@ -806,7 +806,8 @@ public class IoTDBTableIT {
try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("drop timeSeries root.a.b.d.s1");
- statement.execute("create timeSeries root.a.b.d.S1 boolean");
+ statement.execute("create device template t1 (S1 boolean, s9 int32)");
+ statement.execute("set schema template t1 to root.a.b.d");
statement.execute("create timeSeries root.a.b.c.f.g.h.S1 int32");
// Put schema cache
@@ -821,7 +822,7 @@ public class IoTDBTableIT {
statement.execute("use tree_view_db");
try {
- statement.execute("create table view tree_table (tag1 tag, tag2 tag)
as root.a.**");
+ statement.execute("create view tree_table (tag1 tag, tag2 tag) as
root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
@@ -830,8 +831,7 @@ public class IoTDBTableIT {
}
try {
- statement.execute(
- "create table view tree_table (tag1 tag, tag2 tag, S1 field) as
root.a.**");
+ statement.execute("create view tree_table (tag1 tag, tag2 tag, S1
field) as root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
@@ -855,15 +855,23 @@ public class IoTDBTableIT {
// Temporary
try {
statement.execute(
- "create or replace table view tree_table (tag1 tag, tag2 tag, S1
int32 field, s3 boolean from S1) as root.a.**");
+ "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32
field, s3 boolean from S1) as root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
"701: The duplicated source measurement S1 is unsupported yet.",
e.getMessage());
}
+ try {
+ statement.execute(
+ "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32
field, s3 from s2, s8 field) as root.a.**");
+ fail();
+ } catch (final SQLException e) {
+ assertEquals("528: Measurements not found for s8, cannot auto detect",
e.getMessage());
+ }
+
statement.execute(
- "create or replace table view tree_table (tag1 tag, tag2 tag, S1
int32 field, s3 from s2) as root.a.**");
+ "create or replace view tree_table (tag1 tag, tag2 tag, S1 int32
field, s3 from s2) as root.a.**");
statement.execute("alter view tree_table rename to view_table");
statement.execute("alter view view_table rename column s1 to s11");
statement.execute("alter view view_table set properties ttl=100");
@@ -872,7 +880,7 @@ public class IoTDBTableIT {
TestUtils.assertResultSetEqual(
statement.executeQuery("show tables details"),
"TableName,TTL(ms),Status,Comment,TableType,",
- Collections.singleton("view_table,100,USING,comment,TREE_TO_TABLE
VIEW,"));
+ Collections.singleton("view_table,100,USING,comment,VIEW FROM
TREE,"));
TestUtils.assertResultSetEqual(
statement.executeQuery("desc view_table"),
@@ -890,7 +898,7 @@ public class IoTDBTableIT {
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from view_table where tag1 =
'b'"),
"tag1,tag2,",
- new HashSet<>(Arrays.asList("b,c,", "b,null,", "b,d,", "b,e,")));
+ new HashSet<>(Arrays.asList("b,c,", "b,null,", "b,e,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from view_table where tag1 =
'b' and tag2 is null"),
"tag1,tag2,",
@@ -898,7 +906,7 @@ public class IoTDBTableIT {
TestUtils.assertResultSetEqual(
statement.executeQuery("count devices from view_table"),
"count(devices),",
- Collections.singleton("4,"));
+ Collections.singleton("3,"));
}
// Test tree session
@@ -906,9 +914,11 @@ public class IoTDBTableIT {
final Statement statement = connection.createStatement()) {
// Test create & replace + restrict
statement.execute(
- "create or replace table view tree_view_db.view_table (tag1 tag,
tag2 tag, s11 int32 field, s3 from s2) as root.a.** with (ttl=100) restrict");
- } catch (SQLException e) {
- fail(e.getMessage());
+ "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag,
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.a.**");
+ fail();
+ } catch (final SQLException e) {
+ assertTrue(
+ e.getMessage().contains("The 'CreateTableView' is unsupported in
tree sql-dialect."));
}
// Test permission
@@ -924,7 +934,7 @@ public class IoTDBTableIT {
EnvFactory.getEnv().getConnection("testUser", "testUser",
BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
- "create or replace table view tree_view_db.view_table (tag1 tag,
tag2 tag, s11 int32 field, s3 from s2) as root.a.** with (ttl=100) restrict");
+ "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag,
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
@@ -944,7 +954,7 @@ public class IoTDBTableIT {
EnvFactory.getEnv().getConnection("testUser", "testUser",
BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
- "create or replace table view tree_view_db.view_table (tag1 tag,
tag2 tag, s11 int32 field, s3 from s2) as root.a.** with (ttl=100) restrict");
+ "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag,
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
@@ -963,7 +973,7 @@ public class IoTDBTableIT {
EnvFactory.getEnv().getConnection("testUser", "testUser",
BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
- "create or replace table view tree_view_db.view_table (tag1 tag,
tag2 tag, s11 int32 field, s3 from s2) as root.a.** with (ttl=100) restrict");
+ "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag,
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.a.**");
fail();
} catch (final SQLException e) {
assertEquals(
@@ -982,7 +992,7 @@ public class IoTDBTableIT {
EnvFactory.getEnv().getConnection("testUser", "testUser",
BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
- "create or replace table view tree_view_db.view_table (tag1 tag,
tag2 tag, s11 int32 field, s3 from s2) as root.a.** with (ttl=100) restrict");
+ "create or replace view tree_view_db.view_table (tag1 tag, tag2 tag,
s11 int32 field, s3 from s2) restrict with (ttl=100) as root.a.**");
} catch (final SQLException e) {
fail();
}
@@ -1001,14 +1011,14 @@ public class IoTDBTableIT {
statement.executeQuery("show create view view_table"),
"View,Create View,",
Collections.singleton(
- "view_table,CREATE TABLE VIEW \"view_table\" (\"tag1\" STRING
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") AS
root.a.** WITH (ttl=100) RESTRICT,"));
+ "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\")
RESTRICT WITH (ttl=100) AS root.a.**,"));
// Can also use "show create table"
TestUtils.assertResultSetEqual(
statement.executeQuery("show create table view_table"),
"View,Create View,",
Collections.singleton(
- "view_table,CREATE TABLE VIEW \"view_table\" (\"tag1\" STRING
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\") AS
root.a.** WITH (ttl=100) RESTRICT,"));
+ "view_table,CREATE VIEW \"view_table\" (\"tag1\" STRING
TAG,\"tag2\" STRING TAG,\"s11\" INT32 FIELD,\"s3\" STRING FIELD FROM \"s2\")
RESTRICT WITH (ttl=100) AS root.a.**,"));
statement.execute("create table a ()");
try {
@@ -1025,7 +1035,7 @@ public class IoTDBTableIT {
assertEquals("701: The system view does not support show create.",
e.getMessage());
}
try {
- statement.execute("create or replace table view a () as root.b.**");
+ statement.execute("create or replace view a () as root.b.**");
fail();
} catch (final SQLException e) {
assertEquals("551: Table 'tree_view_db.a' already exists.",
e.getMessage());
diff --git
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
index 2dfd93e5b39..94be2e9fef7 100644
---
a/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
+++
b/iotdb-core/antlr/src/main/antlr4/org/apache/iotdb/db/qp/sql/IoTDBSqlParser.g4
@@ -780,12 +780,12 @@ viewSourcePaths
// Table view
createTableView
- : CREATE (OR REPLACE)? TABLE VIEW qualifiedName
- LR_BRACKET (viewColumnDefinition (COMMA viewColumnDefinition)*)
RR_BRACKET
- AS prefixPath
+ : CREATE (OR REPLACE)? VIEW qualifiedName
+ LR_BRACKET (viewColumnDefinition (COMMA viewColumnDefinition)*)?
RR_BRACKET
comment?
- (WITH properties)?
(RESTRICT)?
+ (WITH properties)?
+ AS prefixPath
;
viewColumnDefinition
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
index a8e2d9e7d6c..d3a7b79305c 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java
@@ -1271,7 +1271,7 @@ public class ClusterSchemaInfo implements
SnapshotProcessor {
.ifPresent(info::setComment);
info.setType(
TreeViewSchema.isTreeViewTable(pair.getLeft())
- ? TableType.TREE_TO_TABLE_VIEW.ordinal()
+ ? TableType.VIEW_FROM_TREE.ordinal()
: TableType.BASE_TABLE.ordinal());
return info;
})
@@ -1319,7 +1319,7 @@ public class ClusterSchemaInfo implements
SnapshotProcessor {
.ifPresent(info::setComment);
info.setType(
TreeViewSchema.isTreeViewTable(pair.getLeft())
- ?
TableType.TREE_TO_TABLE_VIEW.ordinal()
+ ?
TableType.VIEW_FROM_TREE.ordinal()
: TableType.BASE_TABLE.ordinal());
return info;
})
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
index 29e3dcf2938..cf3d6ad0786 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ConfigMTree.java
@@ -558,7 +558,6 @@ public class ConfigMTree {
protected boolean shouldVisitSubtreeOfFullMatchedNode(final
IConfigMNode node) {
// descendants of the node cannot set another template, exit from
this branch
return node.getSchemaTemplateId() == NON_TEMPLATE
- && !(node.isDatabase() &&
node.getDatabaseSchema().isIsTableModel())
&& super.shouldVisitSubtreeOfFullMatchedNode(node);
}
@@ -566,7 +565,6 @@ public class ConfigMTree {
protected boolean shouldVisitSubtreeOfInternalMatchedNode(final
IConfigMNode node) {
// descendants of the node cannot set another template, exit from
this branch
return node.getSchemaTemplateId() == NON_TEMPLATE
- && !(node.isDatabase() &&
node.getDatabaseSchema().isIsTableModel())
&& super.shouldVisitSubtreeOfInternalMatchedNode(node);
}
}) {
@@ -575,7 +573,10 @@ public class ConfigMTree {
return resSet;
}
- /** This method returns the templateId set on paths covered by input path
pattern. */
+ /**
+ * This method returns the templateId set on paths if the path set matches
or is a prefix of input
+ * path pattern.
+ */
public Map<Integer, Set<PartialPath>> getTemplateSetInfo(final PartialPath
pathPattern)
throws MetadataException {
final Map<Integer, Set<PartialPath>> result = new HashMap<>();
@@ -606,7 +607,6 @@ public class ConfigMTree {
protected boolean shouldVisitSubtreeOfFullMatchedNode(final
IConfigMNode node) {
// descendants of the node cannot set another template, exit from
this branch
return node.getSchemaTemplateId() == NON_TEMPLATE
- && !(node.isDatabase() &&
node.getDatabaseSchema().isIsTableModel())
&& super.shouldVisitSubtreeOfFullMatchedNode(node);
}
@@ -614,7 +614,6 @@ public class ConfigMTree {
protected boolean shouldVisitSubtreeOfInternalMatchedNode(final
IConfigMNode node) {
// descendants of the node cannot set another template, exit from
this branch
return node.getSchemaTemplateId() == NON_TEMPLATE
- && !(node.isDatabase() &&
node.getDatabaseSchema().isIsTableModel())
&& super.shouldVisitSubtreeOfInternalMatchedNode(node);
}
}) {
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TreeDeviceViewFieldDetector.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TreeDeviceViewFieldDetector.java
index 3527e62e7a3..0b0fae36288 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TreeDeviceViewFieldDetector.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TreeDeviceViewFieldDetector.java
@@ -42,8 +42,11 @@ import org.apache.tsfile.enums.TSDataType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import javax.annotation.Nonnull;
+
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
@@ -173,6 +176,17 @@ public class TreeDeviceViewFieldDetector {
((dataNodeLocation, consensusGroupIdList) ->
new TDeviceViewReq(
consensusGroupIdList, Arrays.asList(path.getNodes()),
tagNumber, restrict)));
+ configManager
+ .getClusterSchemaManager()
+ .getTemplateSetInfo(Collections.singletonList(path))
+ .getPatternTemplateMap()
+ .values()
+ .stream()
+ .flatMap(Collection::stream)
+ .flatMap(template -> template.getSchemaMap().values().stream())
+ .forEach(
+ schema ->
+ mergeMeasurementAndType(schema.getMeasurementName(),
schema.getTypeInByte()));
}
protected TreeDeviceViewFieldDetectionTaskExecutor(
@@ -180,7 +194,7 @@ public class TreeDeviceViewFieldDetector {
final Map<TConsensusGroupId, TRegionReplicaSet> targetRegionGroup,
final int tagNumber,
final boolean restrict,
- final Set<String> measurements) {
+ final @Nonnull Set<String> measurements) {
super(
configManager,
targetRegionGroup,
@@ -190,6 +204,18 @@ public class TreeDeviceViewFieldDetector {
new TDeviceViewReq(
consensusGroupIdList, Arrays.asList(path.getNodes()),
tagNumber, restrict)
.setRequiredMeasurements(measurements)));
+ configManager
+ .getClusterSchemaManager()
+ .getTemplateSetInfo(Collections.singletonList(path))
+ .getPatternTemplateMap()
+ .values()
+ .stream()
+ .flatMap(Collection::stream)
+ .flatMap(template -> template.getSchemaMap().values().stream())
+ .filter(schema -> measurements.contains(schema.getMeasurementName()))
+ .forEach(
+ schema ->
+ mergeMeasurementAndType(schema.getMeasurementName(),
schema.getTypeInByte()));
}
@Override
@@ -235,36 +261,35 @@ public class TreeDeviceViewFieldDetector {
private void mergeDeviceViewResp(final TDeviceViewResp resp) {
// The map is always nonnull in the resp
- resp.getDeviewViewFieldTypeMap()
- .forEach(
- (measurement, type) -> {
- final String fieldName =
measurement.toLowerCase(Locale.ENGLISH);
+ resp.getDeviewViewFieldTypeMap().forEach(this::mergeMeasurementAndType);
+ }
- // Field type collection
- if
(!result.getDeviewViewFieldTypeMap().containsKey(fieldName)) {
- result.getDeviewViewFieldTypeMap().put(fieldName, type);
- } else if (!Objects.equals(
- result.getDeviewViewFieldTypeMap().get(fieldName), type)) {
- result.setStatus(
- RpcUtils.getStatus(
- TSStatusCode.DATA_TYPE_MISMATCH,
- String.format(
- "Multiple types encountered when auto detecting
type of measurement '%s', please check",
- measurement)));
- }
+ private void mergeMeasurementAndType(final String measurement, final byte
type) {
+ final String fieldName = measurement.toLowerCase(Locale.ENGLISH);
- // Field name detection
- if (!lowerCase2OriginalMap.containsKey(fieldName)) {
- lowerCase2OriginalMap.put(fieldName, measurement);
- } else if
(!Objects.equals(lowerCase2OriginalMap.get(fieldName), measurement)) {
- result.setStatus(
- RpcUtils.getStatus(
- TSStatusCode.MEASUREMENT_NAME_CONFLICT,
- String.format(
- "The measurements %s and %s share the same lower
case when auto detecting type, please check",
- lowerCase2OriginalMap.get(fieldName),
measurement)));
- }
- });
+ // Field type collection
+ if (!result.getDeviewViewFieldTypeMap().containsKey(fieldName)) {
+ result.getDeviewViewFieldTypeMap().put(fieldName, type);
+ } else if
(!Objects.equals(result.getDeviewViewFieldTypeMap().get(fieldName), type)) {
+ result.setStatus(
+ RpcUtils.getStatus(
+ TSStatusCode.DATA_TYPE_MISMATCH,
+ String.format(
+ "Multiple types encountered when auto detecting type of
measurement '%s', please check",
+ measurement)));
+ }
+
+ // Field name detection
+ if (!lowerCase2OriginalMap.containsKey(fieldName)) {
+ lowerCase2OriginalMap.put(fieldName, measurement);
+ } else if (!Objects.equals(lowerCase2OriginalMap.get(fieldName),
measurement)) {
+ result.setStatus(
+ RpcUtils.getStatus(
+ TSStatusCode.MEASUREMENT_NAME_CONFLICT,
+ String.format(
+ "The measurements %s and %s share the same lower case when
auto detecting type, please check",
+ lowerCase2OriginalMap.get(fieldName), measurement)));
+ }
}
@Override
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateTableViewProcedureTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateViewProcedureTest.java
similarity index 98%
rename from
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateTableViewProcedureTest.java
rename to
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateViewProcedureTest.java
index 8d89fe58df5..0c0a0c714a8 100644
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateTableViewProcedureTest.java
+++
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/CreateViewProcedureTest.java
@@ -37,7 +37,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
-public class CreateTableViewProcedureTest {
+public class CreateViewProcedureTest {
@Test
public void serializeDeserializeTest() throws IllegalPathException,
IOException {
final TsTable table = new TsTable("table1");
diff --git
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateTableViewProcedureTest.java
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateViewProcedureTest.java
similarity index 98%
rename from
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateTableViewProcedureTest.java
rename to
iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateViewProcedureTest.java
index 0fb0d344356..593128ad696 100644
---
a/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateTableViewProcedureTest.java
+++
b/iotdb-core/confignode/src/test/java/org/apache/iotdb/confignode/procedure/impl/schema/table/view/CreateViewProcedureTest.java
@@ -37,7 +37,7 @@ import java.io.DataOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
-public class CreateTableViewProcedureTest {
+public class CreateViewProcedureTest {
@Test
public void serializeDeserializeTest() throws IllegalPathException,
IOException {
final TsTable table = new TsTable("table1");
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
index 610da9375b8..b75d8fda5db 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java
@@ -125,9 +125,9 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateFunction;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipe;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipePlugin;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTable;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTopic;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTraining;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DataType;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DatabaseStatement;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DeleteDevice;
@@ -466,8 +466,7 @@ public class TableConfigTaskVisitor extends
AstVisitor<IConfigTask, MPPQueryCont
}
@Override
- protected IConfigTask visitCreateTableView(
- final CreateTableView node, final MPPQueryContext context) {
+ protected IConfigTask visitCreateView(final CreateView node, final
MPPQueryContext context) {
final Pair<String, TsTable> databaseTablePair =
parseTable4CreateTableOrView(node, context);
final TsTable table = databaseTablePair.getRight();
accessControl.checkCanCreateViewFromTreePath(
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
index f0b66291d3e..5e8ca0688d0 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/metadata/relational/ShowCreateViewTask.java
@@ -86,9 +86,7 @@ public class ShowCreateViewTask extends AbstractTableTask {
public static String getShowCreateViewSQL(final TsTable table) {
final StringBuilder builder =
- new StringBuilder("CREATE TABLE VIEW ")
- .append(getIdentifier(table.getTableName()))
- .append(" (");
+ new StringBuilder("CREATE VIEW
").append(getIdentifier(table.getTableName())).append(" (");
for (final TsTableColumnSchema schema : table.getColumnList()) {
switch (schema.getColumnCategory()) {
@@ -128,19 +126,23 @@ public class ShowCreateViewTask extends AbstractTableTask
{
builder.deleteCharAt(builder.length() - 1);
}
- builder.append(") AS
").append(table.getPropValue(TreeViewSchema.TREE_PATH_PATTERN).get());
+ builder.append(")");
if (table.getPropValue(TsTable.COMMENT_KEY).isPresent()) {
builder.append(" COMMENT
").append(getString(table.getPropValue(TsTable.COMMENT_KEY).get()));
}
+
+ if (TreeViewSchema.isRestrict(table)) {
+ builder.append(" RESTRICT");
+ }
+
builder
.append(" WITH (ttl=")
.append(table.getPropValue(TsTable.TTL_PROPERTY).orElse("'" +
TTL_INFINITE + "'"))
.append(")");
- if (TreeViewSchema.isRestrict(table)) {
- builder.append(" RESTRICT");
- }
+ builder.append(" AS
").append(table.getPropValue(TreeViewSchema.TREE_PATH_PATTERN).get());
+
return builder.toString();
}
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
index 0d2c719373c..f91017e44fe 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/parser/ASTVisitor.java
@@ -96,7 +96,7 @@ import
org.apache.iotdb.db.queryengine.plan.expression.unary.LogicNotExpression;
import
org.apache.iotdb.db.queryengine.plan.expression.unary.NegationExpression;
import org.apache.iotdb.db.queryengine.plan.expression.unary.RegularExpression;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.ColumnDefinition;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DataType;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DataTypeParameter;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.GenericDataType;
@@ -4604,8 +4604,12 @@ public class ASTVisitor extends
IoTDBSqlParserBaseVisitor<Statement> {
@Override
public Statement visitCreateTableView(final
IoTDBSqlParser.CreateTableViewContext ctx) {
+ if (true) {
+ throw new UnsupportedOperationException(
+ "The 'CreateTableView' is unsupported in tree sql-dialect.");
+ }
return new CreateTableViewStatement(
- new CreateTableView(
+ new CreateView(
null,
getQualifiedName(ctx.qualifiedName()),
ctx.viewColumnDefinition().stream()
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
index e99a7f62a79..df9fa7052e4 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/analyzer/StatementAnalyzer.java
@@ -73,8 +73,8 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateOrUpdateDev
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipe;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipePlugin;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTable;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTopic;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Delete;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DeleteDevice;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DereferenceExpression;
@@ -409,8 +409,7 @@ public class StatementAnalyzer {
}
@Override
- protected Scope visitCreateTableView(
- final CreateTableView node, final Optional<Scope> context) {
+ protected Scope visitCreateView(final CreateView node, final
Optional<Scope> context) {
validateProperties(node.getProperties(), context);
return createAndAssignScope(node, context);
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
index 3345f626f66..8ed558a8a63 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/AstVisitor.java
@@ -333,7 +333,7 @@ public abstract class AstVisitor<R, C> {
return visitStatement(node, context);
}
- protected R visitCreateTableView(final CreateTableView node, final C
context) {
+ protected R visitCreateView(final CreateView node, final C context) {
return visitStatement(node, context);
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateTableView.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateView.java
similarity index 89%
rename from
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateTableView.java
rename to
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateView.java
index d19f9c7e1cd..d0ed0681a61 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateTableView.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/CreateView.java
@@ -28,12 +28,12 @@ import java.util.Objects;
import static com.google.common.base.MoreObjects.toStringHelper;
-public class CreateTableView extends CreateTable {
+public class CreateView extends CreateTable {
private final PartialPath prefixPath;
private final boolean replace;
private final boolean restrict;
- public CreateTableView(
+ public CreateView(
final @Nullable NodeLocation location,
final QualifiedName name,
final List<ColumnDefinition> elements,
@@ -63,15 +63,15 @@ public class CreateTableView extends CreateTable {
@Override
public <R, C> R accept(final AstVisitor<R, C> visitor, final C context) {
- return visitor.visitCreateTableView(this, context);
+ return visitor.visitCreateView(this, context);
}
@Override
public boolean equals(final Object o) {
return super.equals(o)
- && Objects.equals(prefixPath, ((CreateTableView) o).prefixPath)
- && replace == ((CreateTableView) o).replace
- && restrict == ((CreateTableView) o).restrict;
+ && Objects.equals(prefixPath, ((CreateView) o).prefixPath)
+ && replace == ((CreateView) o).replace
+ && restrict == ((CreateView) o).restrict;
}
@Override
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DefaultTraversalVisitor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DefaultTraversalVisitor.java
index 6ab160a1733..ce5970d0fb0 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DefaultTraversalVisitor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/ast/DefaultTraversalVisitor.java
@@ -418,7 +418,7 @@ public abstract class DefaultTraversalVisitor<C> extends
AstVisitor<Void, C> {
}
@Override
- protected Void visitCreateTableView(final CreateTableView node, final C
context) {
+ protected Void visitCreateView(final CreateView node, final C context) {
for (final Property property : node.getProperties()) {
process(property, context);
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
index 6e0f789b767..2feaaaedf96 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/parser/AstBuilder.java
@@ -60,9 +60,9 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateIndex;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipe;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipePlugin;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTable;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTopic;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTraining;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentDatabase;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentTime;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CurrentUser;
@@ -525,13 +525,12 @@ public class AstBuilder extends
RelationalSqlBaseVisitor<Node> {
}
@Override
- public Node visitCreateTableViewStatement(
- final RelationalSqlParser.CreateTableViewStatementContext ctx) {
+ public Node visitCreateViewStatement(final
RelationalSqlParser.CreateViewStatementContext ctx) {
List<Property> properties = ImmutableList.of();
if (ctx.properties() != null) {
properties = visit(ctx.properties().propertyAssignments().property(),
Property.class);
}
- return new CreateTableView(
+ return new CreateView(
getLocation(ctx),
getQualifiedName(ctx.qualifiedName()),
visit(ctx.viewColumnDefinition(), ColumnDefinition.class),
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/SqlFormatter.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/SqlFormatter.java
index 5d075961561..3225e395cd5 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/SqlFormatter.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/relational/sql/util/SqlFormatter.java
@@ -31,8 +31,8 @@ import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateFunction;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipe;
import
org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreatePipePlugin;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTable;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTopic;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.Delete;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DropColumn;
import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.DropDB;
@@ -672,12 +672,12 @@ public final class SqlFormatter {
}
@Override
- protected Void visitCreateTableView(final CreateTableView node, final
Integer indent) {
+ protected Void visitCreateView(final CreateView node, final Integer
indent) {
builder.append("CREATE ");
if (node.isReplace()) {
builder.append("OR REPLACE ");
}
- builder.append("TABLE VIEW ");
+ builder.append("VIEW ");
final String tableName = formatName(node.getName());
builder.append(tableName).append(" (\n");
@@ -700,12 +700,14 @@ public final class SqlFormatter {
builder.append(" COMMENT '").append(node.getComment()).append("'");
}
- builder.append(formatPropertiesMultiLine(node.getProperties()));
-
if (node.isRestrict()) {
builder.append(" RESTRICT");
}
+ builder.append(formatPropertiesMultiLine(node.getProperties()));
+
+ builder.append(" AS ").append(node.getPrefixPath().toString());
+
return null;
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/view/CreateTableViewStatement.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/view/CreateTableViewStatement.java
index 3d5c90cabd0..f41a6debd7e 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/view/CreateTableViewStatement.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/statement/metadata/view/CreateTableViewStatement.java
@@ -20,20 +20,20 @@
package org.apache.iotdb.db.queryengine.plan.statement.metadata.view;
import org.apache.iotdb.commons.path.PartialPath;
-import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateTableView;
+import org.apache.iotdb.db.queryengine.plan.relational.sql.ast.CreateView;
import org.apache.iotdb.db.queryengine.plan.statement.Statement;
import java.util.List;
public class CreateTableViewStatement extends Statement {
- private final CreateTableView createTableView;
+ private final CreateView createView;
- public CreateTableViewStatement(final CreateTableView createTableView) {
- this.createTableView = createTableView;
+ public CreateTableViewStatement(final CreateView createView) {
+ this.createView = createView;
}
- public CreateTableView getCreateTableView() {
- return createTableView;
+ public CreateView getCreateTableView() {
+ return createView;
}
@Override
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/TreeToTableViewAdaptorOperatorTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/ViewFromTreeAdaptorOperatorTest.java
similarity index 96%
rename from
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/TreeToTableViewAdaptorOperatorTest.java
rename to
iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/ViewFromTreeAdaptorOperatorTest.java
index 8ef662e9db9..21ee785aa33 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/TreeToTableViewAdaptorOperatorTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/queryengine/execution/operator/ViewFromTreeAdaptorOperatorTest.java
@@ -74,9 +74,9 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-public class TreeToTableViewAdaptorOperatorTest {
- private static final String TREE_TO_TABLE_VIEW_ADAPTOR_OPERATOR_TEST =
- "root.TreeToTableViewAdaptorOperatorTest";
+public class ViewFromTreeAdaptorOperatorTest {
+ private static final String VIEW_FROM_TREE_ADAPTOR_OPERATOR_TEST =
+ "root.ViewFromTreeAdaptorOperatorTest";
private static final List<IMeasurementSchema> measurementSchemas = new
ArrayList<>();
private static final List<TsFileResource> seqResources = new ArrayList<>();
@@ -87,7 +87,7 @@ public class TreeToTableViewAdaptorOperatorTest {
@BeforeClass
public static void setUp() throws MetadataException, IOException,
WriteProcessException {
AlignedSeriesTestUtil.setUp(
- measurementSchemas, seqResources, unSeqResources,
TREE_TO_TABLE_VIEW_ADAPTOR_OPERATOR_TEST);
+ measurementSchemas, seqResources, unSeqResources,
VIEW_FROM_TREE_ADAPTOR_OPERATOR_TEST);
}
@AfterClass
@@ -104,7 +104,7 @@ public class TreeToTableViewAdaptorOperatorTest {
AlignedFullPath alignedPath =
new AlignedFullPath(
IDeviceID.Factory.DEFAULT_FACTORY.create(
- TREE_TO_TABLE_VIEW_ADAPTOR_OPERATOR_TEST + ".device0"),
+ VIEW_FROM_TREE_ADAPTOR_OPERATOR_TEST + ".device0"),
measurementSchemas.stream()
.map(IMeasurementSchema::getMeasurementName)
.collect(Collectors.toList()),
@@ -180,7 +180,7 @@ public class TreeToTableViewAdaptorOperatorTest {
columnSchemas,
seriesScanOperator,
TableOperatorGenerator.createTreeDeviceIdColumnValueExtractor(
- TREE_TO_TABLE_VIEW_ADAPTOR_OPERATOR_TEST));
+ VIEW_FROM_TREE_ADAPTOR_OPERATOR_TEST));
int count = 0;
while (operator.hasNext()) {
TsBlock tsBlock = operator.next();
diff --git
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TableType.java
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TableType.java
index 347b78fa2f6..2a4713a5b4d 100644
---
a/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TableType.java
+++
b/iotdb-core/node-commons/src/main/java/org/apache/iotdb/commons/schema/table/TableType.java
@@ -21,7 +21,7 @@ package org.apache.iotdb.commons.schema.table;
public enum TableType {
BASE_TABLE("BASE TABLE"),
- TREE_TO_TABLE_VIEW("TREE_TO_TABLE VIEW"),
+ VIEW_FROM_TREE("VIEW FROM TREE"),
VIEW("VIEW"),
SYSTEM_VIEW("SYSTEM VIEW"),
;
diff --git
a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
index 2aa783920f6..fe87803a1c3 100644
---
a/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
+++
b/iotdb-core/relational-grammar/src/main/antlr4/org/apache/iotdb/db/relational/grammar/sql/RelationalSql.g4
@@ -59,7 +59,7 @@ statement
| showCreateTableStatement
// Table View Statement
- | createTableViewStatement
+ | createViewStatement
| alterViewStatement
| dropViewStatement
| showCreateViewStatement
@@ -247,13 +247,13 @@ showCreateTableStatement
;
// ------------------------------------------- Table View Statement
---------------------------------------------------------
-createTableViewStatement
- : CREATE (OR REPLACE)? TABLE VIEW qualifiedName
+createViewStatement
+ : CREATE (OR REPLACE)? VIEW qualifiedName
'(' (viewColumnDefinition (',' viewColumnDefinition)*)? ')'
- AS prefixPath
comment?
- (WITH properties)?
(RESTRICT)?
+ (WITH properties)?
+ AS prefixPath
;
viewColumnDefinition