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 @@ -38,6 +38,7 @@
import java.util.HashSet;
import java.util.Set;

import static org.junit.Assert.assertThrows;
import static org.junit.Assert.fail;

/**
Expand Down Expand Up @@ -264,4 +265,34 @@ public void testQueryDataFromTimeSeriesWithoutData() {
}
Assert.assertEquals(0, cnt);
}

@Test
public void testIllegalInput() {
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
statement.execute("create timeseries root.sg2.d.s1 with datatype=INT64");
assertThrows(
"Unsupported datatype: UNKNOWN",
SQLException.class,
() -> statement.execute("create timeseries root.sg2.d.s1 with datatype=UNKNOWN"));
assertThrows(
"Unsupported datatype: VECTOR",
SQLException.class,
() -> statement.execute("create timeseries root.sg2.d.s1 with datatype=VECTOR"));
assertThrows(
"Unsupported datatype: YES",
SQLException.class,
() -> statement.execute("create timeseries root.sg2.d.s1 with datatype=YES"));
assertThrows(
"Unsupported datatype: UNKNOWN",
SQLException.class,
() -> statement.execute("create device template t1 (s1 UNKNOWN, s2 boolean)"));
assertThrows(
"Unsupported datatype: VECTOR",
SQLException.class,
() -> statement.execute("create device template t1 (s1 VECTOR, s2 boolean)"));
} catch (SQLException ignored) {
fail();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public class IoTDBSelectIntoIT {
SELECT_INTO_SQL_LIST.add("CREATE DATABASE root.sg_type");
for (int deviceId = 0; deviceId < 6; deviceId++) {
for (TSDataType dataType : TSDataType.values()) {
if (!dataType.equals(TSDataType.VECTOR)) {
if (!dataType.equals(TSDataType.VECTOR) && !dataType.equals(TSDataType.UNKNOWN)) {
SELECT_INTO_SQL_LIST.add(
String.format(
"CREATE TIMESERIES root.sg_type.d_%d.s_%s %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3554,6 +3554,9 @@ private TSDataType parseDataTypeAttribute(IoTDBSqlParser.AttributeClausesContext
String dataTypeString = ctx.dataType.getText().toUpperCase();
try {
dataType = TSDataType.valueOf(dataTypeString);
if (TSDataType.UNKNOWN.equals(dataType) || TSDataType.VECTOR.equals(dataType)) {
throw new SemanticException(String.format("Unsupported datatype: %s", dataTypeString));
}
} catch (Exception e) {
throw new SemanticException(String.format("Unsupported datatype: %s", dataTypeString));
}
Expand Down