gokceni commented on a change in pull request #1366:
URL: https://github.com/apache/phoenix/pull/1366#discussion_r770897352



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/schema/transform/Transform.java
##########
@@ -71,14 +87,150 @@ public static void addTransform(PhoenixConnection 
connection, String tenantId, P
                 newPhysicalTableName = generateNewTableName(schema, 
logicalTableName, sequenceNum);
             }
             transformBuilder.setNewPhysicalTableName(newPhysicalTableName);
-            Transform.addTransform(transformBuilder.build(), connection);
+            Transform.addTransform(table, changingProperties, 
transformBuilder.build(), connection);
         } catch (JsonProcessingException ex) {
             LOGGER.error("addTransform failed", ex);
             throw new SQLException("Adding transform failed with 
JsonProcessingException");
+        } catch (SQLException ex) {
+            throw ex;
+        } catch(Exception ex) {
+            throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.valueOf("CANNOT_MUTATE_TABLE"))
+                    .setSchemaName((table.getSchemaName() == null? null: 
table.getSchemaName().getString()))
+                    .setRootCause(ex)
+                    
.setTableName(table.getName().getString()).build().buildException();
         }
     }
 
-    public static void addTransform(
+    protected static void addTransform(
+            PTable table, MetaDataClient.MetaProperties changedProps, 
SystemTransformRecord systemTransformParams, PhoenixConnection connection) 
throws Exception {
+        PName newTableName = 
PNameFactory.newName(systemTransformParams.getNewPhysicalTableName());
+        PName newTableNameWithoutSchema = 
PNameFactory.newName(SchemaUtil.getTableNameFromFullName(systemTransformParams.getNewPhysicalTableName()));
+        PTable newTable = new PTableImpl.Builder()
+                .setTableName(newTableNameWithoutSchema)
+                .setParentTableName(table.getParentTableName())
+                .setBaseTableLogicalName(table.getBaseTableLogicalName())
+                .setPhysicalTableName(newTableNameWithoutSchema)
+                .setAllColumns(table.getColumns())
+                .setAppendOnlySchema(table.isAppendOnlySchema())
+                .setAutoPartitionSeqName(table.getAutoPartitionSeqName())
+                .setBaseColumnCount(table.getBaseColumnCount())
+                .setBucketNum(table.getBucketNum())
+                .setDefaultFamilyName(table.getDefaultFamilyName())
+                .setDisableWAL(table.isWALDisabled())
+                .setEstimatedSize(table.getEstimatedSize())
+                .setFamilies(table.getColumnFamilies())
+                .setImmutableRows(table.isImmutableRows())
+                .setIsChangeDetectionEnabled(table.isChangeDetectionEnabled())
+                .setIndexType(table.getIndexType())
+                .setName(newTableName)
+                .setMultiTenant(table.isMultiTenant())
+                .setParentName(table.getParentName())
+                .setParentSchemaName(table.getParentSchemaName())
+                .setPhoenixTTL(table.getPhoenixTTL())
+                .setNamespaceMapped(table.isNamespaceMapped())
+                .setSchemaName(table.getSchemaName())
+                .setPkColumns(table.getPKColumns())
+                .setPkName(table.getPKName())
+                .setPhoenixTTLHighWaterMark(table.getPhoenixTTLHighWaterMark())
+                .setRowKeySchema(table.getRowKeySchema())
+                .setStoreNulls(table.getStoreNulls())
+                .setTenantId(table.getTenantId())
+                .setType(table.getType())
+                // SchemaExtractor uses physical name to get the table 
descriptor from. So we use the existing table here
+                
.setPhysicalNames(ImmutableList.copyOf(table.getPhysicalNames()))
+                .setUpdateCacheFrequency(table.getUpdateCacheFrequency())
+                .setTransactionProvider(table.getTransactionProvider())
+                
.setUseStatsForParallelization(table.useStatsForParallelization())
+                // TODO SET SCHEMAVERSION
+                // Transformables
+                .setImmutableStorageScheme(
+                        (changedProps.getImmutableStorageSchemeProp() != null? 
changedProps.getImmutableStorageSchemeProp():table.getImmutableStorageScheme()))
+                .setQualifierEncodingScheme(
+                        (changedProps.getColumnEncodedBytesProp() != null? 
changedProps.getColumnEncodedBytesProp() : table.getEncodingScheme()))
+                .build();

Review comment:
       Noted




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to