vvysotskyi commented on a change in pull request #2006: DRILL-7615: UNION ALL 
query returns the wrong result for the decimal value
URL: https://github.com/apache/drill/pull/2006#discussion_r388156185
 
 

 ##########
 File path: 
exec/java-exec/src/test/java/org/apache/drill/exec/store/parquet/TestVarlenDecimal.java
 ##########
 @@ -139,8 +145,32 @@ public void testWriteReadCsv() throws Exception {
           .baselineValues(new BigDecimal(bigDecimalValue))
           .go();
     } finally {
-      resetSessionOption(ExecConstants.OUTPUT_FORMAT_OPTION);
-      test("drop table if exists dfs.tmp.%s", tableName);
+      client.resetSession(ExecConstants.OUTPUT_FORMAT_OPTION);
+      run("drop table if exists dfs.tmp.%s", tableName);
+    }
+  }
+
+  @Test
+  public void testUnionAllWithDifferentScales() throws Exception {
+    try {
+      run("create table dfs.tmp.t as select cast(999999999999999 as 
decimal(15,0)) as d");
+
+      String query = "select cast(1000 as decimal(10,1)) as d\n" +
+          "union all \n" +
+          "select 596.000 as d \n" +
+          "union all \n" +
+          "select d from dfs.tmp.t";
+
+      testBuilder()
+          .sqlQuery(query)
+          .unOrdered()
+          .baselineColumns("d")
+          .baselineValues(new BigDecimal("1000.000"))
+          .baselineValues(new BigDecimal("596.000"))
+          .baselineValues(new BigDecimal("999999999999999.000"))
 
 Review comment:
   @arina-ielchiieva, thanks for pointing to the example, initially I tried a 
similar approach, but union operator returns multiple batches, so in the case 
of using `client.queryBuilder().sql(sql).rowSet()`, it will fail with 
(`IllegalStateException`)[https://github.com/apache/drill/blob/09b805aea4dafe50555b23945302cf8f6c491de8/exec/java-exec/src/test/java/org/apache/drill/test/QueryBuilder.java#L359].
 I also tried to use `rowSetIterator()`, as it was advised in the error 
message, but it returns `QueryRowSetIterator` which actually caused 
complications for me. I tried several approaches, one of them is iterating 
through it and comparing separate row sets, which corresponds to returned 
batches, but such a check would look obscure since the first batch was empty.
   So I ended up with the simpler check for schema using `testBuilder()`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to