You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by st...@apache.org on 2020/10/24 10:27:55 UTC

[impala] 01/04: IMPALA-10266: Identify FileSystem type based on the protocol scheme.

This is an automated email from the ASF dual-hosted git repository.

stigahuang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/impala.git

commit 4b5c66f329cdd818dd11cd1a9c68b58c84bcf45c
Author: Riza Suminto <ri...@cloudera.com>
AuthorDate: Wed Oct 21 11:00:54 2020 -0700

    IMPALA-10266: Identify FileSystem type based on the protocol scheme.
    
    Frontend identifies the type of FileSystem in two ways. The first is
    done using the instanceof operator with subclasses of
    org.apache.hadoop.fs.FileSystem. The second is by checking the
    FileSystem protocol scheme. This patch standardizes the FileSystem
    identification based on the scheme only.
    
    Testing:
    - Add several tests in FileSystemUtilTest to check validity of some
      FileSystemUtil functions.
    - Run and pass core tests.
    
    Change-Id: I04492326a6e84895eef369fc11a3ec11f1536b6b
    Reviewed-on: http://gerrit.cloudera.org:8080/16628
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 .../org/apache/impala/analysis/LoadDataStmt.java   |  20 +--
 .../impala/catalog/CatalogServiceCatalog.java      |   4 +-
 .../org/apache/impala/common/FileSystemUtil.java   | 156 ++++++++++++++++-----
 .../org/apache/impala/service/JniFrontend.java     |  11 +-
 .../apache/impala/analysis/AnalyzeStmtsTest.java   |   6 +-
 .../apache/impala/common/FileSystemUtilTest.java   | 137 +++++++++++++++++-
 6 files changed, 265 insertions(+), 69 deletions(-)

diff --git a/fe/src/main/java/org/apache/impala/analysis/LoadDataStmt.java b/fe/src/main/java/org/apache/impala/analysis/LoadDataStmt.java
index b2daea8..5aa7b42 100644
--- a/fe/src/main/java/org/apache/impala/analysis/LoadDataStmt.java
+++ b/fe/src/main/java/org/apache/impala/analysis/LoadDataStmt.java
@@ -23,13 +23,7 @@ import java.util.List;
 
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.AdlFileSystem;
-import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem;
-import org.apache.hadoop.fs.azurebfs.SecureAzureBlobFileSystem;
-import org.apache.hadoop.fs.ozone.OzoneFileSystem;
 import org.apache.hadoop.fs.permission.FsAction;
-import org.apache.hadoop.fs.s3a.S3AFileSystem;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.impala.authorization.Privilege;
 import org.apache.impala.catalog.FeFsTable;
 import org.apache.impala.catalog.FeTable;
@@ -147,14 +141,10 @@ public class LoadDataStmt extends StatementBase {
     try {
       Path source = sourceDataPath_.getPath();
       FileSystem fs = source.getFileSystem(FileSystemUtil.getConfiguration());
-      if (!(fs instanceof DistributedFileSystem) && !(fs instanceof S3AFileSystem) &&
-          !(fs instanceof AzureBlobFileSystem) &&
-          !(fs instanceof SecureAzureBlobFileSystem) &&
-          !(fs instanceof AdlFileSystem) &&
-          !(fs instanceof OzoneFileSystem)) {
+      if (!FileSystemUtil.isValidLoadDataInpath(fs)) {
         throw new AnalysisException(String.format("INPATH location '%s' "
-                + "must point to an HDFS, S3A, ADL, ABFS, or Ozone filesystem.",
-            sourceDataPath_));
+                + "must point to one of the supported filesystem URI scheme (%s).",
+            sourceDataPath_, FileSystemUtil.getValidLoadDataInpathSchemes()));
       }
       if (!fs.exists(source)) {
         throw new AnalysisException(String.format(
@@ -166,8 +156,8 @@ public class LoadDataStmt extends StatementBase {
       // its parent directory (in order to delete the file as part of the move operation).
       FsPermissionChecker checker = FsPermissionChecker.getInstance();
       // TODO: Disable permission checking for S3A as well (HADOOP-13892)
-      boolean shouldCheckPerms = !(fs instanceof AdlFileSystem ||
-        fs instanceof AzureBlobFileSystem || fs instanceof SecureAzureBlobFileSystem);
+      boolean shouldCheckPerms =
+          FileSystemUtil.FsType.getFsType(fs.getScheme()) != FileSystemUtil.FsType.ADLS;
 
       if (fs.isDirectory(source)) {
         if (FileSystemUtil.getTotalNumVisibleFiles(source) == 0) {
diff --git a/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java b/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
index 38aed8f..7fee648 100644
--- a/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
+++ b/fe/src/main/java/org/apache/impala/catalog/CatalogServiceCatalog.java
@@ -321,7 +321,7 @@ public class CatalogServiceCatalog extends Catalog {
     try {
       // We want only 'true' HDFS filesystems to poll the HDFS cache (i.e not S3,
       // local, etc.)
-      if (FileSystemUtil.getDefaultFileSystem() instanceof DistributedFileSystem) {
+      if (FileSystemUtil.isDistributedFileSystem(FileSystemUtil.getDefaultFileSystem())) {
         cachePoolReader_.scheduleAtFixedRate(
             new CachePoolReader(false), 0, 1, TimeUnit.MINUTES);
       }
@@ -1732,7 +1732,7 @@ public class CatalogServiceCatalog extends Catalog {
     try {
       // We want only 'true' HDFS filesystems to poll the HDFS cache (i.e not S3,
       // local, etc.)
-      if (FileSystemUtil.getDefaultFileSystem() instanceof DistributedFileSystem) {
+      if (FileSystemUtil.isDistributedFileSystem(FileSystemUtil.getDefaultFileSystem())) {
         CachePoolReader reader = new CachePoolReader(true);
         reader.run();
       }
diff --git a/fe/src/main/java/org/apache/impala/common/FileSystemUtil.java b/fe/src/main/java/org/apache/impala/common/FileSystemUtil.java
index ea01c6a..89a26a5 100644
--- a/fe/src/main/java/org/apache/impala/common/FileSystemUtil.java
+++ b/fe/src/main/java/org/apache/impala/common/FileSystemUtil.java
@@ -20,19 +20,17 @@ package org.apache.impala.common;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import org.apache.commons.io.IOUtils;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.fs.FileStatus;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.FileUtil;
-import org.apache.hadoop.fs.LocalFileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.fs.RemoteIterator;
 import org.apache.hadoop.fs.adl.AdlFileSystem;
 import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem;
 import org.apache.hadoop.fs.azurebfs.SecureAzureBlobFileSystem;
-import org.apache.hadoop.fs.ozone.OzoneFileSystem;
-import org.apache.hadoop.fs.s3a.S3AFileSystem;
 import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.hdfs.client.HdfsAdmin;
 import org.apache.hadoop.hdfs.protocol.EncryptionZone;
@@ -47,6 +45,7 @@ import java.io.InputStream;
 import java.net.URI;
 import java.util.Map;
 import java.util.NoSuchElementException;
+import java.util.Set;
 import java.util.Stack;
 import java.util.UUID;
 
@@ -58,6 +57,65 @@ public class FileSystemUtil {
   private static final Configuration CONF = new Configuration();
   private static final Logger LOG = LoggerFactory.getLogger(FileSystemUtil.class);
 
+  public static final String SCHEME_ABFS = "abfs";
+  public static final String SCHEME_ABFSS = "abfss";
+  public static final String SCHEME_ADL = "adl";
+  public static final String SCHEME_FILE = "file";
+  public static final String SCHEME_HDFS = "hdfs";
+  public static final String SCHEME_S3A = "s3a";
+  public static final String SCHEME_O3FS = "o3fs";
+  public static final String SCHEME_ALLUXIO = "alluxio";
+
+  /**
+   * Set containing all FileSystem scheme that known to supports storage UUIDs in
+   * BlockLocation calls.
+   */
+  private static final Set<String> SCHEME_SUPPORT_STORAGE_IDS =
+      ImmutableSet.<String>builder()
+          .add(SCHEME_HDFS)
+          .add(SCHEME_O3FS)
+          .add(SCHEME_ALLUXIO)
+          .build();
+
+  /**
+   * Set containing all FileSystem scheme that is writeable by Impala.
+   */
+  private static final Set<String> SCHEME_WRITEABLE_BY_IMPALA =
+      ImmutableSet.<String>builder()
+          .add(SCHEME_ABFS)
+          .add(SCHEME_ABFSS)
+          .add(SCHEME_ADL)
+          .add(SCHEME_FILE)
+          .add(SCHEME_HDFS)
+          .add(SCHEME_S3A)
+          .add(SCHEME_O3FS)
+          .build();
+
+  /**
+   * Set containing all FileSystem scheme that is supported as Impala default FileSystem.
+   */
+  private static final Set<String> SCHEME_SUPPORTED_AS_DEFAULT_FS =
+      ImmutableSet.<String>builder()
+          .add(SCHEME_ABFS)
+          .add(SCHEME_ABFSS)
+          .add(SCHEME_ADL)
+          .add(SCHEME_HDFS)
+          .add(SCHEME_S3A)
+          .build();
+
+  /**
+   * Set containing all FileSystem scheme that is valid as INPATH for LOAD DATA statement.
+   */
+  private static final Set<String> SCHEME_VALID_FOR_LOAD_INPATH =
+      ImmutableSet.<String>builder()
+          .add(SCHEME_ABFS)
+          .add(SCHEME_ABFSS)
+          .add(SCHEME_ADL)
+          .add(SCHEME_HDFS)
+          .add(SCHEME_S3A)
+          .add(SCHEME_O3FS)
+          .build();
+
   /**
    * Performs a non-recursive delete of all visible (non-hidden) files in a given
    * directory. Returns the number of files deleted as part of this operation.
@@ -309,40 +367,35 @@ public class FileSystemUtil {
    * Returns true if the filesystem supports storage UUIDs in BlockLocation calls.
    */
   public static boolean supportsStorageIds(FileSystem fs) {
-    // Common case.
-    if (isDistributedFileSystem(fs)) return true;
-    // Blacklist FileSystems that are known to not to include storage UUIDs.
-    return !(fs instanceof S3AFileSystem || fs instanceof LocalFileSystem ||
-        fs instanceof AzureBlobFileSystem || fs instanceof SecureAzureBlobFileSystem ||
-        fs instanceof AdlFileSystem);
+    return SCHEME_SUPPORT_STORAGE_IDS.contains(fs.getScheme());
   }
 
   /**
    * Returns true iff the filesystem is a S3AFileSystem.
    */
   public static boolean isS3AFileSystem(FileSystem fs) {
-    return fs instanceof S3AFileSystem;
+    return hasScheme(fs, SCHEME_S3A);
   }
 
   /**
    * Returns true iff the path is on a S3AFileSystem.
    */
   public static boolean isS3AFileSystem(Path path) throws IOException {
-    return isS3AFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_S3A);
   }
 
   /**
    * Returns true iff the filesystem is AdlFileSystem.
    */
   public static boolean isADLFileSystem(FileSystem fs) {
-    return fs instanceof AdlFileSystem;
+    return hasScheme(fs, SCHEME_ADL);
   }
 
   /**
    * Returns true iff the path is on AdlFileSystem.
    */
   public static boolean isADLFileSystem(Path path) throws IOException {
-    return isADLFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_ADL);
   }
 
   /**
@@ -353,8 +406,7 @@ public class FileSystemUtil {
    * wire encryption but that does not matter in usages of this function.
    */
   public static boolean isABFSFileSystem(FileSystem fs) {
-    return fs instanceof AzureBlobFileSystem
-        || fs instanceof SecureAzureBlobFileSystem;
+    return hasScheme(fs, SCHEME_ABFS) || hasScheme(fs, SCHEME_ABFSS);
   }
 
   /**
@@ -362,49 +414,63 @@ public class FileSystemUtil {
    * SecureAzureBlobFileSystem.
    */
   public static boolean isABFSFileSystem(Path path) throws IOException {
-    return isABFSFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_ABFS) || hasScheme(path, SCHEME_ABFSS);
   }
 
   /**
    * Returns true iff the filesystem is an instance of LocalFileSystem.
    */
   public static boolean isLocalFileSystem(FileSystem fs) {
-    return fs instanceof LocalFileSystem;
+    return hasScheme(fs, SCHEME_FILE);
   }
 
   /**
    * Return true iff path is on a local filesystem.
    */
   public static boolean isLocalFileSystem(Path path) throws IOException {
-    return isLocalFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_FILE);
   }
 
   /**
    * Returns true iff the filesystem is a DistributedFileSystem.
    */
   public static boolean isDistributedFileSystem(FileSystem fs) {
-    return fs instanceof DistributedFileSystem;
+    return hasScheme(fs, SCHEME_HDFS);
   }
 
   /**
    * Return true iff path is on a DFS filesystem.
    */
   public static boolean isDistributedFileSystem(Path path) throws IOException {
-    return isDistributedFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_HDFS);
   }
 
   /**
    * Returns true iff the filesystem is a OzoneFileSystem.
    */
   public static boolean isOzoneFileSystem(FileSystem fs) {
-    return fs instanceof OzoneFileSystem;
+    return hasScheme(fs, SCHEME_O3FS);
   }
 
   /**
    * Returns true iff the path is on OzoneFileSystem.
    */
   public static boolean isOzoneFileSystem(Path path) throws IOException {
-    return isOzoneFileSystem(path.getFileSystem(CONF));
+    return hasScheme(path, SCHEME_O3FS);
+  }
+
+  /**
+   * Returns true if the filesystem protocol match the scheme.
+   */
+  private static boolean hasScheme(FileSystem fs, String scheme) {
+    return scheme.equals(fs.getScheme());
+  }
+
+  /**
+   * Returns true if the given path match the scheme.
+   */
+  private static boolean hasScheme(Path path, String scheme) {
+    return scheme.equals(path.toUri().getScheme());
   }
 
   /**
@@ -429,14 +495,14 @@ public class FileSystemUtil {
 
     private static final Map<String, FsType> SCHEME_TO_FS_MAPPING =
         ImmutableMap.<String, FsType>builder()
-            .put("abfs", ADLS)
-            .put("abfss", ADLS)
-            .put("adl", ADLS)
-            .put("file", LOCAL)
-            .put("hdfs", HDFS)
-            .put("s3a", S3)
-            .put("o3fs", OZONE)
-            .put("alluxio", ALLUXIO)
+            .put(SCHEME_ABFS, ADLS)
+            .put(SCHEME_ABFSS, ADLS)
+            .put(SCHEME_ADL, ADLS)
+            .put(SCHEME_FILE, LOCAL)
+            .put(SCHEME_HDFS, HDFS)
+            .put(SCHEME_S3A, S3)
+            .put(SCHEME_O3FS, OZONE)
+            .put(SCHEME_ALLUXIO, ALLUXIO)
             .build();
 
     /**
@@ -548,12 +614,30 @@ public class FileSystemUtil {
   public static boolean isImpalaWritableFilesystem(String location)
       throws IOException {
     Path path = new Path(location);
-    return (FileSystemUtil.isDistributedFileSystem(path) ||
-        FileSystemUtil.isLocalFileSystem(path) ||
-        FileSystemUtil.isS3AFileSystem(path) ||
-        FileSystemUtil.isABFSFileSystem(path) ||
-        FileSystemUtil.isADLFileSystem(path) ||
-        FileSystemUtil.isOzoneFileSystem(path));
+    String scheme = path.toUri().getScheme();
+    return SCHEME_WRITEABLE_BY_IMPALA.contains(scheme);
+  }
+
+  /**
+   * Returns true iff the given filesystem is supported as Impala default filesystem.
+   */
+  public static boolean isValidDefaultFileSystem(FileSystem fs) {
+    return SCHEME_SUPPORTED_AS_DEFAULT_FS.contains(fs.getScheme());
+  }
+
+  /**
+   * Returns true iff the given filesystem is valid as INPATH for LOAD DATA statement.
+   */
+  public static boolean isValidLoadDataInpath(FileSystem fs) {
+    return SCHEME_VALID_FOR_LOAD_INPATH.contains(fs.getScheme());
+  }
+
+  /**
+   * Return list of FileSystem protocol scheme that is valid as INPATH for LOAD DATA
+   * statement, delimited by comma.
+   */
+  public static String getValidLoadDataInpathSchemes() {
+    return String.join(", ", SCHEME_VALID_FOR_LOAD_INPATH);
   }
 
   /**
diff --git a/fe/src/main/java/org/apache/impala/service/JniFrontend.java b/fe/src/main/java/org/apache/impala/service/JniFrontend.java
index 324105d..0eacf29 100644
--- a/fe/src/main/java/org/apache/impala/service/JniFrontend.java
+++ b/fe/src/main/java/org/apache/impala/service/JniFrontend.java
@@ -26,12 +26,7 @@ import org.apache.hadoop.fs.CommonConfigurationKeys;
 import org.apache.hadoop.fs.CommonConfigurationKeysPublic;
 import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.adl.AdlFileSystem;
-import org.apache.hadoop.fs.azurebfs.AzureBlobFileSystem;
-import org.apache.hadoop.fs.azurebfs.SecureAzureBlobFileSystem;
-import org.apache.hadoop.fs.s3a.S3AFileSystem;
 import org.apache.hadoop.hdfs.client.HdfsClientConfigKeys;
-import org.apache.hadoop.hdfs.DistributedFileSystem;
 import org.apache.hadoop.security.Groups;
 import org.apache.hadoop.security.JniBasedUnixGroupsMappingWithFallback;
 import org.apache.hadoop.security.JniBasedUnixGroupsNetgroupMappingWithFallback;
@@ -811,11 +806,7 @@ public class JniFrontend {
   private String checkFileSystem(Configuration conf) {
     try {
       FileSystem fs = FileSystem.get(CONF);
-      if (!(fs instanceof DistributedFileSystem ||
-            fs instanceof S3AFileSystem ||
-            fs instanceof AzureBlobFileSystem ||
-            fs instanceof SecureAzureBlobFileSystem ||
-            fs instanceof AdlFileSystem)) {
+      if (!FileSystemUtil.isValidDefaultFileSystem(fs)) {
         return "Currently configured default filesystem: " +
             fs.getClass().getSimpleName() + ". " +
             CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY +
diff --git a/fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java b/fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
index bbce69b..f523c90 100644
--- a/fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
+++ b/fe/src/test/java/org/apache/impala/analysis/AnalyzeStmtsTest.java
@@ -35,6 +35,7 @@ import org.apache.impala.catalog.ScalarType;
 import org.apache.impala.catalog.Table;
 import org.apache.impala.catalog.Type;
 import org.apache.impala.common.AnalysisException;
+import org.apache.impala.common.FileSystemUtil;
 import org.apache.impala.common.ImpalaException;
 import org.apache.impala.thrift.TFunctionCategory;
 import org.junit.Assert;
@@ -3875,8 +3876,9 @@ public class AnalyzeStmtsTest extends AnalyzerTest {
       // Source must be HDFS or S3A.
       AnalysisError(String.format("load data inpath '%s' %s into table " +
           "tpch.lineitem", "file:///test-warehouse/test.out", overwrite),
-          "INPATH location 'file:/test-warehouse/test.out' must point to an " +
-          "HDFS, S3A, ADL, ABFS, or Ozone filesystem.");
+          "INPATH location 'file:/test-warehouse/test.out' must point to one of the " +
+          "supported filesystem URI scheme (" +
+          FileSystemUtil.getValidLoadDataInpathSchemes() + ").");
 
       // File type / table type mismatch.
       AnalyzesOk(String.format("load data inpath '%s' %s into table " +
diff --git a/fe/src/test/java/org/apache/impala/common/FileSystemUtilTest.java b/fe/src/test/java/org/apache/impala/common/FileSystemUtilTest.java
index da5e11e..2ed60f6 100644
--- a/fe/src/test/java/org/apache/impala/common/FileSystemUtilTest.java
+++ b/fe/src/test/java/org/apache/impala/common/FileSystemUtilTest.java
@@ -24,10 +24,13 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.assertEquals;
 
 import org.apache.hadoop.fs.FileStatus;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import java.io.IOException;
+
 /**
  * Tests for the various util methods in FileSystemUtil class
  */
@@ -86,10 +89,80 @@ public class FileSystemUtilTest {
   }
 
   @Test
-  public void testAlluxioFsType() {
-    Path path = new Path("alluxio://zk@zk-1:2181,zk-2:2181,zk-3:2181/path/");
-    assertEquals(FileSystemUtil.FsType.ALLUXIO,
-        FileSystemUtil.FsType.getFsType(path.toUri().getScheme()));
+  public void testFsType() throws IOException {
+    testFsType(mockLocation(FileSystemUtil.SCHEME_ABFS), FileSystemUtil.FsType.ADLS);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_ABFSS), FileSystemUtil.FsType.ADLS);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_ADL), FileSystemUtil.FsType.ADLS);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_FILE), FileSystemUtil.FsType.LOCAL);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_HDFS), FileSystemUtil.FsType.HDFS);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_S3A), FileSystemUtil.FsType.S3);
+    testFsType(mockLocation(FileSystemUtil.SCHEME_O3FS), FileSystemUtil.FsType.OZONE);
+    testFsType(
+        mockLocation(FileSystemUtil.SCHEME_ALLUXIO), FileSystemUtil.FsType.ALLUXIO);
+  }
+
+  @Test
+  public void testSupportStorageIds() throws IOException {
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_ABFS), false);
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_ABFSS), false);
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_ADL), false);
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_FILE), false);
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_S3A), false);
+
+    testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_HDFS), true);
+
+    // The following tests are disabled because the underlying systems is not included
+    // in impala mini cluster.
+    // TODO: enable following tests if we add them into impala mini cluster.
+    // testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_O3FS), true);
+    // testIsSupportStorageIds(mockLocation(FileSystemUtil.SCHEME_ALLUXIO), true);
+  }
+
+  @Test
+  public void testWriteableByImpala() throws IOException {
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_ALLUXIO), false);
+
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_ABFS), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_ABFSS), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_ADL), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_FILE), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_HDFS), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_S3A), true);
+    testIsWritableByImpala(mockLocation(FileSystemUtil.SCHEME_O3FS), true);
+  }
+
+  @Test
+  public void testSupportedDefaultFs() throws IOException {
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_ABFS), true);
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_ABFSS), true);
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_ADL), true);
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_HDFS), true);
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_S3A), true);
+
+    testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_FILE), false);
+
+    // The following tests are disabled because the underlying systems is not included
+    // in impala mini cluster.
+    // TODO: enable following tests if we add them into impala mini cluster.
+    // testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_O3FS), false);
+    // testIsSupportedDefaultFs(mockLocation(FileSystemUtil.SCHEME_ALLUXIO), false);
+  }
+
+  @Test
+  public void testValidLoadDataInpath() throws IOException {
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_ABFS), true);
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_ABFSS), true);
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_ADL), true);
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_HDFS), true);
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_S3A), true);
+
+    testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_FILE), false);
+
+    // The following tests are disabled because the underlying systems is not included
+    // in impala mini cluster.
+    // TODO: enable following tests if we add them into impala mini cluster.
+    // testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_O3FS), true);
+    // testValidLoadDataInpath(mockLocation(FileSystemUtil.SCHEME_ALLUXIO), false);
   }
 
   private boolean testIsInIgnoredDirectory(Path input) {
@@ -102,4 +175,60 @@ public class FileSystemUtilTest {
     Mockito.when(mockFileStatus.isDirectory()).thenReturn(isDir);
     return FileSystemUtil.isInIgnoredDirectory(TEST_TABLE_PATH, mockFileStatus);
   }
+
+  private String mockLocation(String scheme) throws IOException {
+    switch (scheme) {
+      case FileSystemUtil.SCHEME_ABFS:
+        return "abfs://dummy-fs@dummy-account.dfs.core.windows.net/dummy-part-1";
+      case FileSystemUtil.SCHEME_ABFSS:
+        return "abfss://dummy-fs@dummy-account.dfs.core.windows.net/dummy-part-2";
+      case FileSystemUtil.SCHEME_ADL:
+        return "adl://dummy-account.azuredatalakestore.net/dummy-part-3";
+      case FileSystemUtil.SCHEME_FILE:
+        return "file://tmp/dummy-part-4";
+      case FileSystemUtil.SCHEME_HDFS:
+        return "hdfs://localhost:20500/dummy-part-5";
+      case FileSystemUtil.SCHEME_S3A:
+        return "s3a://dummy-bucket/dummy-part-6";
+      case FileSystemUtil.SCHEME_O3FS:
+        return "o3fs://bucket.volume/key";
+      case FileSystemUtil.SCHEME_ALLUXIO:
+        return "alluxio://zk@zk-1:2181,zk-2:2181,zk-3:2181/path/";
+      default:
+        throw new IOException("FileSystem scheme is not supported!");
+    }
+  }
+
+  private void testFsType(String location, FileSystemUtil.FsType expected) {
+    Path path = new Path(location);
+    FileSystemUtil.FsType type =
+        FileSystemUtil.FsType.getFsType(path.toUri().getScheme());
+    assertEquals(type, expected);
+  }
+
+  private void testIsSupportStorageIds(String location, boolean expected)
+      throws IOException {
+    Path path = new Path(location);
+    FileSystem fs = FileSystemUtil.getFileSystemForPath(path);
+    assertEquals(FileSystemUtil.supportsStorageIds(fs), expected);
+  }
+
+  private void testIsWritableByImpala(String location, boolean expected)
+      throws IOException {
+    assertEquals(FileSystemUtil.isImpalaWritableFilesystem(location), expected);
+  }
+
+  private void testIsSupportedDefaultFs(String location, boolean expected)
+      throws IOException {
+    Path path = new Path(location);
+    FileSystem fs = FileSystemUtil.getFileSystemForPath(path);
+    assertEquals(FileSystemUtil.isValidDefaultFileSystem(fs), expected);
+  }
+
+  private void testValidLoadDataInpath(String location, boolean expected)
+      throws IOException {
+    Path path = new Path(location);
+    FileSystem fs = FileSystemUtil.getFileSystemForPath(path);
+    assertEquals(FileSystemUtil.isValidLoadDataInpath(fs), expected);
+  }
 }