Skip to content

Commit adc66fe

Browse files
committed
Merge branch 'master' into pattern-prune
2 parents 3c62d9a + bd813d8 commit adc66fe

File tree

67 files changed

+4823
-404
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+4823
-404
lines changed

integration-test/src/test/java/org/apache/iotdb/db/it/selectinto/IoTDBSelectIntoIT.java

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

2020
package org.apache.iotdb.db.it.selectinto;
2121

22+
import org.apache.iotdb.db.it.utils.TSDataTypeTestUtils;
2223
import org.apache.iotdb.it.env.EnvFactory;
2324
import org.apache.iotdb.it.framework.IoTDBTestRunner;
2425
import org.apache.iotdb.itbase.category.ClusterIT;
@@ -104,13 +105,11 @@ public class IoTDBSelectIntoIT {
104105
static {
105106
SELECT_INTO_SQL_LIST.add("CREATE DATABASE root.sg_type");
106107
for (int deviceId = 0; deviceId < 6; deviceId++) {
107-
for (TSDataType dataType : TSDataType.values()) {
108-
if (!dataType.equals(TSDataType.VECTOR) && !dataType.equals(TSDataType.UNKNOWN)) {
109-
SELECT_INTO_SQL_LIST.add(
110-
String.format(
111-
"CREATE TIMESERIES root.sg_type.d_%d.s_%s %s",
112-
deviceId, dataType.name().toLowerCase(), dataType));
113-
}
108+
for (TSDataType dataType : TSDataTypeTestUtils.getSupportedTypes()) {
109+
SELECT_INTO_SQL_LIST.add(
110+
String.format(
111+
"CREATE TIMESERIES root.sg_type.d_%d.s_%s %s",
112+
deviceId, dataType.name().toLowerCase(), dataType));
114113
}
115114
}
116115
for (int time = 0; time < 12; time++) {
Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.iotdb.db.it.utils;
20+
21+
import org.apache.tsfile.enums.TSDataType;
22+
23+
import java.util.Arrays;
24+
import java.util.HashSet;
25+
import java.util.List;
26+
import java.util.Set;
27+
import java.util.stream.Collectors;
28+
29+
/**
30+
* Utility class for TSDataType operations in integration tests. This class provides helper methods
31+
* to filter out unsupported data types that should not be used in tests.
32+
*
33+
* <p>Usage in IT tests:
34+
*
35+
* <pre>{@code
36+
* Set<TSDataType> dataTypes = TSDataTypeTestUtils.getSupportedTypes();
37+
* for (TSDataType from : dataTypes) {
38+
* for (TSDataType to : dataTypes) {
39+
* // test logic
40+
* }
41+
* }
42+
* }</pre>
43+
*
44+
* <p>To find this utility class quickly, search for: "TSDataTypeTestUtils" or "getSupportedTypes"
45+
*/
46+
public class TSDataTypeTestUtils {
47+
48+
private TSDataTypeTestUtils() {
49+
// utility class
50+
}
51+
52+
/**
53+
* Get the set of unsupported TSDataType values that should be filtered out in tests.
54+
*
55+
* <p>Currently includes: VECTOR, UNKNOWN, OBJECT
56+
*
57+
* @return Set of unsupported TSDataType values
58+
*/
59+
public static Set<TSDataType> getUnsupportedTypes() {
60+
Set<TSDataType> unsupported = new HashSet<>();
61+
unsupported.add(TSDataType.VECTOR);
62+
unsupported.add(TSDataType.UNKNOWN);
63+
unsupported.add(TSDataType.OBJECT);
64+
return unsupported;
65+
}
66+
67+
/**
68+
* Check if a TSDataType is supported for general use (not an internal type).
69+
*
70+
* @param dataType the TSDataType to check
71+
* @return true if the type is supported, false otherwise
72+
*/
73+
public static boolean isSupportedType(TSDataType dataType) {
74+
return !getUnsupportedTypes().contains(dataType);
75+
}
76+
77+
/**
78+
* Get all supported TSDataType values (filters out unsupported types).
79+
*
80+
* <p>This method filters out VECTOR, UNKNOWN, and any other types returned by {@link
81+
* #getUnsupportedTypes()}.
82+
*
83+
* @return Set of supported TSDataType values
84+
*/
85+
public static Set<TSDataType> getSupportedTypes() {
86+
Set<TSDataType> allTypes = new HashSet<>(Arrays.asList(TSDataType.values()));
87+
allTypes.removeAll(getUnsupportedTypes());
88+
return allTypes;
89+
}
90+
91+
/**
92+
* Get all supported TSDataType values as a List (filters out unsupported types).
93+
*
94+
* @return List of supported TSDataType values
95+
*/
96+
public static List<TSDataType> getSupportedTypesList() {
97+
return Arrays.stream(TSDataType.values())
98+
.filter(TSDataTypeTestUtils::isSupportedType)
99+
.collect(Collectors.toList());
100+
}
101+
102+
/**
103+
* Filter a collection of TSDataType values to only include supported types.
104+
*
105+
* @param dataTypes collection of TSDataType values to filter
106+
* @return Set containing only supported types
107+
*/
108+
public static Set<TSDataType> filterSupportedTypes(Set<TSDataType> dataTypes) {
109+
Set<TSDataType> result = new HashSet<>(dataTypes);
110+
result.removeAll(getUnsupportedTypes());
111+
return result;
112+
}
113+
}

integration-test/src/test/java/org/apache/iotdb/pipe/it/dual/tablemodel/TableModelUtils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public static void insertData(
108108
for (int i = startInclusive; i < endExclusive; ++i) {
109109
list.add(
110110
String.format(
111-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
111+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
112112
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
113113
}
114114
list.add("flush");
@@ -128,7 +128,7 @@ public static void insertData(
128128
for (int i = startInclusive; i < endExclusive; ++i) {
129129
list.add(
130130
String.format(
131-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
131+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
132132
tableName,
133133
deviceIndex,
134134
deviceIndex,
@@ -208,7 +208,7 @@ public static boolean insertDataNotThrowError(
208208
for (int i = start; i < end; ++i) {
209209
list.add(
210210
String.format(
211-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
211+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
212212
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
213213
}
214214
try {
@@ -230,7 +230,7 @@ public static boolean insertData(
230230
for (int i = start; i < end; ++i) {
231231
list.add(
232232
String.format(
233-
"insert into %s (s0, s3, s2, s1, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
233+
"insert into %s (s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, time) values ('t%s','t%s','t%s','t%s','%s', %s.0, %s, %s, %d, %d.0, '%s', '%s', %s)",
234234
tableName, i, i, i, i, i, i, i, i, i, i, getDateStr(i), i, i));
235235
}
236236
list.add("flush");

integration-test/src/test/java/org/apache/iotdb/relational/it/db/it/IoTDBInsertTableIT.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,7 @@ public void testPartialInsertTablet() {
294294
}
295295
Assert.assertEquals(200, cnt);
296296
}
297+
session.executeNonQueryStatement("SET CONFIGURATION enable_auto_create_schema='true'");
297298
} catch (Exception e) {
298299
e.printStackTrace();
299300
fail(e.getMessage());
@@ -505,6 +506,7 @@ public void testInsertMultiRowWithMisMatchDataType() throws SQLException {
505506
public void testInsertMultiRowWithNull() throws SQLException {
506507
try (Connection connection = EnvFactory.getEnv().getConnection(BaseEnv.TABLE_SQL_DIALECT);
507508
Statement st1 = connection.createStatement()) {
509+
st1.execute("SET CONFIGURATION enable_auto_create_schema='false'");
508510
st1.execute("use \"test\"");
509511
st1.execute(
510512
"create table wf14 (tag1 string tag, status boolean field, temperature float field)");
@@ -519,6 +521,8 @@ public void testInsertMultiRowWithNull() throws SQLException {
519521
st2.execute("CREATE TABLE wf15 (wt string tag, s1 double field, s2 double field)");
520522
st2.execute(
521523
"INSERT INTO wf15(wt, time, s1) VALUES ('1', 6, 10),('1', 7,12),('1', 8,14),('1', 9,160),('1', 10,null),('1', 11,58)");
524+
525+
st2.execute("SET CONFIGURATION enable_auto_create_schema='true'");
522526
} catch (SQLException e) {
523527
fail(e.getMessage());
524528
}
@@ -829,6 +833,7 @@ public void testInsertCaseSensitivity()
829833
@Test
830834
public void testInsertKeyword() throws IoTDBConnectionException, StatementExecutionException {
831835
try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
836+
session.executeNonQueryStatement("SET CONFIGURATION enable_auto_create_schema='true'");
832837
session.executeNonQueryStatement("USE \"test\"");
833838
session.executeNonQueryStatement(
834839
"create table table20 ("
@@ -1066,6 +1071,7 @@ public void testInsertTabletWithTTL()
10661071
public void testInsertUnsequenceData()
10671072
throws IoTDBConnectionException, StatementExecutionException {
10681073
try (ITableSession session = EnvFactory.getEnv().getTableSessionConnection()) {
1074+
session.executeNonQueryStatement("SET CONFIGURATION enable_auto_create_schema='true'");
10691075
session.executeNonQueryStatement("USE \"test\"");
10701076
// the table is missing column "m2"
10711077
session.executeNonQueryStatement(

integration-test/src/test/java/org/apache/iotdb/relational/it/query/old/builtinfunction/scalar/IoTDBScalarFunctionTableIT.java

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1370,63 +1370,56 @@ public void lengthTestFail() {
13701370
tableAssertTestFail(
13711371
"select s1,Length(s1,1) from lengthTable",
13721372
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1373-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1373+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
13741374
DATABASE_NAME);
13751375

13761376
// case 2: wrong data type
13771377
tableAssertTestFail(
13781378
"select s1,Length(s2) from lengthTable",
13791379
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1380-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1380+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
13811381
DATABASE_NAME);
13821382

13831383
// case 3: wrong data type
13841384
tableAssertTestFail(
13851385
"select s1,Length(s3) from lengthTable",
13861386
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1387-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1387+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
13881388
DATABASE_NAME);
13891389

13901390
// case 4: wrong data type
13911391
tableAssertTestFail(
13921392
"select s1,Length(s4) from lengthTable",
13931393
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1394-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1394+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
13951395
DATABASE_NAME);
13961396

13971397
// case 5: wrong data type
13981398
tableAssertTestFail(
13991399
"select s1,Length(s5) from lengthTable",
14001400
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1401-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1401+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
14021402
DATABASE_NAME);
14031403

14041404
// case 6: wrong data type
14051405
tableAssertTestFail(
14061406
"select s1,Length(s6) from lengthTable",
14071407
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1408-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1408+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
14091409
DATABASE_NAME);
14101410

14111411
// case 7: wrong data type
14121412
tableAssertTestFail(
14131413
"select s1,Length(s7) from lengthTable",
14141414
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1415-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1415+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
14161416
DATABASE_NAME);
14171417

14181418
// case 8: wrong data type
14191419
tableAssertTestFail(
14201420
"select s1,Length(s8) from lengthTable",
14211421
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1422-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1423-
DATABASE_NAME);
1424-
1425-
// case 9: wrong data type
1426-
tableAssertTestFail(
1427-
"select s1,Length(s10) from lengthTable",
1428-
TSStatusCode.SEMANTIC_ERROR.getStatusCode()
1429-
+ ": Scalar function length only accepts one argument and it must be text or string data type.",
1422+
+ ": Scalar function length only accepts one argument and it must be text, string, or blob data type.",
14301423
DATABASE_NAME);
14311424
}
14321425

0 commit comments

Comments
 (0)