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



##########
File path: 
phoenix-core/src/main/java/org/apache/phoenix/schema/transform/Transform.java
##########
@@ -0,0 +1,220 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.phoenix.schema.transform;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.phoenix.thirdparty.com.google.common.base.Strings;
+import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
+import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
+import org.apache.phoenix.schema.MetaDataClient;
+import org.apache.phoenix.schema.PTable;
+import org.apache.phoenix.util.JacksonUtil;
+import org.apache.phoenix.util.SchemaUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+
+import static org.apache.phoenix.schema.PTableType.INDEX;
+
+public class Transform {
+    public static final Logger LOGGER = 
LoggerFactory.getLogger(Transform.class);
+
+    private static String generateNewTableName(String schema, String 
logicalTableName, long seqNum) {
+        // TODO: Support schema versioning as well.
+        String newName = String.format("%s_%d", 
SchemaUtil.getTableName(schema, logicalTableName), seqNum);
+        return newName;
+    }
+
+    public static void addTransform(PhoenixConnection connection, String 
tenantId, PTable table,
+                                    MetaDataClient.MetaProperties 
changingProperties, long sequenceNum,
+                                    PTable.TransformType transformType) throws 
SQLException {
+        try {
+            String newMetadata = 
JacksonUtil.getObjectWriter().writeValueAsString(changingProperties);
+            String oldMetadata = "";
+            String newPhysicalTableName = "";
+            SystemTransformRecord.SystemTransformBuilder transformBuilder = 
new SystemTransformRecord.SystemTransformBuilder();
+            String schema = table.getSchemaName()!=null ? 
table.getSchemaName().getString() : null;
+            String logicalTableName = table.getTableName().getString();
+            transformBuilder.setSchemaName(schema);
+            transformBuilder.setLogicalTableName(logicalTableName);
+            transformBuilder.setTenantId(tenantId);
+            if (table.getType() == INDEX) {
+                
transformBuilder.setLogicalParentName(table.getParentName().getString());
+            }
+            // TODO: add more ways of finding out what transform type this is
+            transformBuilder.setTransformType(transformType);
+            // TODO: calculate old and new metadata
+            transformBuilder.setNewMetadata(newMetadata);
+            transformBuilder.setOldMetadata(oldMetadata);
+            if (Strings.isNullOrEmpty(newPhysicalTableName)) {

Review comment:
       yes




-- 
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