Github user twdsilva commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/355#discussion_r220413373
--- Diff:
phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java ---
@@ -1294,7 +1277,162 @@ 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());
+ }
+ }
+ }
+
+ @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 row_timestamp column
should fail");
+ } catch (SQLException e) {
+
assertEquals(SQLExceptionCode.DISALLOW_MODIFY_TIMESTAMP_OR_PK_COLUMN.getErrorCode(),
e.getErrorCode());
+ }
+ }
+ }
+
+ @Test
+ public void testModifyColumn() 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.createStatement().execute("CREATE SCHEMA " + schemaName);
+ PhoenixConnection phxConn =
conn.unwrap(PhoenixConnection.class);
+ conn.createStatement().execute(
--- End diff --
What happens if you decrease the length of a varchar column or decreasing
the scale and/or precision of a decimal column that has existing data?
---