This is an automated email from the ASF dual-hosted git repository.

jackietien 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 4ff9c8373fe Revert auto create STRING type inference
4ff9c8373fe is described below

commit 4ff9c8373fef9a15e2a5e04111dece4425860087
Author: Chen YZ <[email protected]>
AuthorDate: Fri May 31 14:14:34 2024 +0800

    Revert auto create STRING type inference
---
 .../iotdb/db/it/schema/IoTDBAutoCreateSchemaIT.java      | 16 ++--------------
 .../apache/iotdb/session/it/IoTDBSessionSimpleIT.java    |  2 +-
 .../main/java/org/apache/iotdb/db/conf/IoTDBConfig.java  |  6 ------
 .../org/apache/iotdb/db/utils/TypeInferenceUtils.java    | 13 -------------
 .../apache/iotdb/db/utils/TypeInferenceUtilsTest.java    |  2 +-
 5 files changed, 4 insertions(+), 35 deletions(-)

diff --git 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAutoCreateSchemaIT.java
 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAutoCreateSchemaIT.java
index 50965078ee4..8d0380bba72 100644
--- 
a/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAutoCreateSchemaIT.java
+++ 
b/integration-test/src/test/java/org/apache/iotdb/db/it/schema/IoTDBAutoCreateSchemaIT.java
@@ -19,7 +19,6 @@
 
 package org.apache.iotdb.db.it.schema;
 
-import org.apache.iotdb.db.conf.IoTDBDescriptor;
 import org.apache.iotdb.db.queryengine.common.header.ColumnHeaderConstant;
 import org.apache.iotdb.it.env.EnvFactory;
 import org.apache.iotdb.itbase.category.ClusterIT;
@@ -234,15 +233,8 @@ public class IoTDBAutoCreateSchemaIT extends 
AbstractSchemaIT {
    */
   @Test
   public void testAutoCreateDataType() throws SQLException {
-    int textLen = 
IoTDBDescriptor.getInstance().getConfig().getInferStringMaxLength() + 1;
-    StringBuilder sb = new StringBuilder();
-    for (int i = 0; i < textLen; i++) {
-      sb.append("a");
-    }
     String SQL =
-        "INSERT INTO root.sg0.d1(time,s1,s2,s3,s4,s5,s6,s7) 
values(1,true,1,now(),X'cafe',\"string\",\"2024-01-01\", \""
-            + sb
-            + "\")";
+        "INSERT INTO root.sg0.d1(time,s1,s2,s3,s4,s5,s6) 
values(1,true,1,now(),X'cafe',\"string\",\"2024-01-01\")";
     try (Connection connection = EnvFactory.getEnv().getConnection();
         Statement statement = connection.createStatement()) {
       statement.execute(SQL);
@@ -267,13 +259,9 @@ public class IoTDBAutoCreateSchemaIT extends 
AbstractSchemaIT {
             break;
           case "root.sg0.d1.s5":
             assertEquals(
-                TSDataType.STRING.toString(), 
resultSet.getString(ColumnHeaderConstant.DATATYPE));
+                TSDataType.TEXT.toString(), 
resultSet.getString(ColumnHeaderConstant.DATATYPE));
             break;
           case "root.sg0.d1.s6":
-            assertEquals(
-                TSDataType.STRING.toString(), 
resultSet.getString(ColumnHeaderConstant.DATATYPE));
-            break;
-          case "root.sg0.d1.s7":
             assertEquals(
                 TSDataType.TEXT.toString(), 
resultSet.getString(ColumnHeaderConstant.DATATYPE));
             break;
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 c0338848946..0a89ee56ded 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
@@ -213,7 +213,7 @@ public class IoTDBSessionSimpleIT {
       
expected.add(IoTDBDescriptor.getInstance().getConfig().getIntegerStringInferType().name());
       
expected.add(IoTDBDescriptor.getInstance().getConfig().getFloatingStringInferType().name());
       
expected.add(IoTDBDescriptor.getInstance().getConfig().getBooleanStringInferType().name());
-      expected.add(TSDataType.STRING.name());
+      expected.add(TSDataType.TEXT.name());
 
       Set<String> actual = new HashSet<>();
       SessionDataSet dataSet = session.executeQueryStatement("show timeseries 
root.**");
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 b996ecd5b47..6b238c69809 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
@@ -654,8 +654,6 @@ public class IoTDBConfig {
   /** register time series as which type when receiving a floating number 
string "6.7" */
   private TSDataType floatingStringInferType = TSDataType.DOUBLE;
 
-  private int inferStringMaxLength = 512;
-
   /**
    * register time series as which type when receiving the Literal NaN. Values 
can be DOUBLE, FLOAT
    * or TEXT
@@ -2293,10 +2291,6 @@ public class IoTDBConfig {
     return floatingStringInferType;
   }
 
-  public int getInferStringMaxLength() {
-    return inferStringMaxLength;
-  }
-
   public void setFloatingStringInferType(TSDataType 
floatingNumberStringInferType) {
     if (floatingNumberStringInferType != TSDataType.DOUBLE
         && floatingNumberStringInferType != TSDataType.FLOAT
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 758cc6f511f..5665fd9aa5a 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
@@ -33,7 +33,6 @@ import 
org.apache.iotdb.db.queryengine.plan.expression.multi.builtin.BuiltInScal
 import org.apache.iotdb.db.utils.constant.SqlConstant;
 
 import org.apache.commons.lang3.StringUtils;
-import org.apache.tsfile.common.conf.TSFileConfig;
 import org.apache.tsfile.enums.TSDataType;
 
 import java.util.Collections;
@@ -53,22 +52,12 @@ public class TypeInferenceUtils {
   private static final TSDataType nanStringInferType =
       IoTDBDescriptor.getInstance().getConfig().getNanStringInferType();
 
-  private static final int inferStringMaxLength =
-      IoTDBDescriptor.getInstance().getConfig().getInferStringMaxLength();
-
   private TypeInferenceUtils() {}
 
   private static boolean isBlob(String s) {
     return s.length() >= 3 && s.startsWith("X'") && s.endsWith("'");
   }
 
-  private static boolean isString(String s) {
-    if (s.getBytes(TSFileConfig.STRING_CHARSET).length <= 
inferStringMaxLength) {
-      return true;
-    }
-    return false;
-  }
-
   static boolean isNumber(String s) {
     if (s == null || s.equals("NaN")) {
       return false;
@@ -133,8 +122,6 @@ public class TypeInferenceUtils {
         return nanStringInferType;
       } else if (isBlob(strValue)) {
         return TSDataType.BLOB;
-      } else if (isString(strValue)) {
-        return TSDataType.STRING;
       } else {
         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 82e4dc1265a..9933d61c688 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
@@ -85,7 +85,7 @@ public class TypeInferenceUtilsTest {
     };
     TSDataType[] inferredTypes = {
       TSDataType.INT32,
-      TSDataType.STRING,
+      TSDataType.TEXT,
       TSDataType.DOUBLE,
       TSDataType.BOOLEAN,
       TSDataType.FLOAT,

Reply via email to