y0908105023 commented on PR #6650:
URL: https://github.com/apache/hudi/pull/6650#issuecomment-1243290760

   `package org.apache.flink.hudi;
   
   import org.apache.flink.configuration.Configuration;
   import org.apache.flink.configuration.RestOptions;
   import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
   import org.apache.flink.table.api.EnvironmentSettings;
   import org.apache.flink.table.api.bridge.java.StreamTableEnvironment;
   
   public class HudiWrite {
   
       public static void main(String[] args) {
   
           Configuration config = new Configuration();
           config.setInteger(RestOptions.PORT, 8081);
           config.setString("metrics.system-resource", "true");
           StreamExecutionEnvironment env = 
StreamExecutionEnvironment.getExecutionEnvironment(config);
           EnvironmentSettings settings = EnvironmentSettings.newInstance()
                   .inStreamingMode()
                   .build();
           env.setParallelism(1);
           StreamTableEnvironment tEnv = StreamTableEnvironment.create(env, 
settings);
           env.enableCheckpointing(10000);
   
           String hudiSql = "CREATE TABLE IF NOT EXISTS hudi (\n" +
                   "  `aa` STRING,`bb` BIGINT,`cc` DECIMAL(10,2),`dd` DATE,`ff` 
TIMESTAMP(6),PRIMARY KEY (aa,bb) NOT ENFORCED\n" +
                   ")\n" +
                   "  PARTITIONED BY (`dd`)\n" +
                   "with (\n" +
                   "  \n" +
                   "  'connector' = 'hudi',\n" +
                   "  'path' = 
'hdfs://yangshuo7.local:9000/user/hudi//hjh8171/mor_fq_82572',\n" +
                   "  'read.streaming.enabled' = 'true',\n" +
                   "  'table.type' = 'MERGE_ON_READ',\n" +
                   "  'write.tasks' = '1',\n" +
                   "  'changelog.enable' = 'true',\n" +
                   "  'write.operation' = 'upsert',\n" +
                   "  'compaction.async.enabled' = 'true',\n" +
                   "  'hive_sync.enable' = 'true',\n" +
                   "  'hive_sync.mode' = 'hms',\n" +
                   "  'hive_sync.db' = 'hjh8171',\n" +
                   "  'hive_sync.table' = 'mor_fq_82572',\n" +
                   "  'hive_sync.metastore.uris' = 'thrift://localhost:9083'\n" 
+
                   ")";
   
           String mysqlCDCSql = "CREATE TABLE IF NOT EXISTS mysql (\n" +
                   "  `aa` STRING,`bb` BIGINT,`cc` DECIMAL(10,2),`dd` DATE,`ff` 
TIMESTAMP(3),PRIMARY KEY (aa,bb) NOT ENFORCED\n" +
                   ")\n" +
                   "  PARTITIONED BY (`aa`,`dd`)\n" +
                   "with (\n" +
                   " 'connector' = 'mysql-cdc', " +
                   " 'scan.startup.mode' = 'latest-offset', " +
                   " 'hostname' = '127.0.0.1', " +
                   " 'port' = '3306', " +
                   " 'username' = 'root', " +
                   " 'password' = '12345678', " +
                   " 'database-name' = 'flink', " +
                   " 'table-name' = 'all_schema3' " +
                   ")";
   
   
           tEnv.executeSql(mysqlCDCSql);
           tEnv.executeSql(hudiSql);
           tEnv.executeSql("insert into hudi select aa, bb, cc, dd, ff from 
mysql");
       }
   }
   `


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