This is an automated email from the ASF dual-hosted git repository.
morrysnow pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 5265f5142f [fix](Nereids) add string and character type (#16044)
5265f5142f is described below
commit 5265f5142f8f6a260646f290c90dae4804b4d378
Author: 谢健 <[email protected]>
AuthorDate: Wed Jan 18 17:27:45 2023 +0800
[fix](Nereids) add string and character type (#16044)
---
.../src/main/java/org/apache/doris/nereids/types/DataType.java | 5 +++--
.../test/java/org/apache/doris/nereids/types/DataTypeTest.java | 8 ++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
index a649352a8a..c2fa66638d 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/nereids/types/DataType.java
@@ -244,6 +244,7 @@ public abstract class DataType implements AbstractDataType {
default:
throw new AnalysisException("Nereids do not support
type: " + type);
}
+ case "character":
case "char":
switch (types.size()) {
case 1:
@@ -335,8 +336,6 @@ public abstract class DataType implements AbstractDataType {
return FloatType.INSTANCE;
} else if (type == Type.DOUBLE) {
return DoubleType.INSTANCE;
- } else if (type == Type.STRING) {
- return StringType.INSTANCE;
} else if (type.isNull()) {
return NullType.INSTANCE;
} else if (type.isDatetimeV2()) {
@@ -361,6 +360,8 @@ public abstract class DataType implements AbstractDataType {
return CharType.createCharType(type.getLength());
} else if (type.getPrimitiveType() ==
org.apache.doris.catalog.PrimitiveType.VARCHAR) {
return VarcharType.createVarcharType(type.getLength());
+ } else if (type.getPrimitiveType() ==
org.apache.doris.catalog.PrimitiveType.STRING) {
+ return StringType.INSTANCE;
} else if (type.isDecimalV3()) {
ScalarType scalarType = (ScalarType) type;
int precision = scalarType.getScalarPrecision();
diff --git
a/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
b/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
index aa63e09f03..9649a04825 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/nereids/types/DataTypeTest.java
@@ -17,6 +17,7 @@
package org.apache.doris.nereids.types;
+import org.apache.doris.catalog.Type;
import org.apache.doris.common.Config;
import org.junit.jupiter.api.Assertions;
@@ -53,6 +54,11 @@ public class DataTypeTest {
Assertions.assertNotEquals(varcharType1.hashCode(),
varcharType3.hashCode());
}
+ @Test
+ void testFromPrimitiveType() {
+ Assertions.assertEquals(DataType.fromCatalogType(Type.STRING),
StringType.INSTANCE);
+ }
+
@Test
void testConvertFromString() {
// boolean
@@ -84,6 +90,8 @@ public class DataTypeTest {
Assertions.assertEquals(StringType.INSTANCE,
DataType.convertFromString("string"));
// char
Assertions.assertEquals(CharType.createCharType(10),
DataType.convertFromString("char(10)"));
+ Assertions.assertEquals(CharType.createCharType(10),
DataType.convertFromString("character(10)"));
+
// varchar
Assertions.assertEquals(VarcharType.createVarcharType(10),
DataType.convertFromString("varchar(10)"));
// null
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]