You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/09/16 04:57:08 UTC

[GitHub] [phoenix] priyankporwal commented on a change in pull request #864: PHOENIX-5261: Implement ALTER TABLE ADD COLUMN CASCADE

priyankporwal commented on a change in pull request #864:
URL: https://github.com/apache/phoenix/pull/864#discussion_r489161430



##########
File path: phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterAddCascadeIndexIT.java
##########
@@ -0,0 +1,339 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.end2end;
+
+import org.apache.phoenix.schema.PTableType;
+import org.apache.phoenix.schema.types.PChar;
+import org.apache.phoenix.schema.types.PDouble;
+import org.apache.phoenix.schema.types.PFloat;
+import org.apache.phoenix.schema.types.PVarchar;
+import org.apache.phoenix.util.ColumnInfo;
+import org.apache.phoenix.util.SchemaUtil;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Properties;
+
+import static org.apache.phoenix.schema.MetaDataClient.INCORRECT_INDEX_NAME_S;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(Parameterized.class)
+public class AlterAddCascadeIndexIT extends ParallelStatsDisabledIT {
+
+    public static final String SYNTAX_ERROR = "Syntax error";
+    @Rule
+    public ExpectedException exception = ExpectedException.none();
+    private static Connection conn;
+    private Properties prop;
+    private boolean isViewIndex;
+    private String phoenixObjectName;
+    private String indexesName;
+    private final String tableDDLOptions;
+
+
+    public AlterAddCascadeIndexIT(boolean isViewIndex, boolean mutable) {
+        this.isViewIndex = isViewIndex;
+        StringBuilder optionBuilder = new StringBuilder();
+        if (!mutable) {
+            optionBuilder.append(" IMMUTABLE_ROWS=true");
+        }
+        this.tableDDLOptions = optionBuilder.toString();
+    }
+
+    @Parameters(name="AlterAddCascadeIndexIT_isViewIndex={0},mutable={1}")
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] {
+                { true, true},
+                { true, false},
+                { false, true},
+                { false, false},
+        });
+    }
+
+    @Before
+    public void setup() throws SQLException {
+        prop = new Properties();
+        conn = DriverManager.getConnection(getUrl(), prop);
+        conn.setAutoCommit(true);
+        conn.createStatement().execute("CREATE TABLE IF NOT EXISTS test.us_population (\n" +
+                "      state CHAR(2) NOT NULL,\n" +
+                "      city VARCHAR NOT NULL,\n" +
+                "      population BIGINT,\n" +
+                "      CONSTRAINT my_pk PRIMARY KEY (state, city)) " + tableDDLOptions);
+
+        if(isViewIndex) {
+            conn.createStatement().execute("CREATE VIEW IF NOT EXISTS test.us_population_gv" +
+                    "(city_area INTEGER, avg_fam_size INTEGER) AS " +
+                    "SELECT * FROM test.us_population WHERE state = 'CA'");
+
+            conn.createStatement().execute("CREATE INDEX IF NOT EXISTS us_population_gv_gi ON " +
+                    "test.us_population_gv (city_area) INCLUDE (population)");
+            conn.createStatement().execute("CREATE INDEX IF NOT EXISTS us_population_gv_gi_2 ON " +
+                    "test.us_population_gv (avg_fam_size) INCLUDE (population)");
+            phoenixObjectName = "test.us_population_gv";
+            indexesName = "us_population_gv_gi, us_population_gv_gi_2";
+        } else {
+            conn.createStatement().execute("CREATE INDEX IF NOT EXISTS us_population_gi ON " +
+                    "test.us_population (population)");
+            conn.createStatement().execute("CREATE INDEX IF NOT EXISTS us_population_gi_2 ON " +
+                    "test.us_population (state, population)");
+            phoenixObjectName = "test.us_population";
+            indexesName = "us_population_gi, us_population_gi_2";
+        }
+    }
+
+    // Test with ALTER TABLE CASCADE INDEX ALL

Review comment:
       Nit: The comment here and line 134 are misleading. The tests are handling both tables and views.




----------------------------------------------------------------
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:
users@infra.apache.org