Skip to content

Commit d90397d

Browse files
authored
[AINode] Call inference should only contain 1 input column (#17087)
1 parent 465170b commit d90397d

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

integration-test/src/test/java/org/apache/iotdb/ainode/it/AINodeCallInferenceIT.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.BUILTIN_MODEL_MAP;
4242
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.checkHeader;
43+
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.errorTest;
4344
import static org.apache.iotdb.ainode.utils.AINodeTestUtils.prepareDataInTree;
4445

4546
@RunWith(IoTDBTestRunner.class)
@@ -72,6 +73,7 @@ public void callInferenceTest() throws SQLException {
7273
Statement statement = connection.createStatement()) {
7374
callInferenceTest(statement, modelInfo);
7475
callInferenceByDefaultTest(statement, modelInfo);
76+
callInferenceErrorTest(statement, modelInfo);
7577
}
7678
}
7779
}
@@ -118,4 +120,16 @@ public static void callInferenceByDefaultTest(
118120
}
119121
}
120122
}
123+
124+
public static void callInferenceErrorTest(
125+
Statement statement, AINodeTestUtils.FakeModelInfo modelInfo) {
126+
String multiVariateSQL =
127+
String.format(
128+
"CALL INFERENCE(%s, \"SELECT s0,s1 FROM root.AI LIMIT 128\", generateTime=true, outputLength=10)",
129+
modelInfo.getModelId());
130+
errorTest(
131+
statement,
132+
multiVariateSQL,
133+
"701: Call inference function should not contain more than one input column, found [2] input columns.");
134+
}
121135
}

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/execution/operator/process/ai/InferenceOperator.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import org.apache.iotdb.commons.client.exception.ClientManagerException;
2525
import org.apache.iotdb.db.exception.ainode.AINodeConnectionException;
2626
import org.apache.iotdb.db.exception.runtime.ModelInferenceProcessException;
27+
import org.apache.iotdb.db.exception.sql.SemanticException;
2728
import org.apache.iotdb.db.protocol.client.an.AINodeClient;
2829
import org.apache.iotdb.db.protocol.client.an.AINodeClientManager;
2930
import org.apache.iotdb.db.queryengine.execution.MemoryEstimationHelper;
@@ -225,6 +226,12 @@ private void appendTsBlockToBuilder(TsBlock inputTsBlock) {
225226
maxTimestamp = Math.max(maxTimestamp, timestamp);
226227
}
227228
timeColumnBuilder.writeLong(timestamp);
229+
if (inputTsBlock.getValueColumnCount() > 1) {
230+
throw new SemanticException(
231+
String.format(
232+
"Call inference function should not contain more than one input column, found [%d] input columns.",
233+
inputTsBlock.getValueColumnCount()));
234+
}
228235
for (int columnIndex = 0; columnIndex < inputTsBlock.getValueColumnCount(); columnIndex++) {
229236
columnBuilders[columnIndexes[columnIndex]].write(inputTsBlock.getColumn(columnIndex), i);
230237
}

0 commit comments

Comments
 (0)