env {
  execution.parallelism = 1
  job.mode = "BATCH"
  checkpoint.interval = 5000
  #execution.checkpoint.data-uri = "hdfs://localhost:9000/checkpoint"
}

source {
  jdbc{
    result_table_name = "fake1"
    url = "jdbc:mysql://localhost:3306/digital_operation"
    driver = "com.mysql.cj.jdbc.Driver"
    connection_check_timeout_sec = 100
    user = "root"
    password = "123456"
    query = "select * from test_copy"
  }
}

transform {
    # 这是一种写法，多列有相同值需要替换成相同的值可以使用这个
#     Replace-list {
#         source_table_name = "fake"
#         result_table_name = "fake1"
#         replace_field = "name,address"
#         pattern = "null"
#         replacement = "测试替换"
#       }
    # 如果多列的数据不一致，并且替换的值也不一致那么使用下面的配置
    TypeConversion {
        source_table_name = "fake"
        result_table_name = "fake1"
        filter_field = [
                            {
                                "column":"status",
                                "conversionType":"bool",
                                # 如果数据为日期类型则为 true，不是则为 false
                                "isDate":false,
                                "dataFormat":""
                            }, {
                                "column":"grade",
                                # int：整型、string：字符串、long：long 型、double：小数、float：浮点数、bool：布尔类型、date：日期类型
                                 "conversionType":"string",
                                 "isDate":false,
                                 # int：整数、pointOne：保留一位小数、pointTow：保留两位小数、percent：百分比、percentPointOne：百分比保留一个小数、percentPointTwo：百分比保留两位小数
                                 "dataFormat":"percentPointTwo"
                            }, {
                                "column":"age",
                                "conversionType":"int",
                                "isDate":false,
                                "dataFormat":""
                            }, {
                                "column":"create_time",
                                "conversionType":"date",
                                "isDate":true,
                                #时间格式：yyyy、yyyyMM、yyyy-MM、yyyy/MM、yyyyMMdd、yyyy-MM-dd、yyyy/MM/dd、yyyyMMdd HH:mm:ss、yyyy-MM-dd HH:mm:ss、yyyy/MM/dd HH:mm:ss、HH、HH:mm、HH:mm:ss
                                "dataFormat":"yyyyMM"
                            }
                        ]
    }
}

sink {
  jdbc {
    source_table_name = "fake"
    url = "jdbc:mysql://localhost:3306/testdb"
    driver = "com.mysql.cj.jdbc.Driver"
    user = "root"
    password = "123456"
    query = "insert into test_copy(id, name, address, sex, age, create_time, tell, grade, status) values(?, ?, ?, ?, ?, ?, ?, ?, ?)"
    batch_size = 1000
  }
}
