Skip to content

Commit

Permalink
branch-3.0: [fix](hive) Incorrect location conversion for target path #…
Browse files Browse the repository at this point in the history
…47162 (#47329)

Cherry-picked from #47162

Co-authored-by: wuwenchi <[email protected]>
  • Loading branch information
github-actions[bot] and wuwenchi authored Feb 22, 2025
1 parent e4367e2 commit 06302d2
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public LocationPath(String location, Map<String, String> props) {
this(location, props, true);
}

private LocationPath(String originLocation, Map<String, String> props, boolean convertPath) {
public LocationPath(String originLocation, Map<String, String> props, boolean convertPath) {
isBindBroker = props.containsKey(HMSExternalCatalog.BIND_BROKER_NAME);
String tmpLocation = originLocation;
if (!(originLocation.contains(SCHEME_DELIM) || originLocation.contains(NONSTANDARD_SCHEME_DELIM))) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public void bindDataSink(Optional<InsertCommandContext> insertCtx)
setSerDeProperties(tSink);

THiveLocationParams locationParams = new THiveLocationParams();
LocationPath locationPath = new LocationPath(sd.getLocation(), targetTable.getHadoopProperties());
LocationPath locationPath = new LocationPath(sd.getLocation(), targetTable.getHadoopProperties(), false);
String location = locationPath.getPath().toString();
String storageLocation = locationPath.toStorageLocation().toString();
TFileType fileType = locationPath.getTFileTypeForBE();
if (fileType == TFileType.FILE_S3) {
locationParams.setWritePath(storageLocation);
locationParams.setOriginalWritePath(sd.getLocation());
locationParams.setOriginalWritePath(location);
locationParams.setTargetPath(location);
if (insertCtx.isPresent()) {
HiveInsertCommandContext context = (HiveInsertCommandContext) insertCtx.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import org.apache.hadoop.hive.metastore.api.SerDeInfo;
import org.apache.hadoop.hive.metastore.api.StorageDescriptor;
import org.apache.hadoop.hive.metastore.api.Table;
import org.junit.Assert;
import org.junit.Test;
import org.locationtech.jts.util.Assert;

import java.util.ArrayList;
import java.util.HashMap;
Expand Down Expand Up @@ -94,7 +94,8 @@ public HMSCachedClient getClient() {
HiveTableSink hiveTableSink = new HiveTableSink(tbl);
hiveTableSink.bindDataSink(Optional.empty());

Assert.equals(hiveTableSink.tDataSink.hive_table_sink.location.original_write_path, location);
Assert.assertEquals(hiveTableSink.tDataSink.hive_table_sink.location.original_write_path, location);
Assert.assertEquals(hiveTableSink.tDataSink.hive_table_sink.location.target_path, location);
}
}

Expand Down

0 comments on commit 06302d2

Please sign in to comment.