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

    https://github.com/apache/phoenix/pull/355#discussion_r224466632
  
    --- 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);
    --- End diff --
    
    ok


---

Reply via email to