leaves12138 commented on code in PR #2368: URL: https://github.com/apache/incubator-paimon/pull/2368#discussion_r1405703538
########## docs/content/migration/migration-from-hive.md: ########## @@ -0,0 +1,80 @@ +--- +title: "Migration From Hive" +weight: 1 +type: docs +aliases: +- /migration/migration-from-hive.html +--- +<!-- +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. +--> + +# Hive Table Migration + +Apache Hive supports ORC, Parquet file formats that could be migrated to Paimon. +When migrating data to a paimon table, the origin table will be permanently disappeared. So please back up your data if you +still need the original table. The migrated table will be [unware-bucket append-only table]({{< ref "concepts/append-only-table#append-for-scalable-table" >}}). + +Now, we can use flink generic catalog with Migrate Table Procedure and Migrate File Procedure to totally migrate a table from hive to paimon. Review Comment: done ########## paimon-flink/paimon-flink-common/src/main/java/org/apache/paimon/flink/procedure/MigrateTableProcedure.java: ########## @@ -0,0 +1,108 @@ +/* + * 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.paimon.flink.procedure; + +import org.apache.paimon.CoreOptions; +import org.apache.paimon.catalog.Identifier; +import org.apache.paimon.flink.FlinkCatalogFactory; +import org.apache.paimon.utils.ParameterUtils; + +import org.apache.flink.table.api.EnvironmentSettings; +import org.apache.flink.table.api.internal.TableEnvironmentImpl; +import org.apache.flink.table.catalog.CatalogTable; +import org.apache.flink.table.catalog.CatalogTableImpl; +import org.apache.flink.table.catalog.ObjectPath; +import org.apache.flink.table.catalog.ResolvedCatalogTable; +import org.apache.flink.table.catalog.ResolvedSchema; +import org.apache.flink.table.procedure.ProcedureContext; + +import java.util.HashMap; +import java.util.Map; + +import static org.apache.flink.table.factories.FactoryUtil.CONNECTOR; + +/** Migrate procedure to migrate hive table to paimon table. */ +public class MigrateTableProcedure extends GenericProcedureBase { + + private static final String BACK_SUFFIX = "_backup_"; + + @Override + public String identifier() { + return "migrate_table"; + } + + public String[] call(ProcedureContext procedureContext, String sourceTablePath) + throws Exception { + return call(procedureContext, sourceTablePath, ""); + } + + public String[] call( + ProcedureContext procedureContext, String sourceTablePath, String properties) + throws Exception { + TableEnvironmentImpl tableEnvironment = + TableEnvironmentImpl.create(EnvironmentSettings.inBatchMode()); + Identifier sourceTableId = Identifier.fromString(sourceTablePath); + + CatalogTable sourceFlinkTable = Review Comment: done -- 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]
