Skip to content

Commit 8ec5aac

Browse files
authored
Ignore device alignment in timeSeries auto-creation (apache#16516)
1 parent 5c39de0 commit 8ec5aac

File tree

4 files changed

+12
-70
lines changed

4 files changed

+12
-70
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBCreateTimeseriesIT.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,4 +300,16 @@ public void testIllegalInput() {
300300
fail();
301301
}
302302
}
303+
304+
@Test
305+
public void testDifferentDeviceAlignment() {
306+
try (Connection connection = EnvFactory.getEnv().getConnection();
307+
Statement statement = connection.createStatement()) {
308+
statement.execute("create timeseries root.sg2.d.s1 with datatype=INT64");
309+
// Should ignore the alignment difference
310+
statement.execute("create aligned timeseries root.sg2.d (s2 int64, s3 int64)");
311+
} catch (SQLException ignored) {
312+
fail();
313+
}
314+
}
303315
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/schema/NormalSchemaFetcher.java

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@
2626
import org.apache.iotdb.commons.pipe.config.constant.SystemConstant;
2727
import org.apache.iotdb.db.conf.IoTDBConfig;
2828
import org.apache.iotdb.db.conf.IoTDBDescriptor;
29-
import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
30-
import org.apache.iotdb.db.exception.sql.SemanticException;
3129
import org.apache.iotdb.db.queryengine.common.MPPQueryContext;
3230
import org.apache.iotdb.db.queryengine.common.schematree.ClusterSchemaTree;
3331
import org.apache.iotdb.db.queryengine.plan.relational.metadata.fetcher.cache.TreeDeviceSchemaCacheManager;
@@ -182,8 +180,6 @@ List<Integer> processNormalTimeSeries(
182180
// Check the isAligned value. If the input value is different from the actual value of the
183181
// existing device, throw exception.
184182
PartialPath devicePath = schemaComputationWithAutoCreation.getDevicePath();
185-
validateIsAlignedValueIfAutoCreate(
186-
schemaComputationWithAutoCreation.isAligned(), isAlignedPutIn, devicePath);
187183
ClusterSchemaTree schemaTree = new ClusterSchemaTree();
188184
autoCreateSchemaExecutor.autoCreateTimeSeries(
189185
schemaTree,
@@ -351,13 +347,6 @@ void processNormalTimeSeries(
351347
schemaComputationWithAutoCreationList.stream()
352348
.map(ISchemaComputationWithAutoCreation::getDevicePath)
353349
.collect(Collectors.toList());
354-
List<Boolean> isAlignedRealList =
355-
schemaComputationWithAutoCreationList.stream()
356-
.map(ISchemaComputationWithAutoCreation::isAligned)
357-
.collect(Collectors.toList());
358-
// Check the isAligned value. If the input value is different from the actual value of the
359-
// existing device, throw exception.
360-
validateIsAlignedValueIfAutoCreate(isAlignedRealList, isAlignedPutInList, devicePathList);
361350

362351
ClusterSchemaTree schemaTree = new ClusterSchemaTree();
363352
autoCreateSchemaExecutor.autoCreateTimeSeries(
@@ -414,29 +403,4 @@ void processNormalTimeSeries(
414403
}
415404
}
416405
}
417-
418-
private void validateIsAlignedValueIfAutoCreate(
419-
List<Boolean> realValueList, List<Boolean> putInValueList, List<PartialPath> devicePathList) {
420-
int checkLen =
421-
Math.min(Math.min(realValueList.size(), putInValueList.size()), devicePathList.size());
422-
for (int i = 0; i < checkLen; i++) {
423-
validateIsAlignedValueIfAutoCreate(
424-
realValueList.get(i), putInValueList.get(i), devicePathList.get(i));
425-
}
426-
}
427-
428-
private void validateIsAlignedValueIfAutoCreate(
429-
boolean realValue, boolean putInValue, PartialPath devicePath) {
430-
if (realValue != putInValue) {
431-
String msg;
432-
if (realValue) {
433-
msg =
434-
"Timeseries under this device is aligned, please use createTimeseries or change device.";
435-
} else {
436-
msg =
437-
"Timeseries under this device is not aligned, please use createTimeseries or change device.";
438-
}
439-
throw new SemanticException(new AlignedTimeseriesException(msg, devicePath.getFullPath()));
440-
}
441-
}
442406
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/mem/MTreeBelowSGMemoryImpl.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression;
3535
import org.apache.iotdb.db.conf.IoTDBDescriptor;
3636
import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
37-
import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
3837
import org.apache.iotdb.db.exception.metadata.MNodeTypeMismatchException;
3938
import org.apache.iotdb.db.exception.metadata.MeasurementAlreadyExistException;
4039
import org.apache.iotdb.db.exception.metadata.MeasurementInBlackListException;
@@ -280,14 +279,6 @@ public IMeasurementMNode<IMemMNode> createTimeSeries(
280279
}
281280
}
282281

283-
if (device.isDevice()
284-
&& device.getAsDeviceMNode().isAlignedNullable() != null
285-
&& device.getAsDeviceMNode().isAligned()) {
286-
throw new AlignedTimeseriesException(
287-
"time series under this device is aligned, please use createAlignedTimeseries or change device.",
288-
device.getFullPath());
289-
}
290-
291282
final IDeviceMNode<IMemMNode> entityMNode;
292283
if (device.isDevice()) {
293284
entityMNode = device.getAsDeviceMNode();
@@ -374,14 +365,6 @@ public List<IMeasurementMNode<IMemMNode>> createAlignedTimeSeries(
374365
}
375366
}
376367

377-
if (device.isDevice()
378-
&& device.getAsDeviceMNode().isAlignedNullable() != null
379-
&& !device.getAsDeviceMNode().isAligned()) {
380-
throw new AlignedTimeseriesException(
381-
"Time series under this device is not aligned, please use createTimeSeries or change device.",
382-
devicePath.getFullPath());
383-
}
384-
385368
final IDeviceMNode<IMemMNode> entityMNode;
386369
if (device.isDevice()) {
387370
entityMNode = device.getAsDeviceMNode();

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/schemaengine/schemaregion/mtree/impl/pbtree/MTreeBelowSGCachedImpl.java

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.apache.iotdb.commons.schema.view.LogicalViewSchema;
3434
import org.apache.iotdb.commons.schema.view.viewExpression.ViewExpression;
3535
import org.apache.iotdb.db.exception.metadata.AliasAlreadyExistException;
36-
import org.apache.iotdb.db.exception.metadata.AlignedTimeseriesException;
3736
import org.apache.iotdb.db.exception.metadata.MNodeTypeMismatchException;
3837
import org.apache.iotdb.db.exception.metadata.MeasurementAlreadyExistException;
3938
import org.apache.iotdb.db.exception.metadata.MeasurementInBlackListException;
@@ -334,14 +333,6 @@ public IMeasurementMNode<ICachedMNode> createTimeSeriesWithPinnedReturn(
334333
}
335334
}
336335

337-
if (device.isDevice()
338-
&& device.getAsDeviceMNode().isAlignedNullable() != null
339-
&& device.getAsDeviceMNode().isAligned()) {
340-
throw new AlignedTimeseriesException(
341-
"Time series under this device is aligned, please use createAlignedTimeSeries or change device.",
342-
device.getFullPath());
343-
}
344-
345336
final IDeviceMNode<ICachedMNode> entityMNode;
346337
if (device.isDevice()) {
347338
entityMNode = device.getAsDeviceMNode();
@@ -440,14 +431,6 @@ public List<IMeasurementMNode<ICachedMNode>> createAlignedTimeSeries(
440431
}
441432
}
442433

443-
if (device.isDevice()
444-
&& device.getAsDeviceMNode().isAlignedNullable() != null
445-
&& !device.getAsDeviceMNode().isAligned()) {
446-
throw new AlignedTimeseriesException(
447-
"TimeSeries under this device is not aligned, please use createTimeSeries or change device.",
448-
devicePath.getFullPath());
449-
}
450-
451434
final IDeviceMNode<ICachedMNode> entityMNode;
452435
if (device.isDevice()) {
453436
entityMNode = device.getAsDeviceMNode();

0 commit comments

Comments
 (0)