How to automatically sync a Hive external table with a MySQL table without using Sqoop?

前端 未结 1 1350
梦毁少年i
梦毁少年i 2021-01-16 15:00

I\'m already having a MySQL table in my local machine (Linux) itself, and I have a Hive external table with the same schema as the MySQL table.

I want to sync my hiv

相关标签:
1条回答
  • 2021-01-16 15:29

    Without scoop, you can create table STORED BY JdbcStorageHandler. Project repository: https://github.com/qubole/Hive-JDBC-Storage-Handler It will work as usual hive table, but query will run on MySQL. Predicate pushdown will work.

    DROP TABLE HiveTable;
    CREATE EXTERNAL TABLE HiveTable(
      id INT,
      id_double DOUBLE,
      names STRING,
      test INT
    )
    STORED BY 'org.apache.hadoop.hive.jdbc.storagehandler.JdbcStorageHandler'
    TBLPROPERTIES (
      "mapred.jdbc.driver.class"="com.mysql.jdbc.Driver",
      "mapred.jdbc.url"="jdbc:mysql://localhost:3306/rstore",
      "mapred.jdbc.username"="root",
      "mapred.jdbc.input.table.name"="JDBCTable",
      "mapred.jdbc.output.table.name"="JDBCTable",
      "mapred.jdbc.password"="",
      "mapred.jdbc.hive.lazy.split"= "false"
    );
    
    0 讨论(0)
提交回复
热议问题