Github user twdsilva commented on a diff in the pull request:

    https://github.com/apache/phoenix/pull/355#discussion_r224207564
  
    --- Diff: 
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java ---
    @@ -1294,7 +1276,272 @@ public void testAddingColumnsToTablesAndViews() 
throws Exception {
                 assertSequenceNumber(schemaName, viewName, 
PTable.INITIAL_SEQ_NUM + 1);
             }
         }
    -   
    +
    +
    +    @Test
    +    public void testModifyingRowTimestampColumnNotAllowedViaAlterTable() 
throws Exception {
    +        try (Connection conn = DriverManager.getConnection(getUrl())) {
    +            conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName +
    +                    " (PK1 DATE NOT NULL, PK2 VARCHAR NOT NULL, KV1 
VARCHAR CONSTRAINT PK PRIMARY KEY(PK1 ROW_TIMESTAMP, PK2)) " + tableDDLOptions);
    +            try {
    +                conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " modify PK1 BIGINT");
    +                fail("Altering table to modify a row_timestamp column 
should fail");
    +            } catch (SQLException e) {
    +                
assertEquals(SQLExceptionCode.DISALLOW_MODIFY_TIMESTAMP_OR_PK_COLUMN.getErrorCode(),
 e.getErrorCode());
    +            }
    +            conn.close();
    +        }
    +    }
    +
    +    @Test
    +    public void testModifyingPKColumnNotAllowedViaAlterTable() throws 
Exception {
    +        try (Connection conn = DriverManager.getConnection(getUrl())) {
    +            conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName +
    +                    " (PK1 DATE NOT NULL PRIMARY KEY, PK2 VARCHAR , KV1 
VARCHAR) " + tableDDLOptions);
    +            try {
    +                conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " modify PK1 BIGINT");
    +                fail("Altering table to modify a PK column should fail");
    +            } catch (SQLException e) {
    +                
assertEquals(SQLExceptionCode.DISALLOW_MODIFY_TIMESTAMP_OR_PK_COLUMN.getErrorCode(),
 e.getErrorCode());
    +            }
    +            conn.close();
    +        }
    +    }
    +
    +    @Test
    +    public void testModifyColumnWithIndexTables() throws Exception {
    +        String schemaName = generateUniqueName();
    +        String baseTableName =  generateUniqueName();
    +        String tableName = schemaName + "." + baseTableName;
    +        Properties props = new Properties();
    +        props.put(QueryServices.IS_NAMESPACE_MAPPING_ENABLED, 
Boolean.toString(true));
    +        try (Connection conn = DriverManager.getConnection(getUrl(), 
props)) {
    +            conn.setAutoCommit(true);
    +            conn.createStatement().execute("CREATE SCHEMA " + schemaName);
    +
    +            conn.createStatement().execute("DROP TABLE IF EXISTS " + 
tableName);
    +            conn.createStatement().execute("CREATE TABLE " + tableName +
    +                    " (ID CHAR(3) NOT NULL, COL1 VARCHAR(5), COL2 
VARCHAR(3), COL3 CHAR(4), COL4 CHAR(4)"
    +                    + " CONSTRAINT PKVIEW PRIMARY KEY(ID, COL1)) " + 
tableDDLOptions);
    +            conn.createStatement().execute("CREATE INDEX IDX_COL2 ON "+ 
tableName + "(COL2) INCLUDE(COL3, COL4)");
    +
    +            conn.createStatement().executeUpdate("UPSERT INTO " + 
tableName + " VALUES('123','12345','123','1234','1444')");
    +
    +            //Increasing char length
    +            conn.createStatement().execute("ALTER TABLE " + tableName + " 
modify COL3 CHAR(6)");
    --- End diff --
    
    Can you also test for increasing the length of an indexed column? Also can 
you please add a comment saying that this is supported because we convert fixed 
length columns to variable length while creating the index.


---

Reply via email to