You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2019/11/07 08:13:16 UTC

[incubator-iotdb] branch fix_auto_create_bool created (now 2afd9a1)

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

qiaojialin pushed a change to branch fix_auto_create_bool
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git.


      at 2afd9a1  fix auto create bool type

This branch includes the following new commits:

     new 2afd9a1  fix auto create bool type

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[incubator-iotdb] 01/01: fix auto create bool type

Posted by qi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch fix_auto_create_bool
in repository https://gitbox.apache.org/repos/asf/incubator-iotdb.git

commit 2afd9a17c1bfded1cc4775b9d9e0abf0fb58376f
Author: qiaojialin <64...@qq.com>
AuthorDate: Thu Nov 7 16:12:54 2019 +0800

    fix auto create bool type
---
 server/src/assembly/resources/conf/iotdb-engine.properties     |  2 +-
 .../java/org/apache/iotdb/db/utils/TypeInferenceUtils.java     | 10 ++++++++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/server/src/assembly/resources/conf/iotdb-engine.properties b/server/src/assembly/resources/conf/iotdb-engine.properties
index 3d45d57..44d69fe 100644
--- a/server/src/assembly/resources/conf/iotdb-engine.properties
+++ b/server/src/assembly/resources/conf/iotdb-engine.properties
@@ -330,7 +330,7 @@ watermark_method=GroupBasedLSBMethod(embed_row_cycle=2,embed_lsb_num=5)
 ####################
 
 # Whether creating schema automatically is enabled
-enable_auto_create_schema=false
+enable_auto_create_schema=true
 
 # Storage group level when creating schema automatically is enabled
 # e.g. root.sg0.d1.s2
diff --git a/server/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java b/server/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
index 934bc8c..63c79a3 100644
--- a/server/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
+++ b/server/src/main/java/org/apache/iotdb/db/utils/TypeInferenceUtils.java
@@ -19,6 +19,7 @@
 
 package org.apache.iotdb.db.utils;
 
+import org.apache.iotdb.db.qp.constant.SQLConstant;
 import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
 
 public class TypeInferenceUtils {
@@ -27,7 +28,7 @@ public class TypeInferenceUtils {
 
   }
 
-  public static boolean isNumber(String s) {
+  static boolean isNumber(String s) {
     try {
       Double.parseDouble(s);
     } catch (NumberFormatException e) {
@@ -36,11 +37,16 @@ public class TypeInferenceUtils {
     return true;
   }
 
+  private static boolean isBoolean(String s) {
+    return s.equalsIgnoreCase(SQLConstant.BOOLEN_TRUE) || s
+        .equalsIgnoreCase(SQLConstant.BOOLEN_FALSE);
+  }
+
   /**
    * Get predicted DataType of the given value
    */
   public static TSDataType getPredictedDataType(Object value) {
-    if (value instanceof Boolean) {
+    if (value instanceof Boolean || (value instanceof String && isBoolean((String) value))) {
       return TSDataType.BOOLEAN;
     } else if (value instanceof Number || (value instanceof String && isNumber((String) value))) {
       String v = String.valueOf(value);