aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorJason Altekruse <altekrusejason@gmail.com>2014-11-04 17:05:35 -0800
committerJason Altekruse <altekrusejason@gmail.com>2014-11-28 22:28:24 -0800
commit1a9543f6707290007779b6b7e3746ff05d882c4f (patch)
tree6417366820d333cb6715afe194326adf6585a39c /common
parent1944b434d7f2ac047d5ca188f14a784da37ce8c6 (diff)
DRILL-1458: New unit test framework.
Review comments, cleanup, additional tests Matching columns, throw useful error messages if there are missing or extra columns. Few more features in unit test framework, providing several baseline records in the builder pattern, allow checking empty result. Added a new unit test to ensure that nulls were validated properly in both the ordered and unordered cases.
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";
}