This is an automated email from the ASF dual-hosted git repository.
tanxinyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new bd61c224742 Optimize String value type infer logic (#12223)
bd61c224742 is described below
commit bd61c2247429890be446feedb1aa5f7541c9465c
Author: Haonan <[email protected]>
AuthorDate: Wed Mar 27 16:29:10 2024 +0800
Optimize String value type infer logic (#12223)
---
.../db/it/IOTDBInsertWithTimeAtAnyIndexIT.java | 6 ++--
.../java/org/apache/iotdb/db/it/IoTDBFilterIT.java | 4 +--
.../org/apache/iotdb/db/it/IoTDBSimpleQueryIT.java | 2 +-
.../db/it/aligned/IoTDBInsertAlignedValuesIT.java | 30 ++++++++--------
.../it/last/IoTDBLastQueryWithLimitOffsetIT.java | 6 ++--
.../iotdb/db/it/last/IoTDBLastWithTTLIT.java | 8 ++---
.../iotdb/db/it/query/IoTDBCaseWhenThenIT.java | 4 +--
.../iotdb/db/it/schema/IoTDBExtendTemplateIT.java | 16 ++++-----
.../iotdb/db/it/schema/IoTDBSchemaTemplateIT.java | 4 +--
.../iotdb/db/it/udf/IoTDBUDFManagementIT.java | 2 +-
.../session/it/IoTDBSessionAlignedInsertIT.java | 4 +--
.../iotdb/session/it/IoTDBSessionSimpleIT.java | 14 ++++----
.../iotdb/zeppelin/it/IoTDBInterpreterIT.java | 8 ++---
iotdb-client/client-py/tests/test_dataframe.py | 2 +-
.../java/org/apache/iotdb/db/conf/IoTDBConfig.java | 38 +++++++++++---------
.../org/apache/iotdb/db/conf/IoTDBDescriptor.java | 6 +---
.../apache/iotdb/db/utils/TypeInferenceUtils.java | 40 ++++++++++++----------
.../iotdb/db/utils/TypeInferenceUtilsTest.java | 37 ++++++++++++--------
.../resources/conf/iotdb-common.properties | 17 +++++----
19 files changed, 129 insertions(+), 119 deletions(-)
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
index 3db755bb547..b0ae70a98e1 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IOTDBInsertWithTimeAtAnyIndexIT.java
@@ -67,13 +67,13 @@ public class IOTDBInsertWithTimeAtAnyIndexIT {
try (ResultSet resultSet = statement.executeQuery("select s1 from
root.db.d1")) {
assertTrue(resultSet.next());
assertEquals(1, resultSet.getLong(1));
- assertEquals(2, resultSet.getFloat(2), 0.00001);
+ assertEquals(2, resultSet.getDouble(2), 0.00001);
assertTrue(resultSet.next());
assertEquals(10, resultSet.getLong(1));
- assertEquals(20, resultSet.getFloat(2), 0.00001);
+ assertEquals(20, resultSet.getDouble(2), 0.00001);
assertTrue(resultSet.next());
assertEquals(100, resultSet.getLong(1));
- assertEquals(200, resultSet.getFloat(2), 0.00001);
+ assertEquals(200, resultSet.getDouble(2), 0.00001);
assertFalse(resultSet.next());
}
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
index 029b4b0032b..306346e2bdc 100644
--- a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
+++ b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBFilterIT.java
@@ -199,13 +199,13 @@ public class IoTDBFilterIT {
public void testMismatchedDataTypes() {
assertTestFail(
"select s1 from root.sg1.d1 where s1;",
- "The output type of the expression in WHERE clause should be BOOLEAN,
actual data type: FLOAT.");
+ "The output type of the expression in WHERE clause should be BOOLEAN,
actual data type: DOUBLE.");
assertTestFail(
"select count(s1) from root.sg1.d1 group by ([0, 40), 5ms) having
count(s1) + 1;",
"The output type of the expression in HAVING clause should be BOOLEAN,
actual data type: DOUBLE.");
assertTestFail(
"select s1 from root.sg1.d1 where s1 align by device;",
- "The output type of the expression in WHERE clause should be BOOLEAN,
actual data type: FLOAT.");
+ "The output type of the expression in WHERE clause should be BOOLEAN,
actual data type: DOUBLE.");
assertTestFail(
"select count(s1) from root.sg1.d1 group by ([0, 40), 5ms) having
count(s1) + 1 align by device;",
"The output type of the expression in HAVING clause should be BOOLEAN,
actual data type: DOUBLE.");
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSimpleQueryIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSimpleQueryIT.java
index 930ab8db1b3..084fb740a22 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSimpleQueryIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/IoTDBSimpleQueryIT.java
@@ -1116,7 +1116,7 @@ public class IoTDBSimpleQueryIT {
try (ResultSet r1 = statement.executeQuery("select s1 from
root.sg1.*a*")) {
while (r1.next()) {
- Assert.assertEquals(1.1234f, r1.getFloat(2), 0);
+ Assert.assertEquals(1.1234f, r1.getDouble(2), 0.001);
}
Assert.assertEquals(3, r1.getMetaData().getColumnCount());
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBInsertAlignedValuesIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBInsertAlignedValuesIT.java
index 786a67d9164..aee8215f284 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBInsertAlignedValuesIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/aligned/IoTDBInsertAlignedValuesIT.java
@@ -84,17 +84,17 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(17.1, resultSet.getFloat(3), 0.1);
+ assertEquals(17.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(5000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(20.1, resultSet.getFloat(3), 0.1);
+ assertEquals(20.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(6000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(22, resultSet.getFloat(3), 0.1);
+ assertEquals(22, resultSet.getDouble(3), 0.1);
assertFalse(resultSet.next());
}
@@ -126,7 +126,7 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(17.1, resultSet.getFloat(3), 0.1);
+ assertEquals(17.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(5000, resultSet.getLong(1));
@@ -136,7 +136,7 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(6000, resultSet.getLong(1));
assertNull(resultSet.getObject(2));
- assertEquals(22.0f, resultSet.getObject(3));
+ assertEquals(22.0d, resultSet.getObject(3));
assertFalse(resultSet.next());
}
@@ -170,17 +170,17 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(17.1, resultSet.getFloat(3), 0.1);
+ assertEquals(17.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(5000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(20.1, resultSet.getFloat(3), 0.1);
+ assertEquals(20.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(6000, resultSet.getLong(1));
assertNull(resultSet.getObject(2));
- assertEquals(22.0f, resultSet.getObject(3));
+ assertEquals(22.0d, resultSet.getObject(3));
assertFalse(resultSet.next());
}
@@ -200,17 +200,17 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(4000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(17.1, resultSet.getFloat(3), 0.1);
+ assertEquals(17.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(5000, resultSet.getLong(1));
assertTrue(resultSet.getBoolean(2));
- assertEquals(20.1, resultSet.getFloat(3), 0.1);
+ assertEquals(20.1, resultSet.getDouble(3), 0.1);
assertTrue(resultSet.next());
assertEquals(6000, resultSet.getLong(1));
assertNull(resultSet.getObject(2));
- assertEquals(22.0f, resultSet.getObject(3));
+ assertEquals(22.0d, resultSet.getObject(3));
assertFalse(resultSet.next());
}
@@ -229,8 +229,8 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(1, resultSet.getLong(1));
- assertEquals(2.0F, resultSet.getObject(2));
- assertEquals(2.0F, resultSet.getObject(3));
+ assertEquals(2.0d, resultSet.getObject(2));
+ assertEquals(2.0d, resultSet.getObject(3));
assertFalse(resultSet.next());
}
@@ -240,8 +240,8 @@ public class IoTDBInsertAlignedValuesIT {
assertTrue(resultSet.next());
assertEquals(1, resultSet.getLong(1));
- assertEquals(2.0F, resultSet.getObject(2));
- assertEquals(2.0F, resultSet.getObject(3));
+ assertEquals(2.0d, resultSet.getObject(2));
+ assertEquals(2.0d, resultSet.getObject(3));
assertFalse(resultSet.next());
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastQueryWithLimitOffsetIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastQueryWithLimitOffsetIT.java
index 4f80081a703..062d5a345c3 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastQueryWithLimitOffsetIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastQueryWithLimitOffsetIT.java
@@ -64,7 +64,7 @@ public class IoTDBLastQueryWithLimitOffsetIT {
public void testWithLimit() {
String[] retArray =
new String[] {
- "1,root.sg.d1.s1,1.0,FLOAT",
+ "1,root.sg.d1.s1,1.0,DOUBLE",
};
try (Connection connection = EnvFactory.getEnv().getConnection();
@@ -95,7 +95,7 @@ public class IoTDBLastQueryWithLimitOffsetIT {
@Test
public void testWithOffset() {
- String[] retArray = new String[] {"2,root.sg.d2.s2,1.0,FLOAT"};
+ String[] retArray = new String[] {"2,root.sg.d2.s2,1.0,DOUBLE"};
try (Connection connection = EnvFactory.getEnv().getConnection();
Statement statement = connection.createStatement()) {
@@ -127,7 +127,7 @@ public class IoTDBLastQueryWithLimitOffsetIT {
public void testWithLimitAndOffset() {
String[] retArray =
new String[] {
- "1,root.sg.d1.s2,1.0,FLOAT", "2,root.sg.d2.s1,1.0,FLOAT",
+ "1,root.sg.d1.s2,1.0,DOUBLE", "2,root.sg.d2.s1,1.0,DOUBLE",
};
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastWithTTLIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastWithTTLIT.java
index f6b0210d143..a09f2ade118 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastWithTTLIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/last/IoTDBLastWithTTLIT.java
@@ -65,10 +65,10 @@ public class IoTDBLastWithTTLIT {
public void withTTL() {
String[] retArray =
new String[] {
- "1,root.sg.d1.s1,1.0,FLOAT",
- "1,root.sg.d1.s2,1.0,FLOAT",
- "2,root.sg.d2.s1,1.0,FLOAT",
- "2,root.sg.d2.s2,1.0,FLOAT"
+ "1,root.sg.d1.s1,1.0,DOUBLE",
+ "1,root.sg.d1.s2,1.0,DOUBLE",
+ "2,root.sg.d2.s1,1.0,DOUBLE",
+ "2,root.sg.d2.s2,1.0,DOUBLE"
};
try (Connection connection = EnvFactory.getEnv().getConnection();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBCaseWhenThenIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBCaseWhenThenIT.java
index 7e3e3754679..7d78130930f 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBCaseWhenThenIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/query/IoTDBCaseWhenThenIT.java
@@ -194,7 +194,7 @@ public class IoTDBCaseWhenThenIT {
expectedHeader = new String[] {TIMESTAMP_STR, "result"};
retArray =
new String[] {
- "0,99.0,", "1000000,99.9000015258789,", "20000000,8.589934588E9,",
"210000000,1000.0,"
+ "0,99.0,", "1000000,99.9,", "20000000,8.589934588E9,",
"210000000,999.9999999999,"
};
resultSetEqualTest(
"select case when s1=0 then 99 when s1=11 then 99.9 when s1=22 then
8589934588 when s1=33 then 999.9999999999 else 10086 end as `result` from
root.sg.d1",
@@ -245,7 +245,7 @@ public class IoTDBCaseWhenThenIT {
expectedHeader = new String[] {TIMESTAMP_STR, "result"};
retArray =
new String[] {
- "0,99.0,", "1000000,99.9000015258789,", "20000000,8.589934588E9,",
"210000000,1000.0,"
+ "0,99.0,", "1000000,99.9,", "20000000,8.589934588E9,",
"210000000,999.9999999999,"
};
resultSetEqualTest(
"select case s1 when 0 then 99 when 11 then 99.9 when 22 then
8589934588 when 33 then 999.9999999999 else 10086 end as `result` from
root.sg.d1",
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
index eb2e772df2f..9945843b091 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBExtendTemplateIT.java
@@ -156,16 +156,16 @@ public class IoTDBExtendTemplateIT extends
AbstractSchemaIT {
Arrays.asList(
"root.db.d1.s1,null,root.db,INT64,PLAIN,LZ4,null,null,null,null,BASE,",
"root.db.d1.s2,null,root.db,DOUBLE,RLE,LZ4,null,null,null,null,BASE,",
-
"root.db.d1.s3,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db.d1.s4,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db.d1.s5,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d1.s3,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d1.s4,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d1.s5,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
"root.db.d2.s1,null,root.db,INT64,PLAIN,LZ4,null,null,null,null,BASE,",
"root.db.d2.s2,null,root.db,DOUBLE,RLE,LZ4,null,null,null,null,BASE,",
-
"root.db.d2.s3,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db.d2.s4,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db.d2.s5,null,root.db,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db1.d1.s2,null,root.db1,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,",
-
"root.db1.d1.s3,null,root.db1,FLOAT,GORILLA,LZ4,null,null,null,null,BASE,"))
+
"root.db.d2.s3,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d2.s4,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db.d2.s5,null,root.db,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db1.d1.s2,null,root.db1,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,",
+
"root.db1.d1.s3,null,root.db1,DOUBLE,GORILLA,LZ4,null,null,null,null,BASE,"))
};
for (int n = 0; n < sqls.length; n++) {
String sql = sqls[n];
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
index 455a56bed94..ecc16af137c 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBSchemaTemplateIT.java
@@ -753,8 +753,8 @@ public class IoTDBSchemaTemplateIT extends AbstractSchemaIT
{
new HashSet<>(
Arrays.asList(
"root.sg1.d.s1,INT32,TS_2DIFF,LZ4",
- "root.sg1.d.s2,FLOAT,GORILLA,LZ4",
- "root.sg1.d.s3,FLOAT,GORILLA,LZ4"));
+ "root.sg1.d.s2,DOUBLE,GORILLA,LZ4",
+ "root.sg1.d.s3,DOUBLE,GORILLA,LZ4"));
try (ResultSet resultSet = statement.executeQuery("SHOW TIMESERIES
root.sg*.*.s*")) {
while (resultSet.next()) {
diff --git
a/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
b/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
index 28c2bc41b0c..798256e5a16 100644
---
a/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/db/it/udf/IoTDBUDFManagementIT.java
@@ -329,7 +329,7 @@ public class IoTDBUDFManagementIT {
try (ResultSet rs = statement.executeQuery("SELECT ABS(s1) FROM
root.vehicle.d1")) {
Assert.assertTrue(rs.next());
Assert.assertEquals(1, rs.getLong(1));
- Assert.assertEquals(10.0F, rs.getFloat(2), 0.00001);
+ Assert.assertEquals(10.0F, rs.getDouble(2), 0.00001);
Assert.assertFalse(rs.next());
}
}
diff --git
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
index 94046d1b22d..b4b83898011 100644
---
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionAlignedInsertIT.java
@@ -148,7 +148,7 @@ public class IoTDBSessionAlignedInsertIT {
long time = 0;
while (dataSet.hasNext()) {
RowRecord rowRecord = dataSet.next();
- assertEquals(time * 10 + 3, rowRecord.getFields().get(0).getFloatV(),
DELTA_DOUBLE);
+ assertEquals(time * 10 + 3, rowRecord.getFields().get(0).getDoubleV(),
DELTA_DOUBLE);
time += 1;
}
assertEquals(100, time);
@@ -172,7 +172,7 @@ public class IoTDBSessionAlignedInsertIT {
long time = 0;
while (dataSet.hasNext()) {
RowRecord rowRecord = dataSet.next();
- assertEquals(time * 10 + 3, rowRecord.getFields().get(0).getFloatV(),
DELTA_DOUBLE);
+ assertEquals(time * 10 + 3, rowRecord.getFields().get(0).getDoubleV(),
DELTA_DOUBLE);
time += 1;
}
assertEquals(100, time);
diff --git
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
index 908887c1e7f..120b65797a5 100644
---
a/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/session/it/IoTDBSessionSimpleIT.java
@@ -1019,11 +1019,11 @@ public class IoTDBSessionSimpleIT {
dataSet.getColumnTypes().toArray(new String[0]),
new String[] {
String.valueOf(TSDataType.INT64),
- String.valueOf(TSDataType.FLOAT),
- String.valueOf(TSDataType.FLOAT),
+ String.valueOf(TSDataType.DOUBLE),
+ String.valueOf(TSDataType.DOUBLE),
String.valueOf(TSDataType.BOOLEAN),
String.valueOf(TSDataType.BOOLEAN),
- String.valueOf(TSDataType.FLOAT)
+ String.valueOf(TSDataType.DOUBLE)
});
long time = 1L;
@@ -1033,7 +1033,7 @@ public class IoTDBSessionSimpleIT {
time++;
assertNulls(record, new int[] {0, 3, 4});
- assertEquals(5.0f, record.getFields().get(1).getFloatV(), 0.01);
+ assertEquals(5.0f, record.getFields().get(1).getDoubleV(), 0.01);
assertEquals(Boolean.TRUE, record.getFields().get(2).getBoolV());
assertTrue(dataSet.hasNext());
@@ -1042,8 +1042,8 @@ public class IoTDBSessionSimpleIT {
time++;
assertNulls(record, new int[] {1, 2, 3});
- assertEquals(4, record.getFields().get(0).getFloatV(), 0.01);
- assertEquals(3, record.getFields().get(4).getFloatV(), 0.01);
+ assertEquals(4, record.getFields().get(0).getDoubleV(), 0.01);
+ assertEquals(3, record.getFields().get(4).getDoubleV(), 0.01);
assertTrue(dataSet.hasNext());
record = dataSet.next();
@@ -1051,7 +1051,7 @@ public class IoTDBSessionSimpleIT {
assertNulls(record, new int[] {0, 1, 2});
assertFalse(record.getFields().get(3).getBoolV());
- assertEquals(6, record.getFields().get(4).getFloatV(), 0.01);
+ assertEquals(6, record.getFields().get(4).getDoubleV(), 0.01);
assertFalse(dataSet.hasNext());
dataSet.closeOperationHandle();
diff --git
a/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
b/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
index e64afb2ea00..0888da9391e 100644
---
a/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
+++
b/integration-test/src/test/java/org/apache/iotdb/zeppelin/it/IoTDBInterpreterIT.java
@@ -311,12 +311,12 @@ public class IoTDBInterpreterIT {
InterpreterResult actual = interpreter.internalInterpret("show
timeseries", null);
String gt =
"Timeseries\tAlias\tDatabase\tDataType\tEncoding\tCompression\tTags\tAttributes\tDeadband\tDeadbandParameters\tViewType\n"
- +
"root.test.wf01.wt01.temperature\tnull\troot.test.wf01\tFLOAT\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
+ +
"root.test.wf01.wt01.temperature\tnull\troot.test.wf01\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
+
"root.test.wf01.wt01.status\tnull\troot.test.wf01\tBOOLEAN\tRLE\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf01.wt01.hardware\tnull\troot.test.wf01\tFLOAT\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf02.wt02.temperature\tnull\troot.test.wf02\tFLOAT\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
+ +
"root.test.wf01.wt01.hardware\tnull\troot.test.wf01\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
+ +
"root.test.wf02.wt02.temperature\tnull\troot.test.wf02\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
+
"root.test.wf02.wt02.status\tnull\troot.test.wf02\tBOOLEAN\tRLE\tLZ4\tnull\tnull\tnull\tnull\tBASE\n"
- +
"root.test.wf02.wt02.hardware\tnull\troot.test.wf02\tFLOAT\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE";
+ +
"root.test.wf02.wt02.hardware\tnull\troot.test.wf02\tDOUBLE\tGORILLA\tLZ4\tnull\tnull\tnull\tnull\tBASE";
Assert.assertNotNull(actual);
Assert.assertEquals(Code.SUCCESS, actual.code());
Assert.assertEquals(gt, actual.message().get(0).getData());
diff --git a/iotdb-client/client-py/tests/test_dataframe.py
b/iotdb-client/client-py/tests/test_dataframe.py
index 1326748c598..a93efdbea3e 100644
--- a/iotdb-client/client-py/tests/test_dataframe.py
+++ b/iotdb-client/client-py/tests/test_dataframe.py
@@ -80,7 +80,7 @@ def test_non_time_query():
"root.device0.pressure",
None,
"root.device0",
- "FLOAT",
+ "DOUBLE",
"GORILLA",
"LZ4",
None,
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
index a574e0260e5..1380a167505 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
@@ -627,17 +627,14 @@ public class IoTDBConfig {
/** Register time series as which type when receiving boolean string "true"
or "false" */
private TSDataType booleanStringInferType = TSDataType.BOOLEAN;
- /** Register time series as which type when receiving an integer string "67"
*/
- private TSDataType integerStringInferType = TSDataType.FLOAT;
-
/**
* register time series as which type when receiving an integer string and
using float may lose
- * precision num > 2 ^ 24
+ * precision
*/
- private TSDataType longStringInferType = TSDataType.DOUBLE;
+ private TSDataType integerStringInferType = TSDataType.DOUBLE;
/** register time series as which type when receiving a floating number
string "6.7" */
- private TSDataType floatingStringInferType = TSDataType.FLOAT;
+ private TSDataType floatingStringInferType = TSDataType.DOUBLE;
/**
* register time series as which type when receiving the Literal NaN. Values
can be DOUBLE, FLOAT
@@ -2197,6 +2194,12 @@ public class IoTDBConfig {
}
public void setBooleanStringInferType(TSDataType booleanStringInferType) {
+ if (booleanStringInferType != TSDataType.BOOLEAN && booleanStringInferType
!= TSDataType.TEXT) {
+ logger.warn(
+ "Config Property boolean_string_infer_type can only be BOOLEAN or
TEXT but is {}",
+ booleanStringInferType);
+ return;
+ }
this.booleanStringInferType = booleanStringInferType;
}
@@ -2208,19 +2211,19 @@ public class IoTDBConfig {
this.integerStringInferType = integerStringInferType;
}
- public void setLongStringInferType(TSDataType longStringInferType) {
- this.longStringInferType = longStringInferType;
- }
-
- public TSDataType getLongStringInferType() {
- return longStringInferType;
- }
-
public TSDataType getFloatingStringInferType() {
return floatingStringInferType;
}
public void setFloatingStringInferType(TSDataType
floatingNumberStringInferType) {
+ if (floatingNumberStringInferType != TSDataType.DOUBLE
+ && floatingNumberStringInferType != TSDataType.FLOAT
+ && floatingNumberStringInferType != TSDataType.TEXT) {
+ logger.warn(
+ "Config Property floating_string_infer_type can only be FLOAT,
DOUBLE or TEXT but is {}",
+ floatingNumberStringInferType);
+ return;
+ }
this.floatingStringInferType = floatingNumberStringInferType;
}
@@ -2232,9 +2235,10 @@ public class IoTDBConfig {
if (nanStringInferType != TSDataType.DOUBLE
&& nanStringInferType != TSDataType.FLOAT
&& nanStringInferType != TSDataType.TEXT) {
- throw new IllegalArgumentException(
- "Config Property nan_string_infer_type can only be FLOAT, DOUBLE or
TEXT but is "
- + nanStringInferType);
+ logger.warn(
+ "Config Property nan_string_infer_type can only be FLOAT, DOUBLE or
TEXT but is {}",
+ nanStringInferType);
+ return;
}
this.nanStringInferType = nanStringInferType;
}
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
index 3a3693e3b7b..139a1374b44 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
@@ -1298,10 +1298,6 @@ public class IoTDBDescriptor {
TSDataType.valueOf(
properties.getProperty(
"integer_string_infer_type",
conf.getIntegerStringInferType().toString())));
- conf.setLongStringInferType(
- TSDataType.valueOf(
- properties.getProperty(
- "long_string_infer_type",
conf.getLongStringInferType().toString())));
conf.setFloatingStringInferType(
TSDataType.valueOf(
properties.getProperty(
@@ -1563,7 +1559,7 @@ public class IoTDBDescriptor {
// update timed flush & close conf
loadTimedService(properties);
StorageEngine.getInstance().rebootTimedService();
- // update params of creating schemaengine automatically
+ // update params of creating schema automatically
loadAutoCreateSchemaProps(properties);
// update tsfile-format config
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
index 187225f622a..1e6723ba637 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
@@ -31,7 +31,6 @@ import
org.apache.iotdb.db.queryengine.plan.expression.multi.FunctionExpression;
import
org.apache.iotdb.db.queryengine.plan.expression.multi.builtin.BuiltInScalarFunctionHelper;
import
org.apache.iotdb.db.queryengine.plan.expression.multi.builtin.BuiltInScalarFunctionHelperFactory;
import org.apache.iotdb.db.utils.constant.SqlConstant;
-import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
import org.apache.commons.lang3.StringUtils;
@@ -47,9 +46,6 @@ public class TypeInferenceUtils {
private static final TSDataType integerStringInferType =
IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType();
- private static final TSDataType longStringInferType =
- IoTDBDescriptor.getInstance().getConfig().getLongStringInferType();
-
private static final TSDataType floatingStringInferType =
IoTDBDescriptor.getInstance().getConfig().getFloatingStringInferType();
@@ -75,6 +71,15 @@ public class TypeInferenceUtils {
|| s.equalsIgnoreCase(SqlConstant.BOOLEAN_FALSE);
}
+ private static boolean isLong(String s) {
+ try {
+ Long.parseLong(s);
+ } catch (NumberFormatException e) {
+ return false;
+ }
+ return true;
+ }
+
private static boolean isConvertFloatPrecisionLack(String s) {
try {
return Long.parseLong(s) > (1 << 24);
@@ -86,15 +91,22 @@ public class TypeInferenceUtils {
/** Get predicted DataType of the given value */
public static TSDataType getPredictedDataType(Object value, boolean
inferType) {
- if (inferType) {
+ if (value instanceof Boolean) {
+ return TSDataType.BOOLEAN;
+ } else if (value instanceof Integer) {
+ return TSDataType.INT32;
+ } else if (value instanceof Long) {
+ return TSDataType.INT64;
+ } else if (value instanceof Float) {
+ return TSDataType.FLOAT;
+ } else if (value instanceof Double) {
+ return TSDataType.DOUBLE;
+ } else if (inferType) {
String strValue = value.toString();
if (isBoolean(strValue)) {
return booleanStringInferType;
} else if (isNumber(strValue)) {
- if (!strValue.contains(TsFileConstant.PATH_SEPARATOR)) {
- if (isConvertFloatPrecisionLack(StringUtils.trim(strValue))) {
- return longStringInferType;
- }
+ if (isLong(StringUtils.trim(strValue))) {
return integerStringInferType;
} else {
return floatingStringInferType;
@@ -107,16 +119,6 @@ public class TypeInferenceUtils {
} else {
return TSDataType.TEXT;
}
- } else if (value instanceof Boolean) {
- return TSDataType.BOOLEAN;
- } else if (value instanceof Integer) {
- return TSDataType.INT32;
- } else if (value instanceof Long) {
- return TSDataType.INT64;
- } else if (value instanceof Float) {
- return TSDataType.FLOAT;
- } else if (value instanceof Double) {
- return TSDataType.DOUBLE;
}
return TSDataType.TEXT;
diff --git
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeInferenceUtilsTest.java
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeInferenceUtilsTest.java
index 89b8b00bd64..a51e64a2839 100644
---
a/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeInferenceUtilsTest.java
+++
b/iotdb-core/datanode/src/test/java/org/apache/iotdb/db/utils/TypeInferenceUtilsTest.java
@@ -19,7 +19,9 @@
package org.apache.iotdb.db.utils;
+import org.apache.iotdb.db.conf.IoTDBConfig;
import org.apache.iotdb.db.conf.IoTDBDescriptor;
+import org.apache.iotdb.db.exception.query.QueryProcessException;
import org.apache.iotdb.tsfile.common.constant.TsFileConstant;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
@@ -60,7 +62,8 @@ public class TypeInferenceUtilsTest {
}
@Test
- public void testInferType() {
+ public void testInferType() throws QueryProcessException {
+ IoTDBConfig config = IoTDBDescriptor.getInstance().getConfig();
Object[] values = {
123,
"abc",
@@ -76,26 +79,32 @@ public class TypeInferenceUtilsTest {
"16777217", // 2^24 + 1
"16777216", // 2^24
"271840880000000000000000",
+ "4.9387406015404442E17",
+ "4E5",
+ "1.0",
};
- TSDataType[] encodings = {
- IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType(),
+ TSDataType[] inferredTypes = {
+ TSDataType.INT32,
TSDataType.TEXT,
- IoTDBDescriptor.getInstance().getConfig().getFloatingStringInferType(),
+ TSDataType.DOUBLE,
TSDataType.BOOLEAN,
TSDataType.FLOAT,
- IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getFloatingStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getLongStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getBooleanStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getLongStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType(),
- IoTDBDescriptor.getInstance().getConfig().getLongStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getFloatingStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getBooleanStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getIntegerStringInferType(),
+ config.getFloatingStringInferType(),
+ config.getFloatingStringInferType(),
+ config.getFloatingStringInferType(),
+ config.getFloatingStringInferType()
};
for (int i = 0; i < values.length; i++) {
- assertEquals(encodings[i],
TypeInferenceUtils.getPredictedDataType(values[i], true));
+ assertEquals(inferredTypes[i],
TypeInferenceUtils.getPredictedDataType(values[i], true));
}
}
diff --git
a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-common.properties
b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-common.properties
index 13adcd1a86f..7dadb6a4d2f 100644
---
a/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-common.properties
+++
b/iotdb-core/node-commons/src/assembly/resources/conf/iotdb-common.properties
@@ -314,23 +314,22 @@ data_replication_factor=1
# register time series as which type when receiving boolean string "true" or
"false"
# Datatype: TSDataType
+# Options: BOOLEAN, TEXT
# boolean_string_infer_type=BOOLEAN
-# register time series as which type when receiving an integer string "67"
+# register time series as which type when receiving an integer string and
using float or double may lose precision
# Datatype: TSDataType
-# integer_string_infer_type=FLOAT
-
-# register time series as which type when receiving an integer string and
using float may lose precision
-# num > 2 ^ 24
-# Datatype: TSDataType
-# long_string_infer_type=DOUBLE
+# Options: DOUBLE, FLOAT, INT32, INT64, TEXT
+# integer_string_infer_type=DOUBLE
# register time series as which type when receiving a floating number string
"6.7"
# Datatype: TSDataType
-# floating_string_infer_type=FLOAT
+# Options: DOUBLE, FLOAT, TEXT
+# floating_string_infer_type=DOUBLE
-# register time series as which type when receiving the Literal NaN. Values
can be DOUBLE, FLOAT or TEXT
+# register time series as which type when receiving the Literal NaN.
# Datatype: TSDataType
+# Options: DOUBLE, FLOAT, TEXT
# nan_string_infer_type=DOUBLE
# BOOLEAN encoding when creating schema automatically is enabled