未验证 提交 56e9d4e2 编写于 作者: J Jialin Qiao 提交者: GitHub

fix auto create bool type (#534)

上级 bd299243
...@@ -330,7 +330,7 @@ watermark_method=GroupBasedLSBMethod(embed_row_cycle=2,embed_lsb_num=5) ...@@ -330,7 +330,7 @@ watermark_method=GroupBasedLSBMethod(embed_row_cycle=2,embed_lsb_num=5)
#################### ####################
# Whether creating schema automatically is enabled # 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 # Storage group level when creating schema automatically is enabled
# e.g. root.sg0.d1.s2 # e.g. root.sg0.d1.s2
......
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
package org.apache.iotdb.db.utils; package org.apache.iotdb.db.utils;
import org.apache.iotdb.db.qp.constant.SQLConstant;
import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType; import org.apache.iotdb.tsfile.file.metadata.enums.TSDataType;
public class TypeInferenceUtils { public class TypeInferenceUtils {
...@@ -27,7 +28,7 @@ public class TypeInferenceUtils { ...@@ -27,7 +28,7 @@ public class TypeInferenceUtils {
} }
public static boolean isNumber(String s) { static boolean isNumber(String s) {
try { try {
Double.parseDouble(s); Double.parseDouble(s);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
...@@ -36,11 +37,16 @@ public class TypeInferenceUtils { ...@@ -36,11 +37,16 @@ public class TypeInferenceUtils {
return true; 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 * Get predicted DataType of the given value
*/ */
public static TSDataType getPredictedDataType(Object value) { public static TSDataType getPredictedDataType(Object value) {
if (value instanceof Boolean) { if (value instanceof Boolean || (value instanceof String && isBoolean((String) value))) {
return TSDataType.BOOLEAN; return TSDataType.BOOLEAN;
} else if (value instanceof Number || (value instanceof String && isNumber((String) value))) { } else if (value instanceof Number || (value instanceof String && isNumber((String) value))) {
String v = String.valueOf(value); String v = String.valueOf(value);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册