apache/seatunnel · error · HiveConnectorException

GET_HDFS_NAMENODE_HOST_FAILED

GET_HDFS_NAMENODE_HOST_FAILED

Error message

Get hdfs namenode host from table location [%s] failed,please check it

What it means

Thrown when the Hive table's storage location (table.getSd().getLocation()) cannot be parsed as a valid URI while extracting the HDFS namenode prefix (fs.default name). The connector builds a java.net.URI from the location string; a URISyntaxException means the location is malformed (illegal characters, spaces, unmatched brackets, etc.).

Source

Thrown at seatunnel-connectors-v2/connector-hive/src/main/java/org/apache/seatunnel/connectors/seatunnel/hive/source/config/HiveSourceConfig.java:269

            }
            current = current.getCause();
        }
        return false;
    }

    private String parseFsDefaultName(Table table) {
        String hdfsLocation = table.getSd().getLocation();
        try {
            URI uri = new URI(hdfsLocation);
            String path = uri.getPath();
            return hdfsLocation.replace(path, "");
        } catch (URISyntaxException e) {
            String errorMsg =
                    String.format(
                            "Get hdfs namenode host from table location [%s] failed,"
                                    + "please check it",
                            hdfsLocation);
            throw new HiveConnectorException(
                    HiveConnectorErrorCode.GET_HDFS_NAMENODE_HOST_FAILED, errorMsg, e);
        }
    }

    private String parseHdfsPath(Table table) {
        String hdfsLocation = table.getSd().getLocation();
        try {
            URI uri = new URI(hdfsLocation);
            return uri.getPath();
        } catch (URISyntaxException e) {
            String errorMsg =
                    String.format(
                            "Get hdfs namenode host from table location [%s] failed,"
                                    + "please check it",
                            hdfsLocation);
            throw new HiveConnectorException(
                    HiveConnectorErrorCode.GET_HDFS_NAMENODE_HOST_FAILED, errorMsg, e);
        }

View on GitHub (pinned to cf67b549a7)

Solutions

  1. Run `new URI(location)` (or `DESCRIBE FORMATTED <table>`) on the location reported in the message and fix the illegal characters in the table's LOCATION
  2. Correct the table location in Hive: `ALTER TABLE <db>.<table> SET LOCATION 'hdfs://namenode:8020/path/to/table'` (URL-encode any spaces/special chars)
  3. Check the Hive metastore warehouse default location property (hive.metastore.warehouse.dir) for the same malformation
  4. If the location string contains spaces, encode them (%20) rather than leaving raw characters

Example fix

// before (broken metastore location)
LOCATION 'hdfs://namenode:8020/user/hive/warehouse/my table'
// after
ALTER TABLE my_db.my_table SET LOCATION 'hdfs://namenode:8020/user/hive/warehouse/my%20table'
Defensive patterns

Strategy: validation

Validate before calling

// Validate the table location URI before submitting the job
String loc = table.getSd().getLocation();
try {
    new java.net.URI(loc);
} catch (java.net.URISyntaxException e) {
    throw new IllegalArgumentException(
        "Invalid Hive table LOCATION URI: " + loc + " -> " + e.getMessage());
}

Type guard

boolean isValidUri(String s) {
    try { new java.net.URI(s); return true; }
    catch (java.net.URISyntaxException e) { return false; }
}

Try / catch

try {
    // ... start Hive source
} catch (org.apache.seatunnel.connectors.seatunnel.hive.exception.HiveConnectorException e) {
    if ("GET_HDFS_NAMENODE_HOST_FAILED".equals(e.getSeaTunnelErrorCode().getCode())) {
        LOG.error("Fix the table LOCATION URI: {}", e.getMessage());
    }
    throw e;
}

Prevention

When it happens

Trigger: HiveSourceConfig.parseFsDefaultName is invoked during source config parsing and `new URI(hdfsLocation)` throws URISyntaxException because the metastore-returned table location is not a valid URI (e.g. contains spaces, backslashes, illegal characters, or a malformed scheme like 'hdfs:/name' or missing host with port).

Common situations: Tables created manually in the metastore with a hand-typed LOCATION; locations copied from Windows paths with backslashes; locations with unencoded spaces or special characters; corrupted metastore entries after cluster migration.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10). Data as JSON: /api/errors/cccfafb1b5934584. Report an issue: GitHub.