morningman commented on code in PR #14978:
URL: https://github.com/apache/doris/pull/14978#discussion_r1047220062
##########
fe/fe-core/src/main/java/org/apache/doris/datasource/EsExternalCatalog.java:
##########
@@ -73,53 +67,70 @@ public class EsExternalCatalog extends ExternalCatalog {
/**
* Default constructor for EsExternalCatalog.
*/
- public EsExternalCatalog(long catalogId, String name, Map<String, String>
props) {
+ public EsExternalCatalog(
+ long catalogId, String name, String resource, Map<String, String>
props) throws DdlException {
this.id = catalogId;
this.name = name;
this.type = "es";
- setProperties(props);
- this.catalogProperty = new CatalogProperty();
- this.catalogProperty.setProperties(props);
+ if (resource == null) {
+ catalogProperty = new CatalogProperty(null,
processCompatibleProperties(props));
+ } else {
+ catalogProperty = new CatalogProperty(resource,
Collections.emptyMap());
+ processCompatibleProperties(catalogProperty.getProperties());
Review Comment:
If do this, when we alter the resource, it can not reflect to the catalog
property
##########
regression-test/suites/external_catalog_p0/hive/test_hive_orc.groovy:
##########
@@ -98,12 +98,11 @@ suite("test_hive_orc", "all_types") {
sql """admin set frontend config ("enable_new_load_scan_node" =
"true");"""
set_be_config.call('true')
sql """drop catalog if exists ${catalog_name}"""
- sql """
- create catalog if not exists ${catalog_name} properties (
+ sql """create resource if not exists hms_resource_hive_orc
properties (
Review Comment:
We need to keep the origin test case to make sure that the origin create
method is still working
##########
docs/zh-CN/docs/sql-manual/sql-reference/Data-Definition-Statements/Create/CREATE-RESOURCE.md:
##########
@@ -158,6 +158,88 @@ PROPERTIES ("key"="value", ...);
- `AWS_REQUEST_TIMEOUT_MS`:s3 请求超时时间,单位毫秒,默认为 3000
- `AWS_CONNECTION_TIMEOUT_MS`:s3 连接超时时间,单位毫秒,默认为 1000
+4. 创建 JDBC resource
+
+ ```sql
+ CREATE RESOURCE mysql_resource PROPERTIES (
+ "type"="jdbc",
+ "user"="root",
+ "password"="123456",
+ "jdbc_url" = "jdbc:mysql://127.0.0.1:3316/doris_test?useSSL=false",
+ "driver_url" =
"https://doris-community-test-1308700295.cos.ap-hongkong.myqcloud.com/jdbc_driver/mysql-connector-java-8.0.25.jar",
+ "driver_class" = "com.mysql.cj.jdbc.Driver"
+ );
+ ```
+
+ JDBC 的相关参数如下:
+ - user:连接数据库使用的用户名
+ - password:连接数据库使用的密码
+ - jdbc_url: 连接到指定数据库的标识符
+ - driver_url: jdbc驱动包的url
+ - driver_class: jdbc驱动类
+
+5. 创建 HDFS resource
+
+ ```sql
+ CREATE RESOURCE hdfs_resource PROPERTIES (
+ "username"="user",
Review Comment:
missing "type"?
##########
fe/fe-core/src/main/java/org/apache/doris/catalog/Resource.java:
##########
@@ -78,6 +95,29 @@ public static Resource fromStmt(CreateResourceStmt stmt)
throws DdlException {
return resource;
}
+ public synchronized boolean removeReference(String referenceName,
ReferenceType type) {
+ String fullName = referenceName + REFERENCE_SPLIT + type.name();
+ if (references.remove(fullName) != null) {
+ Env.getCurrentEnv().getEditLog().logAlterResource(this);
+ LOG.info("Reference(type={}, name={}) is removed from resource {},
current set: {}",
+ type, referenceName, name, references);
+ return true;
+ }
+ return false;
+ }
+
+ public synchronized boolean addReference(String referenceName,
ReferenceType type) throws AnalysisException {
+ String fullName = referenceName + REFERENCE_SPLIT + type.name();
+ if (references.put(fullName, type) == null) {
+ // log set
+ Env.getCurrentEnv().getEditLog().logAlterResource(this);
Review Comment:
Can't write edit log here, because this maybe a replay process.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]