Skip to content

Commit 9c9eae1

Browse files
authored
Banned the duplicated properties in table
1 parent 1768bd9 commit 9c9eae1

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,14 @@ public void testManageTable() {
108108
assertFalse(resultSet.next());
109109
}
110110

111+
try {
112+
statement.execute(
113+
"create table test1.table1(region_id STRING TAG, plant_id STRING TAG, device_id STRING TAG, model STRING ATTRIBUTE, temperature FLOAT FIELD, humidity DOUBLE FIELD) with (ttl=100, ttl=200, ttl=300)");
114+
fail();
115+
} catch (final SQLException e) {
116+
assertEquals("701: Duplicated property: ttl", e.getMessage());
117+
}
118+
111119
// or use full qualified table name
112120
// test "TTL=INF"
113121
// "FIELD" can be omitted when type is specified

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/TableConfigTaskVisitor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,8 +880,12 @@ public Pair<String, String> splitQualifiedName(final QualifiedName name) {
880880
private Map<String, String> convertPropertiesToMap(
881881
final List<Property> propertyList, final boolean serializeDefault) {
882882
final Map<String, String> map = new HashMap<>();
883+
final Set<String> deduplicate = new HashSet<>();
883884
for (final Property property : propertyList) {
884885
final String key = property.getName().getValue().toLowerCase(Locale.ENGLISH);
886+
if (!deduplicate.add(key)) {
887+
throw new SemanticException("Duplicated property: " + key);
888+
}
885889
if (TABLE_ALLOWED_PROPERTIES.contains(key)) {
886890
if (!property.isSetToDefault()) {
887891
final Expression value = property.getNonDefaultValue();

0 commit comments

Comments
 (0)