On Mon, Feb 21, 2011 at 7:31 PM, Edward Capriolo <edlinuxg...@gmail.com> wrote: > On Mon, Feb 21, 2011 at 6:42 PM, Jay Ramadorai > <jramado...@tripadvisor.com> wrote: >> Does anyone have a way of generating the create table statement for a table >> that is in Hive? I see a jira for >> this https://issues.apache.org/jira/browse/HIVE-967 and it appears that Ed >> Capriolo might have a solution for this. Ed, are you able to share this >> solution? >> My goal is to copy a bunch of Hive tables from one cluster to another. What >> I'd like to do is generate the DDL from one cluster and run it on the other, >> and then use DISTCP with lots of mappers to parallel-copy the table-data >> between the clusters. FYI, my metadata is in Derby. I could backup and >> restore the metadata directories but I dont want a copy of all the tables >> from the source database, only a subset. >> I tried Sqooping the table out of Hive, but it runs into : >> 11/02/21 18:23:50 ERROR manager.SqlManager: Error executing statement: >> java.sql.SQLException: Method not supported >> 11/02/21 18:23:50 ERROR sqoop.Sqoop: Got exception running Sqoop: >> java.lang.NullPointerException >> java.lang.NullPointerException >> at >> com.cloudera.sqoop.hive.TableDefWriter.getCreateTableStmt(TableDefWriter.java:133) >> Apparently the Hive Thrift jdbc driver doesnt support extracting table >> metadata. >> Please feel free to suggest alternative approaches. >> thanks >> Jay >> >> > I do have some code that can generate DML. It is a separate problem > that talks to the metastore (outside of the hive cli). I will throw > the code up in the Jira tomorrow. However the plan for the Jira is to > incorporate this in hive with a show create table. >
Jay, I uploaded my "show create table" program to https://issues.apache.org/jira/browse/HIVE-967. Caveats: This is a program you need to build against hive lib files. Caveats: There are edge cases where this will not produce the correct show table statement (hbase storage handler for example) Caveats: Does actually work though ! Enjoy