CREATE CATALOG

    Description

    该语句用于创建外部数据目录(catalog)

    语法:

    可以通过 CREATE RESOURCE 创建,目前支持三种 Resource,分别连接三种外部数据源:

    • hms:Hive MetaStore
    • es:Elasticsearch
    • jdbc:数据库访问的标准接口(JDBC), 当前支持 MySQL 和 PostgreSQL

    1.2.0 以后的版本推荐通过 resource 创建 catalog,多个使用场景可以复用相同的 resource。

    1. CREATE RESOURCE catalog_resource PROPERTIES (
    2. 'type'='hms|es|jdbc',
    3. ...
    4. );
    5. // 在 PROERPTIES 中指定的配置,将会覆盖 Resource 中的配置。
    6. CREATE CATALOG catalog_name WITH RESOURCE catalog_resource PROPERTIES(
    7. 'key' = 'value'
    8. )

    通过 properties 创建 catalog

    1.2.0 版本通过 properties 创建 catalog。

    1. CREATE CATALOG catalog_name PROPERTIES (
    2. 'type'='hms|es|jdbc',
    3. ...
    4. );

    Example

    1. 新建数据目录 hive

      1. -- 1.2.0+ 版本
      2. CREATE RESOURCE es_resource PROPERTIES (
      3. "type"="es",
      4. "hosts"="http://127.0.0.1:9200"
      5. );
      6. CREATE CATALOG es WITH RESOURCE es_resource;
      7. -- 1.2.0 版本
      8. CREATE CATALOG es PROPERTIES (
      9. "type"="es",
      10. "hosts"="http://127.0.0.1:9200"
      11. );
    2. 新建数据目录 jdbc mysql

      1. CREATE RESOURCE mysql_resource PROPERTIES (
      2. "type"="jdbc",
      3. "user"="root",
      4. "password"="123456",
      5. "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false",
      6. "driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar",
      7. "driver_class" = "com.mysql.cj.jdbc.Driver"
      8. );
      9. CREATE CATALOG jdbc WITH RESOURCE msyql_resource;
      10. -- 1.2.0 版本
      11. CREATE CATALOG jdbc PROPERTIES (
      12. "type"="jdbc",
      13. "jdbc.user"="root",
      14. "jdbc.password"="123456",
      15. "jdbc.jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false",
      16. "jdbc.driver_url" = "https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar",
      17. "jdbc.driver_class" = "com.mysql.cj.jdbc.Driver"
      18. );

      postgresql

      clickhouse

      1. -- 1.2.0+ Version
      2. CREATE RESOURCE clickhouse_resource PROPERTIES (
      3. "type"="jdbc",
      4. "user"="default",
      5. "jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo",
      6. "driver_url" = "file:///path/to/clickhouse-jdbc-0.3.2-patch11-all.jar",
      7. "driver_class" = "com.clickhouse.jdbc.ClickHouseDriver"
      8. CREATE CATALOG jdbc WITH RESOURCE clickhouse_resource;
      9. -- 1.2.0 Version
      10. CREATE CATALOG jdbc PROPERTIES (
      11. "type"="jdbc",
      12. "jdbc.jdbc_url" = "jdbc:clickhouse://127.0.0.1:8123/demo",
      13. ...
      14. )

      oracle

      1. -- 方式一
      2. CREATE RESOURCE oracle_resource PROPERTIES (
      3. "type"="jdbc",
      4. "user"="doris",
      5. "password"="123456",
      6. "jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin",
      7. "driver_url" = "file:/path/to/ojdbc6.jar",
      8. "driver_class" = "oracle.jdbc.driver.OracleDriver"
      9. );
      10. CREATE CATALOG jdbc WITH RESOURCE oracle_resource;
      11. -- 方式二,注意有jdbc前缀
      12. CREATE CATALOG jdbc PROPERTIES (
      13. "type"="jdbc",
      14. "jdbc.user"="doris",
      15. "jdbc.password"="123456",
      16. "jdbc.jdbc_url" = "jdbc:oracle:thin:@127.0.0.1:1521:helowin",
      17. "jdbc.driver_url" = "file:/path/to/ojdbc6.jar",

    CREATE, CATALOG

    Best Practice