Skip to content

Commit a602b5b

Browse files
committed
Merge branch 'DisableObjectType' of https://github.com/apache/iotdb into DisableObjectType
2 parents b9d8241 + 7375147 commit a602b5b

File tree

19 files changed

+10
-2018
lines changed

19 files changed

+10
-2018
lines changed

integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/IoTDBSimpleQueryTableIT.java

Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -658,19 +658,18 @@ public void testNewDataType() {
658658
statement.execute("USE " + DATABASE_NAME);
659659
statement.execute(
660660
"CREATE TABLE table1(device STRING TAG, "
661-
+ "s4 DATE FIELD, s5 TIMESTAMP FIELD, s6 BLOB FIELD, s7 STRING FIELD, s8 OBJECT FIELD)");
661+
+ "s4 DATE FIELD, s5 TIMESTAMP FIELD, s6 BLOB FIELD, s7 STRING FIELD)");
662662

663663
for (int i = 1; i <= 10; i++) {
664664
statement.execute(
665665
String.format(
666-
"insert into table1(time, device, s4, s5, s6, s7, s8) "
667-
+ "values(%d, 'd1', '%s', %d, %s, '%s', %s)",
666+
"insert into table1(time, device, s4, s5, s6, s7) "
667+
+ "values(%d, 'd1', '%s', %d, %s, '%s')",
668668
i,
669669
LocalDate.of(2024, 5, i % 31 + 1),
670670
i,
671671
"X'cafebabe'",
672-
i,
673-
"to_object(true, 0, X'cafebabe')"));
672+
i));
674673
}
675674

676675
try (ResultSet resultSet = statement.executeQuery("select * from table1")) {
@@ -687,8 +686,6 @@ public void testNewDataType() {
687686
columnType.put(i, TSDataType.BLOB);
688687
} else if (metaData.getColumnLabel(i).equals("s7")) {
689688
columnType.put(i, TSDataType.TEXT);
690-
} else if (metaData.getColumnLabel(i).equals("s8")) {
691-
columnType.put(i, TSDataType.OBJECT);
692689
}
693690
}
694691
byte[] byteArray = new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
@@ -698,58 +695,12 @@ public void testNewDataType() {
698695
long timestamp = resultSet.getLong(4);
699696
byte[] blob = resultSet.getBytes(5);
700697
String text = resultSet.getString(6);
701-
String objectSizeString = resultSet.getString(7);
702698
assertEquals(2024 - 1900, date.getYear());
703699
assertEquals(5 - 1, date.getMonth());
704700
assertEquals(time % 31 + 1, date.getDate());
705701
assertEquals(time, timestamp);
706702
assertArrayEquals(byteArray, blob);
707703
assertEquals(String.valueOf(time), text);
708-
assertEquals("(Object) 4 B", objectSizeString);
709-
}
710-
}
711-
try (ResultSet resultSet = statement.executeQuery("select read_object(s8) from table1")) {
712-
final ResultSetMetaData metaData = resultSet.getMetaData();
713-
final int columnCount = metaData.getColumnCount();
714-
assertEquals(1, columnCount);
715-
byte[] byteArray = new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
716-
while (resultSet.next()) {
717-
byte[] blob = resultSet.getBytes(1);
718-
assertArrayEquals(byteArray, blob);
719-
}
720-
}
721-
722-
} catch (SQLException e) {
723-
fail();
724-
}
725-
}
726-
727-
@Test
728-
public void testObjectDataType() {
729-
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
730-
Statement statement = connection.createStatement()) {
731-
statement.execute("CREATE DATABASE test");
732-
statement.execute("USE " + DATABASE_NAME);
733-
statement.execute("CREATE TABLE table1(device STRING TAG, s8 OBJECT FIELD)");
734-
statement.execute(
735-
"insert into table1(time, device, s8) values(1, 'd1', to_object(false, 0, X'cafe'))");
736-
statement.execute(
737-
"insert into table1(time, device, s8) values(1, 'd1', to_object(true, 2, X'babe'))");
738-
739-
try (ResultSet resultSet = statement.executeQuery("select * from table1")) {
740-
while (resultSet.next()) {
741-
String objectSizeString = resultSet.getString(3);
742-
assertEquals("(Object) 4 B", objectSizeString);
743-
}
744-
}
745-
try (ResultSet resultSet = statement.executeQuery("select read_object(s8) from table1")) {
746-
final ResultSetMetaData metaData = resultSet.getMetaData();
747-
final int columnCount = metaData.getColumnCount();
748-
assertEquals(1, columnCount);
749-
byte[] byteArray = new byte[] {(byte) 0xCA, (byte) 0xFE, (byte) 0xBA, (byte) 0xBE};
750-
while (resultSet.next()) {
751-
byte[] blob = resultSet.getBytes(1);
752-
assertArrayEquals(byteArray, blob);
753704
}
754705
}
755706

integration-test/src/test/java/org/apache/iotdb/relational/it/schema/IoTDBTableIT.java

Lines changed: 0 additions & 141 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package org.apache.iotdb.relational.it.schema;
2121

22-
import org.apache.iotdb.commons.utils.WindowsOSUtils;
2322
import org.apache.iotdb.db.it.utils.TestUtils;
2423
import org.apache.iotdb.isession.ITableSession;
2524
import org.apache.iotdb.it.env.EnvFactory;
@@ -32,7 +31,6 @@
3231

3332
import org.apache.tsfile.enums.ColumnCategory;
3433
import org.apache.tsfile.enums.TSDataType;
35-
import org.apache.tsfile.external.commons.lang3.SystemUtils;
3634
import org.apache.tsfile.write.record.Tablet;
3735
import org.apache.tsfile.write.schema.IMeasurementSchema;
3836
import org.apache.tsfile.write.schema.MeasurementSchema;
@@ -43,9 +41,6 @@
4341
import org.junit.experimental.categories.Category;
4442
import org.junit.runner.RunWith;
4543

46-
import java.io.File;
47-
import java.nio.file.Files;
48-
import java.nio.file.Paths;
4944
import java.sql.Connection;
5045
import java.sql.ResultSet;
5146
import java.sql.ResultSetMetaData;
@@ -783,142 +778,6 @@ public void testConcurrentAutoCreateAndDropColumn() throws Exception {
783778
}
784779
}
785780

786-
@Test
787-
public void testTableObjectCheck() throws Exception {
788-
final Set<String> illegal = new HashSet<>(Arrays.asList("./", ".", "..", ".\\", "../hack"));
789-
if (SystemUtils.IS_OS_WINDOWS) {
790-
illegal.add("C.");
791-
illegal.add("a:b<|");
792-
illegal.add("COM1");
793-
}
794-
for (final String single : illegal) {
795-
testObject4SingleIllegalPath(single);
796-
}
797-
}
798-
799-
private void testObject4SingleIllegalPath(final String illegal) throws Exception {
800-
try (final Connection connection =
801-
EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
802-
final Statement statement = connection.createStatement();
803-
final ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
804-
statement.execute("create database if not exists db2");
805-
statement.execute("use db2");
806-
807-
// Test auto-create table
808-
final String testObject =
809-
System.getProperty("user.dir")
810-
+ File.separator
811-
+ "target"
812-
+ File.separator
813-
+ "test-classes"
814-
+ File.separator
815-
+ "object-example.pt";
816-
817-
final List<IMeasurementSchema> schemaList = new ArrayList<>();
818-
schemaList.add(new MeasurementSchema("a", TSDataType.STRING));
819-
schemaList.add(new MeasurementSchema("b", TSDataType.STRING));
820-
schemaList.add(new MeasurementSchema("c", TSDataType.INT32));
821-
schemaList.add(new MeasurementSchema(illegal, TSDataType.OBJECT));
822-
final List<ColumnCategory> columnTypes =
823-
Arrays.asList(
824-
ColumnCategory.TAG,
825-
ColumnCategory.ATTRIBUTE,
826-
ColumnCategory.FIELD,
827-
ColumnCategory.FIELD);
828-
final Tablet tablet =
829-
new Tablet(
830-
illegal,
831-
IMeasurementSchema.getMeasurementNameList(schemaList),
832-
IMeasurementSchema.getDataTypeList(schemaList),
833-
columnTypes,
834-
1);
835-
tablet.addTimestamp(0, System.currentTimeMillis());
836-
tablet.addValue(schemaList.get(0).getMeasurementName(), 0, "d1");
837-
tablet.addValue(schemaList.get(1).getMeasurementName(), 0, "a1");
838-
tablet.addValue(schemaList.get(2).getMeasurementName(), 0, 0);
839-
tablet.addValue(0, 3, true, 0, Files.readAllBytes(Paths.get(testObject)));
840-
841-
final String expectedTableError =
842-
String.format(
843-
"701: When there are object fields, the tableName %s shall not be '.', '..' or contain './', '.\\'."
844-
+ (SystemUtils.IS_OS_WINDOWS ? " " + WindowsOSUtils.OS_SEGMENT_ERROR : ""),
845-
illegal.toLowerCase());
846-
final String expectedObjectError =
847-
String.format(
848-
"701: When there are object fields, the objectName %s shall not be '.', '..' or contain './', '.\\'."
849-
+ (SystemUtils.IS_OS_WINDOWS ? " " + WindowsOSUtils.OS_SEGMENT_ERROR : ""),
850-
illegal.toLowerCase());
851-
852-
try {
853-
session.executeNonQueryStatement("use db2");
854-
session.insert(tablet);
855-
} catch (final Exception e) {
856-
Assert.assertEquals(expectedTableError, e.getMessage());
857-
}
858-
859-
statement.execute(String.format("create table \"%s\" ()", illegal));
860-
861-
try {
862-
statement.execute(String.format("alter table \"%s\" add column a object", illegal));
863-
fail();
864-
} catch (final SQLException e) {
865-
Assert.assertEquals(expectedTableError, e.getMessage());
866-
}
867-
868-
// Test auto-create column
869-
try {
870-
session.executeNonQueryStatement("use db2");
871-
session.insert(tablet);
872-
} catch (final Exception e) {
873-
Assert.assertEquals(expectedTableError, e.getMessage());
874-
}
875-
876-
try {
877-
statement.execute(String.format("create table test (\"%s\" object)", illegal));
878-
fail();
879-
} catch (final SQLException e) {
880-
Assert.assertEquals(expectedObjectError, e.getMessage());
881-
}
882-
883-
statement.execute("create table test (a tag, b attribute, c int32, d object)");
884-
885-
// Cannot auto-extend illegal column
886-
tablet.setTableName("test");
887-
try {
888-
session.executeNonQueryStatement("use db2");
889-
session.insert(tablet);
890-
} catch (final Exception e) {
891-
Assert.assertEquals(expectedObjectError, e.getMessage());
892-
}
893-
894-
// It's OK if you don't write object
895-
statement.execute(String.format("insert into test (a, b, c) values ('%s', 1, 1)", illegal));
896-
try {
897-
statement.execute(
898-
String.format(
899-
"insert into test (a, b, c, d) values ('%s', 1, 1, to_object(true, 0, X'aa'))",
900-
illegal));
901-
fail();
902-
} catch (final SQLException e) {
903-
Assert.assertEquals(
904-
String.format(
905-
"507: When there are object fields, the deviceId [test, %s] shall not be '.', '..' or contain './', '.\\'."
906-
+ (SystemUtils.IS_OS_WINDOWS ? " " + WindowsOSUtils.OS_SEGMENT_ERROR : ""),
907-
illegal),
908-
e.getMessage());
909-
}
910-
911-
try {
912-
statement.execute(String.format("alter table test add column \"%s\" object", illegal));
913-
fail();
914-
} catch (final SQLException e) {
915-
Assert.assertEquals(expectedObjectError, e.getMessage());
916-
}
917-
918-
statement.execute("drop database db2");
919-
}
920-
}
921-
922781
@Test
923782
public void testTreeViewTable() throws Exception {
924783
try (final Connection connection = EnvFactory.getEnv().getConnection();

0 commit comments

Comments
 (0)