zoukankan      html  css  js  c++  java
  • Flink Sql Client初探

    注: 对应的sql_lib依赖jar,在参考博客的留言下面有

    1、运行f'link sql 

    1、首先进入flink目录,启动flink:bin/start-cluster.sh
    2、其次启动Flink SQL Client:bin/sql-client.sh embedded -l sql_lib

    2、启动界面

     3、测试demo

    DROP TABLE IF  EXISTS  `user`;
    
    CREATE TABLE `user` (
        id INT, 
        name STRING,
        create_time TIMESTAMP(3)
    ) WITH (
        'connector.type' = 'jdbc',
        'connector.url' = 'jdbc:mysql://localhost:3306/test',
        'connector.table' = 'user',
        'connector.driver' = 'com.mysql.jdbc.Driver',
        'connector.username' = 'root',
        'connector.password' = 'root',
        'connector.lookup.cache.max-rows' = '5000',
        'connector.lookup.cache.ttl' = '10min'
    );
    
    CREATE TABLE user_info (
        id INT,
        username STRING,
        password STRING
    ) WITH (
        'connector.type' = 'jdbc',
        'connector.url' = 'jdbc:mysql://localhost:3306/test',
        'connector.table' = 'user_info',
        'connector.driver' = 'com.mysql.jdbc.Driver',
        'connector.username' = 'root',
        'connector.password' = 'root',
        'connector.lookup.cache.max-rows' = '5000',
        'connector.lookup.cache.ttl' = '10min'
    );

    4、执行sql,查看结果

    select u.id,u.name,u.create_time,ui.id,ui.username,ui.password  
    from `user` as u 
    left join user_info as ui 
    on u.id = ui.id;

     

     ===============实现Datax效果========================

    DROP TABLE IF  EXISTS  `user`;
    CREATE TABLE `user` (
        id INT, 
        name STRING,
        create_time TIMESTAMP(3)
    ) WITH (
        'connector.type' = 'jdbc',
        'connector.url' = 'jdbc:mysql://localhost:3306/test',
        'connector.table' = 'user',
        'connector.driver' = 'com.mysql.jdbc.Driver',
        'connector.username' = 'root',
        'connector.password' = 'root',
        'connector.lookup.cache.max-rows' = '5000',
        'connector.lookup.cache.ttl' = '10min'
    );
    
    DROP TABLE IF  EXISTS  `user_info`;
    CREATE TABLE user_info (
        id INT,
        username STRING,
        password STRING
    ) WITH (
        'connector.type' = 'jdbc',
        'connector.url' = 'jdbc:mysql://localhost:3306/test',
        'connector.table' = 'user_info',
        'connector.driver' = 'com.mysql.jdbc.Driver',
        'connector.username' = 'root',
        'connector.password' = 'root',
        'connector.lookup.cache.max-rows' = '5000',
        'connector.lookup.cache.ttl' = '10min'
    );
    
    
    DROP TABLE IF  EXISTS  `user_all`;
    CREATE TABLE user_all (
        id INT,
        name STRING,
        create_time TIMESTAMP(3),
        bid INT,
        username STRING,
        password STRING
    ) WITH (
        'connector.type' = 'jdbc',
        'connector.url' = 'jdbc:mysql://localhost:3306/test',
        'connector.table' = 'user_all',
        'connector.driver' = 'com.mysql.jdbc.Driver',
        'connector.username' = 'root',
        'connector.password' = 'root',
        'connector.lookup.cache.max-rows' = '5000',
        'connector.lookup.cache.ttl' = '10min'
    );
    
    
    insert into user_all
        select u.id,u.name,u.create_time,ui.id as bid,ui.username,ui.password  
        from `user` as u 
        left join user_info as ui 
        on u.id = ui.id group by u.id,u.name,u.create_time,ui.id,ui.username,ui.password  ;
  • 相关阅读:
    删除CSDN上传图片水印
    Win10任务栏中隐藏/恢复日期显示
    使用idea和gradle编译spring5源码
    错误:找不到或无法加载主类
    判断字符串是否为数字
    mysql根据json数据过滤
    mysql当不存在时插入
    org.apache.xerces.parsers.SAXParser
    mybatis mapper判断if条件写法
    《Java面向对象编程》
  • 原文地址:https://www.cnblogs.com/ywjfx/p/14276499.html
Copyright © 2011-2022 走看看