Skip to content

Commit

Permalink
[Hotfix][Connector-V2][Hive] Fix hive unknownhost (#4141)
Browse files Browse the repository at this point in the history
* [Hotfix][Connector-V2][Hive] Fix the bug that can not load hdfs-site.xml
  • Loading branch information
TyrantLucifer authored Feb 16, 2023
1 parent 32e1f91 commit f1a1dfe
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/en/connector-v2/sink/Hive.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ By default, we use 2PC commit to ensure `exactly-once`
| table_name | string | yes | - |
| metastore_uri | string | yes | - |
| compress_codec | string | no | none |
| hdfs_site_path | string | no | - |
| kerberos_principal | string | no | - |
| kerberos_keytab_path | string | no | - |
| common-options | | no | - |
Expand All @@ -47,6 +48,10 @@ Target Hive table name eg: db1.table1

Hive metastore uri

### hdfs_site_path [string]

The path of `hdfs-site.xml`, used to load ha configuration of namenodes

### kerberos_principal [string]

The principal of kerberos
Expand Down
5 changes: 5 additions & 0 deletions docs/en/connector-v2/source/Hive.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Read all the data in a split in a pollNext call. What splits are read will be sa
| metastore_uri | string | yes | - |
| kerberos_principal | string | no | - |
| kerberos_keytab_path | string | no | - |
| hdfs_site_path | string | no | - |
| read_partitions | list | no | - |
| common-options | | no | - |

Expand All @@ -50,6 +51,10 @@ Target Hive table name eg: db1.table1

Hive metastore uri

### hdfs_site_path [string]

The path of `hdfs-site.xml`, used to load ha configuration of namenodes

### read_partitions [list]

The target partitions that user want to read from hive table, if user does not set this parameter, it will read all the data from hive table.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import java.util.Optional;
import java.util.stream.Collectors;

import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.FS_DEFAULT_NAME_KEY;
import static org.apache.seatunnel.connectors.seatunnel.file.config.BaseSinkConfig.FIELD_DELIMITER;
import static org.apache.seatunnel.connectors.seatunnel.file.config.BaseSinkConfig.FILE_FORMAT;
import static org.apache.seatunnel.connectors.seatunnel.file.config.BaseSinkConfig.FILE_NAME_EXPRESSION;
Expand Down Expand Up @@ -157,9 +158,13 @@ public void prepare(Config pluginConfig) throws PrepareFailException {
try {
URI uri = new URI(hdfsLocation);
String path = uri.getPath();
pluginConfig =
pluginConfig.withValue(FILE_PATH.key(), ConfigValueFactory.fromAnyRef(path));
hadoopConf = new HadoopConf(hdfsLocation.replace(path, ""));
pluginConfig =
pluginConfig
.withValue(FILE_PATH.key(), ConfigValueFactory.fromAnyRef(path))
.withValue(
FS_DEFAULT_NAME_KEY,
ConfigValueFactory.fromAnyRef(hadoopConf.getHdfsNameKey()));
} catch (URISyntaxException e) {
String errorMsg =
String.format(
Expand All @@ -170,6 +175,7 @@ public void prepare(Config pluginConfig) throws PrepareFailException {
HiveConnectorErrorCode.GET_HDFS_NAMENODE_HOST_FAILED, errorMsg, e);
}
this.pluginConfig = pluginConfig;
super.prepare(pluginConfig);
}

@Override
Expand Down

0 comments on commit f1a1dfe

Please sign in to comment.