aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rw-r--r--common/src/main/java/org/apache/drill/common/types/Types.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/common/src/main/java/org/apache/drill/common/types/Types.java b/common/src/main/java/org/apache/drill/common/types/Types.java
index 8ae3edda2..04fec54ac 100644
--- a/common/src/main/java/org/apache/drill/common/types/Types.java
+++ b/common/src/main/java/org/apache/drill/common/types/Types.java
@@ -18,7 +18,9 @@
package org.apache.drill.common.types;
import static org.apache.drill.common.types.TypeProtos.DataMode.REPEATED;
+import static org.apache.drill.common.types.TypeProtos.MinorType.*;
+import org.apache.drill.common.exceptions.DrillRuntimeException;
import org.apache.drill.common.types.TypeProtos.DataMode;
import org.apache.drill.common.types.TypeProtos.MajorType;
import org.apache.drill.common.types.TypeProtos.MinorType;
@@ -370,6 +372,57 @@ public class Types {
}
}
+ public static String getNameOfMinorType(MinorType type) {
+ switch (type) {
+ case BIT:
+ return "bool";
+ case TINYINT:
+ return "tinyint";
+ case UINT1:
+ return "uint1";
+ case SMALLINT:
+ return "smallint";
+ case UINT2:
+ return "uint2";
+ case INT:
+ return "int";
+ case UINT4:
+ return "uint4";
+ case BIGINT:
+ return "bigint";
+ case UINT8:
+ return "uint8";
+ case FLOAT4:
+ return "float";
+ case FLOAT8:
+ return "double";
+ case DECIMAL9:
+ return "decimal";
+ case DECIMAL18:
+ return "decimal";
+ case DECIMAL28SPARSE:
+ return "decimal";
+ case DECIMAL38SPARSE:
+ return "decimal";
+ case VARCHAR:
+ return "varchar";
+ case VAR16CHAR:
+ return "utf16";
+ case DATE:
+ return "date";
+ case TIME:
+ return "time";
+ case TIMESTAMP:
+ return "timestamp";
+ case VARBINARY:
+ return "binary";
+ case LATE:
+ throw new DrillRuntimeException("The late type should never appear in execution or an SQL query, so it does not have a name to refer to it.");
+ default:
+ throw new DrillRuntimeException("Unrecognized type " + type);
+ }
+ }
+
public static String toString(MajorType type) {
return type != null ? "MajorType[" + TextFormat.shortDebugString(type) + "]" : "null";
}