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


##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/HadoopClientOptions.java:
##########
@@ -0,0 +1,167 @@
+// 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.filesystem.properties;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public final class HadoopClientOptions {
+    private static final Set<String> HDFS_SCHEMES = Set.of("hdfs", "viewfs", 
"jfs");
+    private static final Set<String> REMOTE_SCHEMES = Set.of("hdfs", "viewfs", 
"jfs", "oss");
+    private static final Set<String> USER_CONFIG_KEYS = Set.of(
+            "fs.defaultFS",
+            "hadoop.username",
+            "hadoop.security.authentication",
+            "hadoop.security.auth_to_local",
+            "hadoop.security.token.service.use_ip",
+            "hadoop.rpc.protection",
+            "hadoop.kerberos.principal",
+            "hadoop.kerberos.keytab",
+            "hadoop.kerberos.min.seconds.before.relogin",
+            "hadoop.kerberos.keytab.login.autorenewal.enabled",
+            "dfs.nameservices",
+            "dfs.namenode.rpc-address",
+            "dfs.namenode.kerberos.principal",
+            "dfs.namenode.kerberos.principal.pattern",
+            "dfs.datanode.kerberos.principal",
+            "dfs.data.transfer.protection",
+            "dfs.encrypt.data.transfer",
+            "dfs.encrypt.data.transfer.algorithm",
+            "dfs.encrypt.data.transfer.cipher.suites",
+            "dfs.encrypt.data.transfer.cipher.key.bitlength",
+            "dfs.client.use.datanode.hostname",
+            "dfs.client.socket-timeout",
+            "dfs.datanode.socket.write.timeout",
+            "dfs.domain.socket.path",
+            "dfs.client.failover.max.attempts",
+            "dfs.client.failover.sleep.base.millis",
+            "dfs.client.failover.sleep.max.millis",
+            "dfs.client.failover.connection.retries",
+            "dfs.client.failover.connection.retries.on.timeouts",
+            "dfs.client.failover.random.order",
+            "dfs.replication",
+            "dfs.blocksize");
+
+    private static final List<String> USER_CONFIG_KEY_PREFIXES = List.of(
+            "dfs.ha.namenodes.",
+            "dfs.namenode.rpc-address.",
+            "dfs.client.read.",
+            "dfs.client.hedged.read.",
+            "dfs.client.retry.",
+            "dfs.client.failover.observer.",
+            "dfs.client.block.write.",
+            "juicefs.");
+
+    private static final Map<String, String> IMPLEMENTATIONS = Map.of(
+            "fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem",
+            "fs.AbstractFileSystem.hdfs.impl", "org.apache.hadoop.fs.Hdfs",
+            "fs.viewfs.impl", "org.apache.hadoop.fs.viewfs.ViewFileSystem",
+            "fs.AbstractFileSystem.viewfs.impl", 
"org.apache.hadoop.fs.viewfs.ViewFs",
+            "fs.jfs.impl", "io.juicefs.JuiceFileSystem",
+            "fs.AbstractFileSystem.jfs.impl", "io.juicefs.JuiceFS");
+
+    private HadoopClientOptions() {
+    }
+
+    public static boolean isHdfsOption(String key, String value) {
+        if (key == null || !key.equals(key.trim())) {
+            return false;
+        }
+        String implementation = IMPLEMENTATIONS.get(key);
+        if (implementation != null) {
+            if (value == null || !implementation.equals(value.trim())) {
+                throw new IllegalArgumentException("Unsupported filesystem 
implementation for property: " + key);
+            }
+            return true;
+        }
+        if (key.startsWith("dfs.client.failover.proxy.provider.")) {
+            if (value == null || 
!value.trim().startsWith("org.apache.hadoop.hdfs.server.namenode.ha.")) {
+                throw new IllegalArgumentException("Unsupported failover 
provider for property: " + key);
+            }
+            return true;
+        }
+        if (key.startsWith("fs.viewfs.mounttable.")) {
+            if (!key.contains(".link")) {
+                return key.endsWith(".homedir");
+            }
+            for (String target : value.split(",", -1)) {
+                if (remoteUri(target.trim(), HDFS_SCHEMES) == null) {
+                    throw new IllegalArgumentException("Unsupported mount 
target for property: " + key);
+                }
+            }
+            return true;
+        }
+        if (USER_CONFIG_KEYS.contains(key) || 
USER_CONFIG_KEY_PREFIXES.stream().anyMatch(key::startsWith)) {
+            return true;
+        }
+        return HDFS_SCHEMES.stream().anyMatch(scheme -> key.equals("fs." + 
scheme + ".impl.disable.cache"));
+    }
+
+    public static boolean isOssClientOption(String key) {
+        return key.startsWith("fs.oss.") && key.equals(key.trim()) && 
!key.equals("fs.oss.impl");
+    }
+
+    public static Map<String, String> forStatement(Map<String, String> 
properties) {
+        Map<String, String> result = new LinkedHashMap<>();
+        properties.forEach((name, value) -> {
+            String key = name.regionMatches(true, 0, "broker.", 0, 7) ? 
name.substring(7) : name;
+            if (!name.equals(name.trim()) || !key.equals(key.trim())) {
+                return;
+            }
+            String lower = key.toLowerCase(Locale.ROOT);
+            if (lower.equals("fs.defaultfs") || 
lower.equals("oss.hdfs.fs.defaultfs")) {
+                URI uri = remoteUri(value, REMOTE_SCHEMES);
+                if (uri == null || uri.getRawAuthority() == null) {

Review Comment:
   [P2] Allow the default ViewFS mount-table URI
   
   `fs.defaultFS=viewfs:///` is a valid Hadoop configuration: the absent 
authority selects `fs.viewfs.mounttable.default.*`, as documented by the 
[Hadoop ViewFs 
API](https://hadoop.apache.org/docs/current/api/org/apache/hadoop/fs/viewfs/ViewFs.html).
 For example, an HDFS TVF with `uri=viewfs:///warehouse/f.csv`, 
`fs.defaultFS=viewfs:///`, and 
`fs.viewfs.mounttable.default.link./warehouse=hdfs://nn/warehouse` previously 
reached the remote mount through the existing HDFS URI normalizer. It now 
throws here before binding, because `getRawAuthority()` is null. Validate the 
authority according to the scheme so statements using the default ViewFS mount 
table continue to work.



##########
fe/fe-filesystem/fe-filesystem-api/src/main/java/org/apache/doris/filesystem/properties/HadoopClientOptions.java:
##########
@@ -0,0 +1,167 @@
+// 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.filesystem.properties;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Set;
+
+public final class HadoopClientOptions {
+    private static final Set<String> HDFS_SCHEMES = Set.of("hdfs", "viewfs", 
"jfs");
+    private static final Set<String> REMOTE_SCHEMES = Set.of("hdfs", "viewfs", 
"jfs", "oss");
+    private static final Set<String> USER_CONFIG_KEYS = Set.of(
+            "fs.defaultFS",
+            "hadoop.username",
+            "hadoop.security.authentication",
+            "hadoop.security.auth_to_local",
+            "hadoop.security.token.service.use_ip",
+            "hadoop.rpc.protection",
+            "hadoop.kerberos.principal",
+            "hadoop.kerberos.keytab",
+            "hadoop.kerberos.min.seconds.before.relogin",
+            "hadoop.kerberos.keytab.login.autorenewal.enabled",
+            "dfs.nameservices",
+            "dfs.namenode.rpc-address",
+            "dfs.namenode.kerberos.principal",
+            "dfs.namenode.kerberos.principal.pattern",
+            "dfs.datanode.kerberos.principal",
+            "dfs.data.transfer.protection",
+            "dfs.encrypt.data.transfer",
+            "dfs.encrypt.data.transfer.algorithm",
+            "dfs.encrypt.data.transfer.cipher.suites",
+            "dfs.encrypt.data.transfer.cipher.key.bitlength",
+            "dfs.client.use.datanode.hostname",
+            "dfs.client.socket-timeout",
+            "dfs.datanode.socket.write.timeout",
+            "dfs.domain.socket.path",
+            "dfs.client.failover.max.attempts",
+            "dfs.client.failover.sleep.base.millis",
+            "dfs.client.failover.sleep.max.millis",
+            "dfs.client.failover.connection.retries",
+            "dfs.client.failover.connection.retries.on.timeouts",
+            "dfs.client.failover.random.order",
+            "dfs.replication",
+            "dfs.blocksize");
+
+    private static final List<String> USER_CONFIG_KEY_PREFIXES = List.of(
+            "dfs.ha.namenodes.",
+            "dfs.namenode.rpc-address.",
+            "dfs.client.read.",
+            "dfs.client.hedged.read.",
+            "dfs.client.retry.",
+            "dfs.client.failover.observer.",
+            "dfs.client.block.write.",
+            "juicefs.");
+
+    private static final Map<String, String> IMPLEMENTATIONS = Map.of(
+            "fs.hdfs.impl", "org.apache.hadoop.hdfs.DistributedFileSystem",
+            "fs.AbstractFileSystem.hdfs.impl", "org.apache.hadoop.fs.Hdfs",
+            "fs.viewfs.impl", "org.apache.hadoop.fs.viewfs.ViewFileSystem",
+            "fs.AbstractFileSystem.viewfs.impl", 
"org.apache.hadoop.fs.viewfs.ViewFs",
+            "fs.jfs.impl", "io.juicefs.JuiceFileSystem",
+            "fs.AbstractFileSystem.jfs.impl", "io.juicefs.JuiceFS");
+
+    private HadoopClientOptions() {
+    }
+
+    public static boolean isHdfsOption(String key, String value) {
+        if (key == null || !key.equals(key.trim())) {
+            return false;
+        }
+        String implementation = IMPLEMENTATIONS.get(key);
+        if (implementation != null) {
+            if (value == null || !implementation.equals(value.trim())) {
+                throw new IllegalArgumentException("Unsupported filesystem 
implementation for property: " + key);
+            }
+            return true;
+        }
+        if (key.startsWith("dfs.client.failover.proxy.provider.")) {
+            if (value == null || 
!value.trim().startsWith("org.apache.hadoop.hdfs.server.namenode.ha.")) {
+                throw new IllegalArgumentException("Unsupported failover 
provider for property: " + key);
+            }
+            return true;
+        }
+        if (key.startsWith("fs.viewfs.mounttable.")) {
+            if (!key.contains(".link")) {
+                return key.endsWith(".homedir");
+            }
+            for (String target : value.split(",", -1)) {
+                if (remoteUri(target.trim(), HDFS_SCHEMES) == null) {
+                    throw new IllegalArgumentException("Unsupported mount 
target for property: " + key);
+                }
+            }
+            return true;
+        }
+        if (USER_CONFIG_KEYS.contains(key) || 
USER_CONFIG_KEY_PREFIXES.stream().anyMatch(key::startsWith)) {
+            return true;
+        }
+        return HDFS_SCHEMES.stream().anyMatch(scheme -> key.equals("fs." + 
scheme + ".impl.disable.cache"));
+    }
+
+    public static boolean isOssClientOption(String key) {
+        return key.startsWith("fs.oss.") && key.equals(key.trim()) && 
!key.equals("fs.oss.impl");
+    }
+
+    public static Map<String, String> forStatement(Map<String, String> 
properties) {
+        Map<String, String> result = new LinkedHashMap<>();
+        properties.forEach((name, value) -> {
+            String key = name.regionMatches(true, 0, "broker.", 0, 7) ? 
name.substring(7) : name;
+            if (!name.equals(name.trim()) || !key.equals(key.trim())) {
+                return;
+            }
+            String lower = key.toLowerCase(Locale.ROOT);
+            if (lower.equals("fs.defaultfs") || 
lower.equals("oss.hdfs.fs.defaultfs")) {
+                URI uri = remoteUri(value, REMOTE_SCHEMES);
+                if (uri == null || uri.getRawAuthority() == null) {
+                    throw new IllegalArgumentException("Default filesystem 
must have a remote scheme and authority: "
+                            + name);
+                }
+            } else if (lower.equals("fs.default.name") || 
lower.equals("_hadoop_config_dir_")
+                    || lower.equals("_storage_type_") || 
lower.endsWith(".config.resources")
+                    || lower.startsWith("doris.fs.cache.key.")
+                    || (lower.startsWith("fs.") && 
lower.endsWith(".support"))) {
+                throw new IllegalArgumentException("Storage property is not 
allowed in this statement: " + name);
+            } else if (lower.startsWith("fs.") || lower.startsWith("dfs.") || 
lower.startsWith("hadoop.")
+                    || lower.startsWith("juicefs.")) {
+                if (!isHdfsOption(key, value) && !isOssClientOption(key)) {

Review Comment:
   [P2] Preserve case-insensitive matching for supported statement options
   
   `forStatement` recognizes the prefix using `lower`, but checks the original 
`key` against the case-sensitive allowlist. For example, `SELECT * FROM 
hdfs("uri"="hdfs://nn/data.csv", "format"="csv", "HADOOP.USERNAME"="alice")` 
now silently drops the username. Previously `parseCommonProperties` built a 
case-insensitive map, so `HdfsCompatibleProperties` bound this alias and 
emitted `hadoop.username=alice`; the query now uses the process's default 
Hadoop identity and can fail to read files it previously accessed. OUTFILE has 
the same regression, and mixed-case Hadoop Kerberos aliases are also affected. 
Preserve the existing case-insensitive handling of supported typed aliases 
before filtering, with tests for username and Kerberos options.



##########
fe/fe-filesystem/fe-filesystem-hdfs/src/main/java/org/apache/doris/filesystem/hdfs/properties/HdfsProperties.java:
##########
@@ -104,8 +105,7 @@ private void extractUserOverriddenHdfsConfig(Map<String, 
String> origProps) {
         }
         userOverriddenHdfsConfig = new HashMap<>();
         origProps.forEach((key, value) -> {
-            if (key.startsWith("hadoop.") || key.startsWith("dfs.") || 
key.startsWith("fs.")
-                    || key.startsWith("juicefs.")) {
+            if (HadoopClientOptions.isHdfsOption(key, value)) {

Review Comment:
   [P2] Update the existing parity expectations for the new filter
   
   This deliberately stops forwarding `fs.hdfs.support`, but 
`HdfsPropertiesSpiParityTest.testSimpleAuthBackendMapMatchesFeCoreGolden` and 
`testKerberosBackendMapMatchesFeCoreGolden` still include 
`fs.hdfs.support=true` in their exact expected backend maps. Both fixtures pass 
that property to `PROVIDER.bind`, and no later initialization step restores it, 
so both exact-map assertions now fail. Update those golden maps alongside the 
behavior change and include the parity class in validation; the newly added 
selection test does not cover these existing expectations. This mismatch is 
established by static inspection; tests were not executed in this review.



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