[ 
https://issues.apache.org/jira/browse/PHOENIX-4815?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16621205#comment-16621205
 ] 

Josh Elser commented on PHOENIX-4815:
-------------------------------------

{code:java}
+    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");{code}
Failure message is wrong (copy paste from the other test method)
{code:java}
+            MetaDataMutationResult result = 
connection.getQueryServices().modifyColumn(tableMetaData, table);
+            if (result.getMutationCode() == MutationCode.TABLE_ALREADY_EXISTS) 
{
+                logger.info(oldColumn.getName().getString() + " is modified 
successfully!");
+                addTableToCache(result);
+                if (result.getMutatedTableNames() != null) {
+                    long resolvedTime = 
TransactionUtil.getResolvedTime(connection, result);
+                    for (byte[] name : result.getMutatedTableNames()) {
+                        String schema = 
SchemaUtil.getSchemaNameFromFullName(name);
+                        String tableName = 
SchemaUtil.getTableNameFromFullName(name);
+                        connection.removeTable(connection.getTenantId(),  
SchemaUtil.getTableName(schema, tableName), null, resolvedTime);
+                    }
+                }
+            }
+            return new MutationState(0, 0, connection);{code}
This looks weird to me. We don't have a MutationCode for the positive execution 
of this call? Also, we don't throw an error if the modifyColumn fails?

Take this all with a grain of salt – this isn't my area of expertise with 
Phoenix. Maybe [~tdsilva] would have some input?

> support alter table modify column 
> ----------------------------------
>
>                 Key: PHOENIX-4815
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-4815
>             Project: Phoenix
>          Issue Type: Improvement
>    Affects Versions: 4.12.0
>            Reporter: Jaanai
>            Assignee: Jaanai
>            Priority: Major
>         Attachments: PHOENIX-4815.patch
>
>
> if we want to change max length or scale of  fields of  variable length type( 
>  example for :varchar, char and decimal type etc),  we can not drop column to 
> recreate new column when the table has massive data,  which may affects 
> online service,meanwhile, it is also very expensive. so sometimes this 
> function is very useful.
> Taking ORACLE dialect as an reference 
> {code:java}
> alter table
>    table_name
> modify
>    column_name  datatype;
> {code}
> reference link: 
> https://docs.oracle.com/cd/B28359_01/server.111/b28286/statements_3001.htm#i2103956



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to