Skip to content

Commit

Permalink
tmp2
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-alhuang committed Jun 10, 2024
1 parent f1c1824 commit 25696a7
Showing 1 changed file with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ SnowflakeFileTransferMetadataV1 fetchSignedURL(String fileName)
Map<String, Object> response = this.makeConfigureCall(payload);

JsonNode responseNode =
this.parseStageLocation(mapper.valueToTree(response).get("stage_location"));
this.parseConfigureResponse(response);

SnowflakeFileTransferMetadataV1 metadata =
(SnowflakeFileTransferMetadataV1)
Expand All @@ -278,6 +278,22 @@ protected JsonNode parseStageLocation(JsonNode stageLocation) {
return responseNode;
}

private JsonNode parseConfigureResponse(Map<String, Object> response) {
JsonNode responseNode = mapper.valueToTree(response);

// Currently there are a few mismatches between the client/configure response and what
// SnowflakeFileTransferAgent expects
ObjectNode mutable = (ObjectNode) responseNode;
mutable.putObject("data");
ObjectNode dataNode = (ObjectNode) mutable.get("data");
dataNode.set("stageInfo", responseNode.get("stage_location"));

// JDBC expects this field which maps to presignedFileUrlName. We will set this later
dataNode.putArray("src_locations").add("placeholder");
return responseNode;
}


/**
* Gets new storage credentials and other metadata from Snowflake. Synchronized to prevent
* multiple calls to putRemote from trying to refresh at the same time
Expand All @@ -301,7 +317,7 @@ synchronized SnowflakeFileTransferMetadataWithAge refreshCloudStorageMetadata(bo
Map<String, Object> response = this.makeConfigureCall(payload);

JsonNode responseNode =
this.parseStageLocation(mapper.valueToTree(response).get("stage_location"));
this.parseConfigureResponse(response);
// Do not change the prefix everytime we have to refresh credentials
if (Utils.isNullOrEmpty(this.clientPrefix)) {
this.clientPrefix = createClientPrefix(responseNode);
Expand Down

0 comments on commit 25696a7

Please sign in to comment.