Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9140007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:27:35+00:00 2026-06-17T09:27:35+00:00

Given a SQL script containing DDL for creating tables in MySQL database, I would

  • 0

Given a SQL script containing DDL for creating tables in MySQL database, I would like to convert the script into Hive DDL, so that I can create tables into hive. I could have written an interpreter myself, but thought there might be details I could miss (e.g. data format conversion, int, bigint, time, date, etc.) since I am very new to hive DDL.

I have seen this thread How to transfer mysql table to hive?, which mentioned sqoop http://archive.cloudera.com/cdh/3/sqoop/SqoopUserGuide.html. However, from what I see, sqoop certainly translate the DDL, but only as an intermediate step (thus the translated DDL is no where to be found). Am I missing the command that would output the translation with the MySQL DDL as an input?

For example, my MySQL DDL look like:

CREATE TABLE `user_keyword` (
  `username` varchar(32) NOT NULL DEFAULT '',
  `keyword_id` int(10) unsigned NOT NULL,
  PRIMARY KEY (`username`,`keyword_id`),
  KEY `keyword_id` (`keyword_id`),
  CONSTRAINT `analyst_keywords_ibfk_1` FOREIGN KEY (`keyword_id`) REFERENCES `keywords` (`keyword_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

And the output Hive DDL would be like:

CREATE TABLE user_keyword (
  username string,
  keyword_id int,
);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:27:36+00:00Added an answer on June 17, 2026 at 9:27 am

    I actually thought this was not supported, but after looking at the Source here is what I saw in HiveImport.java:

    /**
     * @return true if we're just generating the DDL for the import, but
     * not actually running it (i.e., --generate-only mode). If so, don't
     * do any side-effecting actions in Hive.
     */
    private boolean isGenerateOnly() {
      return generateOnly;
    }
    
    /**
     * @return a File object that can be used to write the DDL statement.
     * If we're in gen-only mode, this should be a file in the outdir, named
     * after the Hive table we're creating. If we're in import mode, this should
     * be a one-off temporary file.
     */
    private File getScriptFile(String outputTableName) throws IOException {
      if (!isGenerateOnly()) {
        return File.createTempFile("hive-script-", ".txt",
            new File(options.getTempDir()));
      } else {
        return new File(new File(options.getCodeOutputDir()),
            outputTableName + ".q");
      }
    }
    

    So basically you should be able to do only the DDL generation using the option --generate-only used in cunjunction with --outdir and your table will be create in the output dir specified and named after your table.

    For example based on the link you provided:

    sqoop import --verbose --fields-terminated-by ',' --connect jdbc:mysql://localhost/test --table employee --hive-import --warehouse-dir /user/hive/warehouse --fields-terminated-by ',' --split-by id --hive-table employee --outdir /tmp/mysql_to_hive/ddl --generate-only
    

    will create /tmp/mysql_to_hive/ddl/employee.q

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given some arbitrary SQL I would like to get the data types of the
We recently had some issues where a sql script that would remove duplicate entries
Given a large input file that looks like this: 02/26/2012 08:54:38 Error:java.sql.Exception 02/26/2012 08:54:48
Let's say that I have a sql script that looks like this: --split statement
Given SQL as an input, I have to query a PostgreSQL database and return
Given this SQL: SELECT * FROM mytable ORDER BY mycolumn, RAND() Assuming that mycolumn
Question: Given a SQL string like CREATE VIEW TestView AS SELECT value1, value2 FROM
Given the follwing: SQL Tables: Names ----- Id (int) FirstName (varchar) LastName (varchar) NameProperties
Given the following schema / data / output how would I format a SQL
In a SQL Server 2008 R2 database, given this schema: AgentsAccounts _______________ AgentID int

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.