You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@drill.apache.org by "Akihiko Kusanagi (JIRA)" <ji...@apache.org> on 2015/12/27 16:20:49 UTC

[jira] [Created] (DRILL-4227) UNION ALL or UNION of tables derived from VALUES clause return incorrect results

Akihiko Kusanagi created DRILL-4227:
---------------------------------------

             Summary: UNION ALL or UNION of tables derived from VALUES clause return incorrect results
                 Key: DRILL-4227
                 URL: https://issues.apache.org/jira/browse/DRILL-4227
             Project: Apache Drill
          Issue Type: Bug
          Components: Query Planning & Optimization
    Affects Versions: 1.4.0
            Reporter: Akihiko Kusanagi
            Priority: Critical


The following UNION ALL and UNION queries return incorrect results:
{noformat}
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES('ab')) AS a(col)
. . . . . . . . . . . > UNION ALL
. . . . . . . . . . . > SELECT b.col FROM (VALUES('bc')) AS b(col);
+------+
| col  |
+------+
| bc   |
| bc   |
+------+
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES('ab')) AS a(col) 
. . . . . . . . . . . > UNION
. . . . . . . . . . . > SELECT b.col FROM (VALUES('bc')) AS b(col);
+------+
| col  |
+------+
| bc   |
+------+
{noformat}
The same is true for numeric values:
{noformat}
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES(100)) AS a(col) 
. . . . . . . . . . . > UNION ALL
. . . . . . . . . . . > SELECT b.col FROM (VALUES(200)) AS b(col);
+------+
| col  |
+------+
| 200  |
| 200  |
+------+
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES(100)) AS a(col) 
. . . . . . . . . . . > UNION
. . . . . . . . . . . > SELECT b.col FROM (VALUES(200)) AS b(col);
+------+
| col  |
+------+
| 200  |
+------+
{noformat}
However, if those strings have different length, the queries work correctly:
{noformat}
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES('ab')) AS a(col) 
. . . . . . . . . . . > UNION ALL
. . . . . . . . . . . > SELECT b.col FROM (VALUES('abc')) AS b(col);
+------+
| col  |
+------+
| ab   |
| abc  |
+------+
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES('ab')) AS a(col) 
. . . . . . . . . . . > UNION
. . . . . . . . . . . > SELECT b.col FROM (VALUES('abc')) AS b(col);
+------+
| col  |
+------+
| ab   |
| abc  |
+------+
{noformat}
If the numeric values have different bit length, the queries work correctly:
{noformat}
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES(100)) AS a(col) 
. . . . . . . . . . . > UNION ALL
. . . . . . . . . . . > SELECT b.col FROM (VALUES(2147483648)) AS b(col);
+-------------+
|     col     |
+-------------+
| 100         |
| 2147483648  |
+-------------+
0: jdbc:drill:zk=local> SELECT a.col FROM (VALUES(100)) AS a(col) 
. . . . . . . . . . . > UNION
. . . . . . . . . . . > SELECT b.col FROM (VALUES(2147483648)) AS b(col);
+-------------+
|     col     |
+-------------+
| 100         |
| 2147483648  |
+-------------+
{noformat}
All the queries above have the same plan:
{noformat}
00-00    Screen
00-01      Project(col=[$0])
00-02        UnionAll(all=[true])
00-04          Values
00-03          Values
{noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)