You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@drill.apache.org by GitBox <gi...@apache.org> on 2019/01/23 12:52:19 UTC
[GitHub] KazydubB commented on a change in pull request #1614: DRILL-6962:
Function coalesce returns an Error when none of the columns in coalesce
exist in a parquet file
KazydubB commented on a change in pull request #1614: DRILL-6962: Function coalesce returns an Error when none of the columns in coalesce exist in a parquet file
URL: https://github.com/apache/drill/pull/1614#discussion_r250181296
##########
File path: exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestCastFunctions.java
##########
@@ -752,18 +770,59 @@ public void testCastTimeLiteralInFilter() throws Exception {
@Test
public void testCastUntypedNull() throws Exception {
- String[] types = new String[] {
- "BOOLEAN", "INT", "BIGINT", "FLOAT", "DOUBLE", "DATE", "TIME", "TIMESTAMP", "INTERVAL MONTH",
- "INTERVAL YEAR", "VARBINARY", "VARCHAR", "DECIMAL(9)", "DECIMAL(18)", "DECIMAL(28)", "DECIMAL(38)"
- };
String query = "select cast(coalesce(unk1, unk2) as %s) as coal from cp.`tpch/nation.parquet` limit 1";
- for (String type : types) {
+
+ Map<String, Triple<TypeProtos.MinorType, Integer, Integer>> typesMap = createCastTypeMap();
+ for (Map.Entry<String, Triple<TypeProtos.MinorType, Integer, Integer>> entry : typesMap.entrySet()) {
+ String q = String.format(query, entry.getKey());
+
+ TypeProtos.MinorType minorType = entry.getValue().getLeft();
+ int precision = entry.getValue().getMiddle();
+ int scale = entry.getValue().getRight();
+ MaterializedField field = new ColumnBuilder("coal", minorType)
+ .setMode(TypeProtos.DataMode.OPTIONAL)
+ .setPrecisionAndScale(precision, scale)
+ .build();
+ BatchSchema expectedSchema = new SchemaBuilder()
+ .add(field)
+ .build();
+
+ // Validate schema
+ testBuilder()
+ .sqlQuery(q)
+ .schemaBaseLine(expectedSchema)
+ .go();
+
+ // Validate result
testBuilder()
- .sqlQuery(String.format(query, type))
+ .sqlQuery(q)
.unOrdered()
.baselineColumns("coal")
.baselineValues(new Object[] {null})
.go();
}
}
+
+ private static Map<String, Triple<TypeProtos.MinorType, Integer, Integer>> createCastTypeMap() {
+ Map<String, Triple<TypeProtos.MinorType, Integer, Integer>> typesMap = new HashMap<>();
Review comment:
Good point. made `Map<String, TypeProtos.MajorType>` instead.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services