You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by el...@apache.org on 2018/07/25 22:34:47 UTC

[09/50] [abbrv] phoenix git commit: PHOENIX-4728 ARRAY_APPEND and ARRAY_REMOVE should work with null column value (Xavier Jodoin)

PHOENIX-4728 ARRAY_APPEND and ARRAY_REMOVE should work with null column value (Xavier Jodoin)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/9335972f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/9335972f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/9335972f

Branch: refs/heads/4.x-HBase-1.4
Commit: 9335972fb1d231f9ff1cce8b55ca5753149cba2c
Parents: 8d80d5a
Author: James Taylor <jt...@salesforce.com>
Authored: Fri May 25 09:36:41 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Fri May 25 09:39:35 2018 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/ArrayAppendFunctionIT.java  | 38 ++++++++++++++++++++
 .../apache/phoenix/compile/UpsertCompiler.java  |  2 +-
 2 files changed, 39 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9335972f/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java
index caa17fe..7962a7a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayAppendFunctionIT.java
@@ -132,6 +132,24 @@ public class ArrayAppendFunctionIT extends ParallelStatsDisabledIT {
     }
     
     @Test
+    public void testUpsertEmptyArrayModification() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        String tableName = initTables(conn);
+
+        ResultSet rs;
+        String[] strings = new String[]{"34567"};
+        Array array = conn.createArrayOf("VARCHAR", strings);
+
+        conn.createStatement().execute("UPSERT INTO " + tableName + " (region_name,nullVarChar) SELECT region_name,ARRAY_APPEND(nullVarChar,'34567') FROM " + tableName);
+        conn.commit();
+        
+        rs = conn.createStatement().executeQuery("SELECT nullVarChar FROM " + tableName + " LIMIT 1");
+        assertTrue(rs.next());
+        assertEquals(array, rs.getArray(1));
+        assertFalse(rs.next());
+    }
+    
+    @Test
     public void testArrayAppendFunctionVarchar() throws Exception {
         Connection conn = DriverManager.getConnection(getUrl());
         String tableName = initTables(conn);
@@ -147,6 +165,26 @@ public class ArrayAppendFunctionIT extends ParallelStatsDisabledIT {
         assertEquals(array, rs.getArray(1));
         assertFalse(rs.next());
     }
+    
+    @Test
+    public void testUpsertArrayAppendFunctionVarchar() throws Exception {
+        Connection conn = DriverManager.getConnection(getUrl());
+        String tableName = initTables(conn);
+
+        conn.createStatement().execute("UPSERT INTO " + tableName + " (region_name,varchars) SELECT region_name,ARRAY_APPEND(varchars,'34567') as varchars FROM " + tableName+ " WHERE region_name = 'SF Bay Area'");
+        conn.commit();
+        
+        ResultSet rs;
+        rs = conn.createStatement().executeQuery("SELECT varchars FROM " + tableName + " WHERE region_name = 'SF Bay Area'");
+        assertTrue(rs.next());
+
+        String[] strings = new String[]{"2345", "46345", "23234", "34567"};
+
+        Array array = conn.createArrayOf("VARCHAR", strings);
+
+        assertEquals(array, rs.getArray(1));
+        assertFalse(rs.next());
+    }
 
     @Test
     public void testArrayAppendFunctionInteger() throws Exception {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/9335972f/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index 30f0c18..c3cfa10 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -549,7 +549,7 @@ public class UpsertCompiler {
             select = SelectStatement.create(select, hint);
             // Pass scan through if same table in upsert and select so that projection is computed correctly
             // Use optimizer to choose the best plan
-            QueryCompiler compiler = new QueryCompiler(statement, select, selectResolver, targetColumns, parallelIteratorFactoryToBe, new SequenceManager(statement), false, false, null);
+            QueryCompiler compiler = new QueryCompiler(statement, select, selectResolver, targetColumns, parallelIteratorFactoryToBe, new SequenceManager(statement), true, false, null);
             queryPlanToBe = compiler.compile();
             // This is post-fix: if the tableRef is a projected table, this means there are post-processing
             // steps and parallelIteratorFactory did not take effect.