Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ public class IoTDBComplexQueryTableViewIT {
"create aligned timeseries root.test.employees.D002(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
"create aligned timeseries root.test.employees.D002(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
"create aligned timeseries root.test.employees.D003(name TEXT,Gender TEXT,Status BOOLEAN,employee_id INT32,salary DOUBLE,date_of_birth DATE,Contac_info string)",
"create aligned timeseries root.test.departments.D001(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D002(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D003(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D004(department_id STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D001(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D002(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D003(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"create aligned timeseries root.test.departments.D004(`1department_id` STRING,dep_name TEXT,dep_phone TEXT,dep_status BOOLEAN,dep_member INT32,employee_id INT32)",
"insert into root.test.employees.D001(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(1, 'Mary','Female', false, 1223, 5500.22, '1988-10-12', '133-1212-1234')",
"insert into root.test.employees.D001(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(2, 'John', 'Male', true, 40012, 8822, '1985-06-15', '130-1002-1334')",
"insert into root.test.employees.D002(time, name, gender, status, employee_id, salary, date_of_birth, contac_info) aligned values(3, 'Nancy', 'Female', true, 30112, 10002, '1983-08-15', '135-1302-1354')",
Expand All @@ -69,8 +69,8 @@ public class IoTDBComplexQueryTableViewIT {
new String[] {
"CREATE DATABASE " + DATABASE_NAME,
"USE " + DATABASE_NAME,
"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.**",
"create view employees(\"`1department_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(\"`1department_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
Expand All @@ -88,11 +88,11 @@ public static void tearDown() throws Exception {
@Test
public void queryTest1() {
// Look for the non-intersecting departments in the two tables
String[] expectedHeader = new String[] {"department_id", "dep_name"};
String[] expectedHeader = new String[] {"`1department_id`", "dep_name"};
String[] retArray = new String[] {"D004,人事部,"};
tableResultSetEqualTest(
"select department_id, dep_name from departments where not exists("
+ "select 1 from employees where employees.department_id = departments.department_id)",
"select \"`1department_id`\", dep_name from departments where not exists("
+ "select 1 from employees where employees.\"`1department_id`\" = departments.\"`1department_id`\")",
expectedHeader,
retArray,
DATABASE_NAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -761,10 +761,10 @@ public void testTreeViewTable() throws Exception {
try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("create database root.another");
statement.execute("create database root.`重庆`.b");
statement.execute("create timeSeries root.`重庆`.b.c.S1 int32");
statement.execute("create timeSeries root.`重庆`.b.c.s2 string");
statement.execute("create timeSeries root.`重庆`.b.S1 int32");
statement.execute("create database root.`重庆`.`1`.b");
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.S1 int32");
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.s2 string");
statement.execute("create timeSeries root.`重庆`.`1`.b.S1 int32");
} catch (SQLException e) {
fail(e.getMessage());
}
Expand All @@ -783,13 +783,13 @@ public void testTreeViewTable() throws Exception {
"701: Cannot specify view pattern to match more than one tree database.",
e.getMessage());
}
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
statement.execute("drop view tree_table");
}

try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("create timeSeries root.`重庆`.b.d.s1 int32");
statement.execute("create timeSeries root.`重庆`.`1`.b.`1`.s1 int32");
} catch (SQLException e) {
fail(e.getMessage());
}
Expand All @@ -800,7 +800,7 @@ public void testTreeViewTable() throws Exception {
statement.execute("use tree_view_db");

try {
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
final Set<String> result =
Expand All @@ -814,13 +814,13 @@ public void testTreeViewTable() throws Exception {

try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("drop timeSeries root.`重庆`.b.d.s1");
statement.execute("drop timeSeries root.`重庆`.`1`.b.`1`.s1");
statement.execute("create device template t1 (S1 boolean, s9 int32)");
statement.execute("set schema template t1 to root.`重庆`.b.d");
statement.execute("create timeSeries root.`重庆`.b.c.f.g.h.S1 int32");
statement.execute("set schema template t1 to root.`重庆`.`1`.b.`1`");
statement.execute("create timeSeries root.`重庆`.`1`.b.`2`.f.g.h.S1 int32");

// Put schema cache
statement.execute("select S1, s2 from root.`重庆`.b.c");
statement.execute("select S1, s2 from root.`重庆`.`1`.b.`2`");
} catch (SQLException e) {
fail(e.getMessage());
}
Expand All @@ -831,7 +831,7 @@ public void testTreeViewTable() throws Exception {
statement.execute("use tree_view_db");

try {
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".**");
statement.execute("create view tree_table (tag1 tag, tag2 tag) as root.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -841,7 +841,7 @@ public void testTreeViewTable() throws Exception {

try {
statement.execute(
"create view tree_table (tag1 tag, tag2 tag, S1 field) as root.\"重庆\".**");
"create view tree_table (tag1 tag, tag2 tag, S1 field) as root.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -852,7 +852,7 @@ public void testTreeViewTable() throws Exception {

try (final Connection connection = EnvFactory.getEnv().getConnection();
final Statement statement = connection.createStatement()) {
statement.execute("create timeSeries root.`重庆`.b.e.s1 int32");
statement.execute("create timeSeries root.`重庆`.`1`.b.e.s1 int32");
} catch (SQLException e) {
fail(e.getMessage());
}
Expand All @@ -873,7 +873,7 @@ public void testTreeViewTable() throws Exception {
// Temporary
try {
statement.execute(
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 boolean from S1) as root.\"重庆\".**");
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 boolean from S1) as root.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -882,14 +882,14 @@ public void testTreeViewTable() throws Exception {

try {
statement.execute(
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2, s8 field) as root.\"重庆\".**");
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2, s8 field) as root.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals("528: Measurements not found for s8, cannot auto detect", e.getMessage());
}

statement.execute(
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2) as root.\"重庆\".**");
"create or replace view tree_table (tag1 tag, tag2 tag, S1 int32 field, s3 from s2) as root.\"重庆\".\"1\".**");

// Cannot be written
try {
Expand Down Expand Up @@ -937,11 +937,15 @@ public void testTreeViewTable() throws Exception {
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from view_table where tag1 = 'b'"),
"tag1,tag2,",
new HashSet<>(Arrays.asList("b,c,", "b,null,", "b,e,")));
new HashSet<>(Arrays.asList("b,`2`,", "b,null,", "b,e,")));
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from view_table where tag1 = 'b' and tag2 is null"),
"tag1,tag2,",
Collections.singleton("b,null,"));
TestUtils.assertResultSetEqual(
statement.executeQuery("show devices from view_table where tag1 = 'b' and tag2 = '`2`'"),
"tag1,tag2,",
Collections.singleton("b,`2`,"));
TestUtils.assertResultSetEqual(
statement.executeQuery("count devices from view_table"),
"count(devices),",
Expand All @@ -953,7 +957,7 @@ public void testTreeViewTable() throws Exception {
final Statement statement = connection.createStatement()) {
// Test create & replace + restrict
statement.execute(
"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.`重庆`.**");
"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.`重庆`.`1`.**");
fail();
} catch (final SQLException e) {
assertTrue(
Expand All @@ -974,7 +978,7 @@ public void testTreeViewTable() throws Exception {
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
"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.\"重庆\".**");
"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.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -995,7 +999,7 @@ public void testTreeViewTable() throws Exception {
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
"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.\"重庆\".**");
"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.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -1015,7 +1019,7 @@ public void testTreeViewTable() throws Exception {
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
"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.\"重庆\".**");
"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.\"重庆\".\"1\".**");
fail();
} catch (final SQLException e) {
assertEquals(
Expand All @@ -1035,7 +1039,7 @@ public void testTreeViewTable() throws Exception {
.getConnection("testUser", "testUser123456", BaseEnv.TABLE_SQL_DIALECT);
final Statement statement = connection.createStatement()) {
statement.execute(
"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.\"重庆\".**");
"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.\"重庆\".\"1\".**");
} catch (final SQLException e) {
fail();
}
Expand All @@ -1054,14 +1058,14 @@ public void testTreeViewTable() throws Exception {
statement.executeQuery("show create view view_table"),
"View,Create View,",
Collections.singleton(
"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.\"重庆\".**,"));
"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.\"重庆\".\"1\".**,"));

// Can also use "show create table"
TestUtils.assertResultSetEqual(
statement.executeQuery("show create table view_table"),
"View,Create View,",
Collections.singleton(
"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.\"重庆\".**,"));
"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.\"重庆\".\"1\".**,"));

statement.execute("create table a ()");
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static DatasetHeader getShowDevicesHeader() {
}

public static DatasetHeader getShowDevicesWithSgHeader() {
return new DatasetHeader(ColumnHeaderConstant.showDevicesWithSgColumnHeaders, true);
return new DatasetHeader(ColumnHeaderConstant.showDevicesWithDbColumnHeaders, true);
}

public static DatasetHeader getShowDatabaseHeader(final boolean isDetailed) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public ISchemaReader<IDeviceSchemaInfo> getSchemaReader(ISchemaRegion schemaRegi
@Override
public List<ColumnHeader> getInfoQueryColumnHeaders() {
return hasSgCol
? ColumnHeaderConstant.showDevicesWithSgColumnHeaders
? ColumnHeaderConstant.showDevicesWithDbColumnHeaders
: ColumnHeaderConstant.showDevicesColumnHeaders;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ public static String getShowCreateViewSQL(final TsTable table) {
final String[] pathNodes = TreeViewSchema.getPrefixPattern(table).getNodes();
builder.append(pathNodes[0]);
for (int i = 1; i < pathNodes.length - 1; ++i) {
builder.append(".\"").append(pathNodes[i]).append("\"");
builder.append(".\"").append(pathNodes[i].replace("`", "")).append("\"");
}
builder.append(".").append(pathNodes[pathNodes.length - 1]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,7 @@ public Operator visitDevicesSchemaScan(
node.isPrefixPath(),
node.getLimit(),
node.getOffset(),
node.isHasSgCol(),
node.isHasDbCol(),
node.getSchemaFilter(),
node.getScope()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

public class DevicesSchemaScanNode extends SchemaQueryScanNode {

private final boolean hasSgCol;
private final boolean hasDbCol;
private final SchemaFilter schemaFilter;

public DevicesSchemaScanNode(
Expand All @@ -49,16 +49,16 @@ public DevicesSchemaScanNode(
long limit,
long offset,
boolean isPrefixPath,
boolean hasSgCol,
boolean hasDbCol,
SchemaFilter schemaFilter,
PathPatternTree scope) {
super(id, path, limit, offset, isPrefixPath, scope);
this.hasSgCol = hasSgCol;
this.hasDbCol = hasDbCol;
this.schemaFilter = schemaFilter;
}

public boolean isHasSgCol() {
return hasSgCol;
public boolean isHasDbCol() {
return hasDbCol;
}

public SchemaFilter getSchemaFilter() {
Expand All @@ -73,13 +73,13 @@ public PlanNodeType getType() {
@Override
public PlanNode clone() {
return new DevicesSchemaScanNode(
getPlanNodeId(), path, limit, offset, isPrefixPath, hasSgCol, schemaFilter, scope);
getPlanNodeId(), path, limit, offset, isPrefixPath, hasDbCol, schemaFilter, scope);
}

@Override
public List<String> getOutputColumnNames() {
if (hasSgCol) {
return ColumnHeaderConstant.showDevicesWithSgColumnHeaders.stream()
if (hasDbCol) {
return ColumnHeaderConstant.showDevicesWithDbColumnHeaders.stream()
.map(ColumnHeader::getColumnName)
.collect(Collectors.toList());
}
Expand All @@ -96,7 +96,7 @@ protected void serializeAttributes(ByteBuffer byteBuffer) {
ReadWriteIOUtils.write(limit, byteBuffer);
ReadWriteIOUtils.write(offset, byteBuffer);
ReadWriteIOUtils.write(isPrefixPath, byteBuffer);
ReadWriteIOUtils.write(hasSgCol, byteBuffer);
ReadWriteIOUtils.write(hasDbCol, byteBuffer);
SchemaFilter.serialize(schemaFilter, byteBuffer);
}

Expand All @@ -108,7 +108,7 @@ protected void serializeAttributes(DataOutputStream stream) throws IOException {
ReadWriteIOUtils.write(limit, stream);
ReadWriteIOUtils.write(offset, stream);
ReadWriteIOUtils.write(isPrefixPath, stream);
ReadWriteIOUtils.write(hasSgCol, stream);
ReadWriteIOUtils.write(hasDbCol, stream);
SchemaFilter.serialize(schemaFilter, stream);
}

Expand Down Expand Up @@ -143,12 +143,12 @@ public boolean equals(Object o) {
return false;
}
DevicesSchemaScanNode that = (DevicesSchemaScanNode) o;
return hasSgCol == that.hasSgCol && Objects.equals(schemaFilter, that.schemaFilter);
return hasDbCol == that.hasDbCol && Objects.equals(schemaFilter, that.schemaFilter);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), hasSgCol, schemaFilter);
return Objects.hash(super.hashCode(), hasDbCol, schemaFilter);
}

@Override
Expand Down
Loading
Loading