Github user jaanai0 commented on a diff in the pull request:
https://github.com/apache/phoenix/pull/355#discussion_r220898281
--- 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 --
Sorry, I didn't forget to test these case. I saw that a row of query
results will be compressed a KeyValue which is byte representation of the
`KeyValueSchema`ï¼so this patch will not work, I will initializing a PR again
after fixing the problems.
---