apache / seatunnel

SeaTunnel is a next-generation super high-performance, distributed, massive data integration tool.
https://seatunnel.apache.org/
Apache License 2.0
7.86k stars 1.78k forks source link

[Bug] [Config] seatunnel config file do not use include file do substitutions #1944

Open jersy opened 2 years ago

jersy commented 2 years ago

Search before asking

What happened

seatunnel config file do not use include file do substitutions

SeaTunnel Version

2.1.1

SeaTunnel Config

#source_sql_db.conf
ems {
  driver = "com.mysql.jdbc.Driver"
  url = "jdbc:mysql://localhost:3306/ems"
  user = "ems"
  password = "emspass"
}

#spark_application4.conf

driver="com.mysql.jdbc.Driver"
refer_driver=${driver}

include "source_sql_db.conf"

source {
    jdbc {
      driver = ${ems.driver}
      url = ${ems.url}
      table =${ems.driver}
      user = ${ems.user}
      password = ${ems.password}
      result_table_name = "test_table"
    }
}
transform {
}
sink {
}

Running Command

import org.apache.seatunnel.shade.com.typesafe.config.Config;
import org.apache.seatunnel.shade.com.typesafe.config.ConfigFactory;
import org.apache.seatunnel.shade.com.typesafe.config.ConfigRenderOptions;
import org.apache.seatunnel.shade.com.typesafe.config.ConfigResolveOptions;

import java.io.File;
import java.io.FileNotFoundException;

public class TestConfig4 {
    public static void main(String[] args) throws FileNotFoundException {
        String configFile = "config/spark_application4.conf";
        File file = new File(configFile);
        if (!file.exists()) {
            throw new FileNotFoundException("config file '" + file + "' does not exists!");
        }

        Config appConfig = ConfigFactory.parseFile(file)
                .resolve(ConfigResolveOptions.defaults().setAllowUnresolved(true))
                .resolveWith( ConfigFactory.systemEnvironment(), ConfigResolveOptions.defaults().setAllowUnresolved(true));

        ConfigRenderOptions options = ConfigRenderOptions.concise().setFormatted(true);
        System.out.println(appConfig.root().render(options));;
    }
}

Error Exception

{
    "transform" : [],
    "driver" : "com.mysql.jdbc.Driver",
    "sink" : [],
    "ems" : {
        "driver" : "com.mysql.jdbc.Driver",
        "url" : "jdbc:mysql://localhost:3306/ems",
        "user" : "ems",
        "password" : "emspass"
    },
    "source" : [
        {
            "password" : ${ems.password},
            "driver" : ${ems.driver},
            "result_table_name" : "test_table",
            "plugin_name" : "jdbc",
            "user" : ${ems.user},
            "url" : ${ems.url},
            "table" : ${ems.driver}
        }
    ],
    "refer_driver" : "com.mysql.jdbc.Driver"
}

Flink or Spark Version

No response

Java or Scala Version

1.8

Screenshots

No response

Are you willing to submit PR?

Code of Conduct

Hisoka-X commented 2 years ago

Yeap, SeaTunnel not support include other file. If you want, you can contribute this.

jersy commented 2 years ago

Yeap, SeaTunnel not support include other file. If you want, you can contribute this.

If I had 100 Mysql tables to import, it would be crazy to configure JDBC information in 100 files. I think should support this feature。

Hisoka-X commented 2 years ago

Yeap, SeaTunnel not support include other file. If you want, you can contribute this.

If I had 100 Mysql tables to import, it would be crazy to configure JDBC information in 100 files. I think should support this feature。

Looking forward your contribute!