yanxinyi commented on a change in pull request #558: PHOENIX-5413: Fix union 
all error when exists literal column type.
URL: https://github.com/apache/phoenix/pull/558#discussion_r309491460
 
 

 ##########
 File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/UnionAllIT.java
 ##########
 @@ -1065,4 +1065,41 @@ public void testCoerceExpr() throws Exception {
             conn.close();
         }
     }
+
+    @Test
+    public void testUnionAllWithLiteralColumn() throws Exception {
+        String tableName1 = generateUniqueName();
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        Connection conn = DriverManager.getConnection(getUrl(), props);
+        conn.setAutoCommit(false);
+
+        try {
+            String ddl = "CREATE TABLE " + tableName1 + " " +
+                    "  (id varchar not null, col1 varchar" +
+                    "  CONSTRAINT pk PRIMARY KEY (id))\n";
+            createTestTable(getUrl(), ddl);
+
+            String dml = "UPSERT INTO " + tableName1 + " VALUES(?, ?)";
+            PreparedStatement stmt = conn.prepareStatement(dml);
+            stmt.setString(1, "a");
+            stmt.setString(2, "11111");
+            stmt.execute();
+            conn.commit();
+
+            String unionAll = "select id, col1 from " + tableName1 + " union 
all select 'b' id, '2' col1";
+            String select  = "select t.id, case when t.col1='11111' then 'yes' 
else 'no' end c from ( " + unionAll + " ) t";
 
 Review comment:
   Maybe reformat SQL here

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to