github-actions[bot] commented on code in PR #62183:
URL: https://github.com/apache/doris/pull/62183#discussion_r3097315131


##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcQueryBuilder.java:
##########
@@ -0,0 +1,634 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.jdbc;
+
+import org.apache.doris.connector.api.ConnectorType;
+import org.apache.doris.connector.api.handle.ConnectorColumnHandle;
+import org.apache.doris.connector.api.pushdown.ConnectorAnd;
+import org.apache.doris.connector.api.pushdown.ConnectorBetween;
+import org.apache.doris.connector.api.pushdown.ConnectorColumnRef;
+import org.apache.doris.connector.api.pushdown.ConnectorComparison;
+import org.apache.doris.connector.api.pushdown.ConnectorExpression;
+import org.apache.doris.connector.api.pushdown.ConnectorFunctionCall;
+import org.apache.doris.connector.api.pushdown.ConnectorIn;
+import org.apache.doris.connector.api.pushdown.ConnectorIsNull;
+import org.apache.doris.connector.api.pushdown.ConnectorLike;
+import org.apache.doris.connector.api.pushdown.ConnectorLiteral;
+import org.apache.doris.connector.api.pushdown.ConnectorNot;
+import org.apache.doris.connector.api.pushdown.ConnectorOr;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.Set;
+import java.util.StringJoiner;
+
+/**
+ * Converts {@link ConnectorExpression} trees into SQL WHERE clauses
+ * with database-specific formatting.
+ *
+ * <p>Handles column quoting, date literal formatting, LIMIT syntax
+ * differences, function pushdown validation, function name rewriting,
+ * and time arithmetic conversion across supported JDBC database types.</p>
+ */
+public final class JdbcQueryBuilder {
+
+    private static final Logger LOG = 
LogManager.getLogger(JdbcQueryBuilder.class);
+
+    private static final DateTimeFormatter DATE_FMT = 
DateTimeFormatter.ofPattern("yyyy-MM-dd");
+    private static final DateTimeFormatter DATETIME_FMT = 
DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

Review Comment:
   `DATETIME_FMT` truncates fractional seconds for every non-Oracle path. The 
previous JDBC scan path emitted `expr.getStringValue()`, so DATETIMEV2 literals 
like `2024-01-15 10:30:45.123456` kept microsecond precision for 
MySQL/PostgreSQL/ClickHouse/Trino/SQL Server. Here `formatGenericDate()`, 
`formatTrinoDate()`, and `formatSqlServerDate()` all reformat through 
`yyyy-MM-dd HH:mm:ss`, which can change the result set for equality/range 
predicates. Please preserve the fractional part and add at least one non-Oracle 
regression test.



##########
fe/fe-core/src/main/java/org/apache/doris/datasource/PluginDrivenExternalCatalog.java:
##########
@@ -0,0 +1,300 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.datasource;
+
+import org.apache.doris.common.DdlException;
+import org.apache.doris.connector.ConnectorFactory;
+import org.apache.doris.connector.ConnectorSessionBuilder;
+import org.apache.doris.connector.DefaultConnectorContext;
+import org.apache.doris.connector.DefaultConnectorValidationContext;
+import org.apache.doris.connector.api.Connector;
+import org.apache.doris.connector.api.ConnectorSession;
+import org.apache.doris.connector.api.ConnectorTestResult;
+import org.apache.doris.datasource.property.metastore.MetastoreProperties;
+import org.apache.doris.qe.ConnectContext;
+import org.apache.doris.transaction.PluginDrivenTransactionManager;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+
+/**
+ * An {@link ExternalCatalog} backed by a Connector SPI plugin.
+ *
+ * <p>This adapter bridges the connector SPI ({@link Connector}) with the 
existing
+ * ExternalCatalog hierarchy. Metadata operations are delegated to the 
connector's
+ * {@link org.apache.doris.connector.api.ConnectorMetadata} implementation.</p>
+ *
+ * <p>When created via {@link CatalogFactory}, the Connector instance is 
provided
+ * directly. After GSON deserialization (FE restart), the Connector is 
recreated
+ * from catalog properties during {@link #initLocalObjectsImpl()}.</p>
+ */
+public class PluginDrivenExternalCatalog extends ExternalCatalog {
+
+    private static final Logger LOG = 
LogManager.getLogger(PluginDrivenExternalCatalog.class);
+
+    // Volatile for cross-thread visibility; all mutations happen under 
synchronized(this)
+    // via makeSureInitialized() → initLocalObjectsImpl(), or 
resetToUninitialized() → onClose().
+    private transient volatile Connector connector;
+
+    /** No-arg constructor for GSON deserialization. */
+    public PluginDrivenExternalCatalog() {
+    }
+
+    /**
+     * Creates a plugin-driven catalog with an already-created Connector.
+     *
+     * @param catalogId unique catalog id
+     * @param name catalog name
+     * @param resource optional resource name
+     * @param props catalog properties
+     * @param comment catalog comment
+     * @param connector the SPI connector instance
+     */
+    public PluginDrivenExternalCatalog(long catalogId, String name, String 
resource,
+            Map<String, String> props, String comment, Connector connector) {
+        super(catalogId, name, InitCatalogLog.Type.PLUGIN, comment);
+        this.catalogProperty = new CatalogProperty(resource, props);
+        this.connector = connector;
+    }
+
+    @Override
+    protected void initLocalObjectsImpl() {
+        // Always (re-)create the connector so it gets the proper engine 
context,
+        // including the catalog's execution authenticator for 
Kerberos/secured HMS.
+        // The connector created by CatalogFactory used a lightweight context
+        // without auth (the catalog didn't exist yet); we replace it now.
+        Connector newConnector = createConnectorFromProperties();
+        if (newConnector != null) {
+            connector = newConnector;
+        }
+        if (connector == null) {
+            throw new RuntimeException("No ConnectorProvider found for 
plugin-driven catalog: "
+                    + name + ", type: " + getType()
+                    + ". Ensure the connector plugin is installed.");
+        }
+        transactionManager = new PluginDrivenTransactionManager();
+        initPreExecutionAuthenticator();
+    }
+
+    @Override
+    protected synchronized void initPreExecutionAuthenticator() {
+        if (executionAuthenticator != null) {
+            return;
+        }
+        try {
+            MetastoreProperties msp = catalogProperty.getMetastoreProperties();
+            if (msp != null) {
+                executionAuthenticator = msp.getExecutionAuthenticator();
+                return;
+            }
+        } catch (Exception ignored) {
+            // Not all catalog types have metastore properties (e.g., JDBC, ES)
+        }
+        super.initPreExecutionAuthenticator();
+    }
+
+    /**
+     * Creates a new Connector from catalog properties. Extracted as a 
protected method
+     * so tests can override without depending on the static ConnectorFactory 
registry.
+     */
+    protected Connector createConnectorFromProperties() {
+        // Use getType() which falls back to logType when "type" is not in 
properties.
+        // This handles image deserialization of old resource-backed catalogs 
whose
+        // properties never contained "type" (it was derived from the Resource 
object).
+        String catalogType = getType();
+        return ConnectorFactory.createConnector(catalogType,
+                catalogProperty.getProperties(),
+                new DefaultConnectorContext(name, id, 
this::getExecutionAuthenticator));
+    }
+
+    @Override
+    public void checkProperties() throws DdlException {
+        super.checkProperties();
+        String catalogType = getType();
+        try {
+            ConnectorFactory.validateProperties(catalogType, 
catalogProperty.getProperties());
+        } catch (IllegalArgumentException e) {
+            throw new DdlException(e.getMessage());
+        }
+        // Validate function_rules JSON if present (shared across all 
connector types).
+        String functionRules = catalogProperty.getOrDefault("function_rules", 
null);
+        ExternalFunctionRules.check(functionRules);
+    }
+
+    @Override
+    public void checkWhenCreating() throws DdlException {
+        // Let the connector perform its type-specific pre-creation validation
+        // (e.g., JDBC driver security, checksum computation).
+        DefaultConnectorValidationContext validationCtx =
+                new DefaultConnectorValidationContext(getId(), 
catalogProperty);
+        try {
+            connector.preCreateValidation(validationCtx);
+        } catch (DdlException e) {
+            throw e;
+        } catch (Exception e) {
+            throw new DdlException(e.getMessage(), e);
+        }
+
+        boolean testConnection = Boolean.parseBoolean(

Review Comment:
   This changes JDBC's default CREATE CATALOG behavior. 
`ExternalCatalog.DEFAULT_TEST_CONNECTION` is `false`, and 
`setDefaultPropsIfMissing()` never backfills `test_connection` for 
plugin-driven catalogs. In the old JDBC path the default was `true` 
(`JdbcResource` / `JdbcExternalCatalog`). So when the user omits the property, 
this now skips both `connector.testConnection()` and 
`validationCtx.executePendingBeTests()`, which means bad driver jars or BE-side 
connectivity problems are accepted at create time and only fail later at query 
time. Please preserve the old JDBC default here (or make the default 
connector-specific) before returning.



##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcIdentifierMapper.java:
##########
@@ -0,0 +1,436 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.jdbc;
+
+import org.apache.doris.connector.api.DorisConnectorException;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.LinkedHashMap;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.logging.Logger;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Maps remote identifier names (databases, tables, columns) to local Doris 
names.
+ *
+ * <p>Supports two modes:
+ * <ul>
+ *   <li><b>Lowercase mode</b>: When {@code isLowerCaseMetaNames} is true,
+ *       all remote names are lowercased.</li>
+ *   <li><b>Explicit mapping</b>: A JSON mapping string defines specific
+ *       remote-to-local name translations.</li>
+ * </ul>
+ *
+ * <p>This is a pure-Java reimplementation of the fe-core {@code 
JdbcIdentifierMapping}
+ * without Jackson dependency. JSON parsing uses a simple regex-based 
approach.</p>
+ */
+public final class JdbcIdentifierMapper {
+
+    private static final Logger LOG = 
Logger.getLogger(JdbcIdentifierMapper.class.getName());
+
+    // Matches a JSON string key-value pair: "key" : "value"
+    // Key: any characters except unescaped quote (supports Unicode, spaces, 
hyphens, etc.)
+    // Value: any characters except unescaped quote, but allows escaped quotes 
(\")
+    private static final Pattern JSON_STRING_FIELD = Pattern.compile(
+            "\"((?:[^\"\\\\]|\\\\.)*)\"\\s*:\\s*\"((?:[^\"\\\\]|\\\\.)*)\"");
+
+    private final boolean isLowerCaseTableNames;
+    private final boolean isLowerCaseMetaNames;
+    private final String metaNamesMapping;
+
+    private final List<DbMapping> databaseMappings;
+    private final List<TableMapping> tableMappings;
+    private final List<ColumnMapping> columnMappings;
+
+    /**
+     * Creates an identifier mapper.
+     *
+     * @param isLowerCaseTableNames whether the server lower_case_table_names 
!= 0
+     * @param isLowerCaseMetaNames whether the catalog lower_case_meta_names 
is true
+     * @param metaNamesMapping the JSON mapping string (may be null or empty)
+     */
+    public JdbcIdentifierMapper(boolean isLowerCaseTableNames,
+            boolean isLowerCaseMetaNames, String metaNamesMapping) {
+        this.isLowerCaseTableNames = isLowerCaseTableNames;
+        this.isLowerCaseMetaNames = isLowerCaseMetaNames;
+        this.metaNamesMapping = metaNamesMapping;
+        this.databaseMappings = new ArrayList<>();
+        this.tableMappings = new ArrayList<>();
+        this.columnMappings = new ArrayList<>();
+        if (!isMappingInvalid()) {
+            parseMappings();
+            validateMappings();
+        }
+    }
+
+    public String fromRemoteDatabaseName(String remoteDatabaseName) {
+        if (!isLowerCaseMetaNames && isMappingInvalid()) {
+            return remoteDatabaseName;
+        }
+        Map<String, String> databaseNameMapping = new HashMap<>();
+        for (DbMapping m : databaseMappings) {
+            databaseNameMapping.put(m.remoteDatabase,
+                    applyLowerCaseIfNeeded(m.mapping));
+        }
+        return getMappedName(remoteDatabaseName, databaseNameMapping);
+    }
+
+    public String fromRemoteTableName(String remoteDatabaseName,
+            String remoteTableName) {
+        if (!isLowerCaseMetaNames && isMappingInvalid()) {
+            return remoteTableName;
+        }
+        Map<String, String> tableNameMapping = new HashMap<>();
+        for (TableMapping m : tableMappings) {
+            if (remoteDatabaseName.equals(m.remoteDatabase)) {
+                tableNameMapping.put(m.remoteTable,
+                        applyLowerCaseIfNeeded(m.mapping));
+            }
+        }
+        return getMappedName(remoteTableName, tableNameMapping);
+    }
+
+    public String fromRemoteColumnName(String remoteDatabaseName,
+            String remoteTableName, String remoteColumnName) {
+        if (!isLowerCaseMetaNames && isMappingInvalid()) {
+            return remoteColumnName;
+        }
+        Map<String, String> columnNameMapping = new HashMap<>();
+        for (ColumnMapping m : columnMappings) {
+            if (remoteDatabaseName.equals(m.remoteDatabase)
+                    && remoteTableName.equals(m.remoteTable)) {
+                columnNameMapping.put(m.remoteColumn,
+                        applyLowerCaseIfNeeded(m.mapping));
+            }
+        }
+        return getMappedName(remoteColumnName, columnNameMapping);
+    }
+
+    private boolean isMappingInvalid() {
+        return metaNamesMapping == null || metaNamesMapping.isEmpty();
+    }
+
+    private String getMappedName(String name, Map<String, String> nameMapping) 
{
+        String mappedName = nameMapping.getOrDefault(name, name);
+        return isLowerCaseMetaNames ? mappedName.toLowerCase() : mappedName;
+    }
+
+    private String applyLowerCaseIfNeeded(String value) {
+        return isLowerCaseMetaNames ? value.toLowerCase() : value;
+    }
+
+    // ---- Simple JSON parsing (no Jackson/Gson dependency) ----
+
+    private void parseMappings() {
+        List<Map<String, String>> databases = parseJsonArray(metaNamesMapping, 
"databases");
+        for (Map<String, String> obj : databases) {
+            databaseMappings.add(new DbMapping(
+                    obj.getOrDefault("remoteDatabase", ""),
+                    obj.getOrDefault("mapping", "")));
+        }
+
+        List<Map<String, String>> tables = parseJsonArray(metaNamesMapping, 
"tables");
+        for (Map<String, String> obj : tables) {
+            tableMappings.add(new TableMapping(
+                    obj.getOrDefault("remoteDatabase", ""),
+                    obj.getOrDefault("remoteTable", ""),
+                    obj.getOrDefault("mapping", "")));
+        }
+
+        List<Map<String, String>> columns = parseJsonArray(metaNamesMapping, 
"columns");
+        for (Map<String, String> obj : columns) {
+            columnMappings.add(new ColumnMapping(
+                    obj.getOrDefault("remoteDatabase", ""),
+                    obj.getOrDefault("remoteTable", ""),
+                    obj.getOrDefault("remoteColumn", ""),
+                    obj.getOrDefault("mapping", "")));
+        }
+    }
+
+    /**
+     * Parses a JSON array from a top-level JSON object by field name.
+     * Expected format: {"fieldName": [{...}, {...}]}
+     * Returns a list of maps, each representing one JSON object in the array.
+     */
+    static List<Map<String, String>> parseJsonArray(String json, String 
fieldName) {
+        List<Map<String, String>> result = new ArrayList<>();
+        if (json == null || json.isEmpty()) {
+            return result;
+        }
+        // Find "fieldName" : [
+        String key = "\"" + fieldName + "\"";
+        int keyIdx = json.indexOf(key);
+        if (keyIdx < 0) {
+            return result;
+        }
+        int bracketStart = json.indexOf('[', keyIdx + key.length());
+        if (bracketStart < 0) {
+            return result;
+        }
+        int bracketEnd = findMatchingBracket(json, bracketStart);
+        if (bracketEnd < 0) {
+            throw new DorisConnectorException(
+                    "JSON format is incorrect, please check the 
meta_names_mapping property");
+        }
+        String arrayContent = json.substring(bracketStart + 1, bracketEnd);
+
+        // Parse each {...} object in the array
+        int pos = 0;
+        while (pos < arrayContent.length()) {
+            int objStart = arrayContent.indexOf('{', pos);
+            if (objStart < 0) {
+                break;
+            }
+            int objEnd = arrayContent.indexOf('}', objStart);
+            if (objEnd < 0) {
+                break;
+            }
+            String objStr = arrayContent.substring(objStart, objEnd + 1);
+            result.add(parseJsonObject(objStr));
+            pos = objEnd + 1;
+        }
+        return result;
+    }
+
+    private static int findMatchingBracket(String json, int openBracketIdx) {
+        int depth = 0;
+        for (int i = openBracketIdx; i < json.length(); i++) {
+            char c = json.charAt(i);
+            if (c == '[') {
+                depth++;
+            } else if (c == ']') {
+                depth--;
+                if (depth == 0) {
+                    return i;
+                }
+            }
+        }
+        return -1;
+    }
+
+    private static Map<String, String> parseJsonObject(String objStr) {
+        Map<String, String> map = new HashMap<>();
+        Matcher m = JSON_STRING_FIELD.matcher(objStr);
+        while (m.find()) {
+            map.put(unescapeJson(m.group(1)), unescapeJson(m.group(2)));
+        }
+        return map;
+    }
+
+    private static String unescapeJson(String s) {
+        if (s.indexOf('\\') < 0) {
+            return s;
+        }
+        StringBuilder sb = new StringBuilder(s.length());
+        for (int i = 0; i < s.length(); i++) {
+            char c = s.charAt(i);
+            if (c == '\\' && i + 1 < s.length()) {
+                char next = s.charAt(i + 1);
+                switch (next) {
+                    case '"':
+                    case '\\':
+                    case '/':
+                        sb.append(next);
+                        break;
+                    case 'n':
+                        sb.append('\n');
+                        break;
+                    case 't':
+                        sb.append('\t');
+                        break;
+                    case 'r':
+                        sb.append('\r');
+                        break;
+                    default:
+                        sb.append(c);
+                        sb.append(next);
+                        break;
+                }
+                i++;
+            } else {
+                sb.append(c);
+            }
+        }
+        return sb.toString();
+    }
+
+    // ---- Validation ----
+
+    private void validateMappings() {
+        Map<String, Set<String>> duplicateErrors = new LinkedHashMap<>();
+
+        Set<String> dbKeySet = new HashSet<>();
+        Map<String, Set<String>> tableKeySet = new HashMap<>();
+        Map<String, Map<String, Set<String>>> columnKeySet = new HashMap<>();
+        Map<String, Set<String>> dbMappingCheck = new HashMap<>();
+        Map<String, Map<String, Set<String>>> tableMappingCheck = new 
HashMap<>();
+        Map<String, Map<String, Map<String, Set<String>>>> columnMappingCheck 
= new HashMap<>();
+
+        validateDatabases(duplicateErrors, dbKeySet, dbMappingCheck);
+        validateTables(duplicateErrors, tableKeySet, tableMappingCheck);
+        validateColumns(duplicateErrors, columnKeySet, columnMappingCheck);
+
+        if (!duplicateErrors.isEmpty()) {
+            StringBuilder sb = new StringBuilder("Duplicate mapping found:\n");
+            duplicateErrors.forEach((key, value) -> {
+                sb.append(key).append(":\n");
+                value.forEach(error -> sb.append("  - 
").append(error).append("\n"));
+            });
+            throw new DorisConnectorException(sb.toString());
+        }
+    }
+
+    private void validateDatabases(Map<String, Set<String>> errors,
+            Set<String> dbKeySet, Map<String, Set<String>> dbMappingCheck) {
+        Map<String, String> mappingSet = new HashMap<>();
+        for (DbMapping m : databaseMappings) {
+            if (!dbKeySet.add(m.remoteDatabase)) {
+                errors.computeIfAbsent("databases", k -> new LinkedHashSet<>())
+                        .add(String.format("Duplicate remoteDatabase found: 
%s", m.remoteDatabase));
+            }
+            String existed = mappingSet.get(m.mapping);
+            if (existed != null) {
+                errors.computeIfAbsent("databases", k -> new LinkedHashSet<>())
+                        .add(String.format("Remote name: %s, duplicate 
mapping: %s (original: %s)",
+                                m.remoteDatabase, m.mapping, existed));
+            } else {
+                mappingSet.put(m.mapping, m.remoteDatabase);
+            }
+            if (isLowerCaseMetaNames) {
+                checkCaseConflict(m.mapping, dbMappingCheck,
+                        errors, "databases", m.remoteDatabase);
+            }
+        }
+    }
+
+    private void validateTables(Map<String, Set<String>> errors,
+            Map<String, Set<String>> tableKeySet,
+            Map<String, Map<String, Set<String>>> tableMappingCheck) {
+        Map<String, String> mappingSet = new HashMap<>();

Review Comment:
   This duplicate check is wider than the runtime namespace. 
`fromRemoteTableName()` only resolves mappings within a single remote database, 
but `mappingSet` here is global across all databases, so entries like `db1.t1 
-> foo` and `db2.t2 -> foo` are rejected even though they are valid and 
unambiguous at runtime. `validateColumns()` has the same problem one level down 
for different tables. The uniqueness check should be scoped per database for 
tables and per (database, table) for columns.



##########
fe/fe-connector/fe-connector-jdbc/src/main/java/org/apache/doris/connector/jdbc/JdbcConnectorProvider.java:
##########
@@ -0,0 +1,171 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package org.apache.doris.connector.jdbc;
+
+import org.apache.doris.connector.api.Connector;
+import org.apache.doris.connector.api.DorisConnectorException;
+import org.apache.doris.connector.spi.ConnectorContext;
+import org.apache.doris.connector.spi.ConnectorProvider;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * SPI entry point for the JDBC connector plugin.
+ */
+public class JdbcConnectorProvider implements ConnectorProvider {
+
+    private static final List<String> REQUIRED_PROPERTIES = Arrays.asList(
+            JdbcConnectorProperties.JDBC_URL,
+            JdbcConnectorProperties.DRIVER_URL,
+            JdbcConnectorProperties.DRIVER_CLASS
+    );
+
+    @Override
+    public String getType() {
+        return "jdbc";
+    }
+
+    @Override
+    public Connector create(Map<String, String> properties, ConnectorContext 
context) {
+        return new JdbcDorisConnector(properties, context);
+    }
+
+    @Override
+    public void validateProperties(Map<String, String> properties) {
+        // 1. Required properties
+        for (String required : REQUIRED_PROPERTIES) {
+            String value = resolve(properties, required);
+            if (value == null || value.isEmpty()) {
+                throw new IllegalArgumentException(
+                        "Required property '" + required + "' is missing");
+            }
+        }
+
+        // 2. Reject deprecated lower_case_table_names
+        if 
(properties.containsKey(JdbcConnectorProperties.LOWER_CASE_TABLE_NAMES)
+                || properties.containsKey(
+                        JdbcDorisConnector.JDBC_PROPERTIES_PREFIX
+                                + 
JdbcConnectorProperties.LOWER_CASE_TABLE_NAMES)) {
+            throw new IllegalArgumentException(
+                    "Jdbc catalog property lower_case_table_names is not 
supported,"
+                            + " please use lower_case_meta_names instead");
+        }
+
+        // 3. Boolean property validation
+        checkBooleanProperty(properties, 
JdbcConnectorProperties.ONLY_SPECIFIED_DATABASE);
+        checkBooleanProperty(properties, 
JdbcConnectorProperties.LOWER_CASE_META_NAMES);
+        checkBooleanProperty(properties, 
JdbcConnectorProperties.CONNECTION_POOL_KEEP_ALIVE);
+        checkBooleanProperty(properties, 
JdbcConnectorProperties.TEST_CONNECTION);
+
+        // 4. Database list consistency: include/exclude cannot be set when 
only_specified_database=false
+        String onlySpecified = resolve(properties, 
JdbcConnectorProperties.ONLY_SPECIFIED_DATABASE);
+        if (onlySpecified == null || !onlySpecified.equalsIgnoreCase("true")) {
+            String includeList = resolve(properties, 
JdbcConnectorProperties.INCLUDE_DATABASE_LIST);
+            String excludeList = resolve(properties, 
JdbcConnectorProperties.EXCLUDE_DATABASE_LIST);
+            if ((includeList != null && !includeList.isEmpty())
+                    || (excludeList != null && !excludeList.isEmpty())) {
+                throw new IllegalArgumentException(
+                        "include_database_list and exclude_database_list "
+                                + "cannot be set when only_specified_database 
is false");
+            }
+        }
+
+        // 5. Connection pool settings
+        checkConnectionPoolProperties(properties);
+
+        // 6. Validate meta_names_mapping
+        String metaNamesMapping = resolve(properties, 
JdbcConnectorProperties.META_NAMES_MAPPING);
+        if (metaNamesMapping != null && !metaNamesMapping.isEmpty()) {
+            try {
+                new JdbcIdentifierMapper(false, false, metaNamesMapping);

Review Comment:
   Validation here does not match runtime behavior. 
`JdbcConnectorMetadata.getIdentifierMapper()` later builds the mapper with the 
real `lower_case_meta_names` catalog property and the server 
`lower_case_table_names` setting from the session, but this pre-check hardcodes 
both flags to `false`. A `meta_names_mapping` that only collides after 
lowercasing therefore passes `CREATE CATALOG` and then fails later on first 
metadata access. Please validate with the same flags/runtime inputs used by 
`JdbcConnectorMetadata`.



-- 
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]

Reply via email to