diff --git a/src/main/java/net/snowflake/ingest/streaming/internal/AbstractCloudStorage.java b/src/main/java/net/snowflake/ingest/streaming/internal/AbstractCloudStorage.java index 10d8f9177..e08faedd7 100644 --- a/src/main/java/net/snowflake/ingest/streaming/internal/AbstractCloudStorage.java +++ b/src/main/java/net/snowflake/ingest/streaming/internal/AbstractCloudStorage.java @@ -254,7 +254,7 @@ SnowflakeFileTransferMetadataV1 fetchSignedURL(String fileName) Map response = this.makeConfigureCall(payload); JsonNode responseNode = - this.parseStageLocation(mapper.valueToTree(response).get("stage_location")); + this.parseConfigureResponse(response); SnowflakeFileTransferMetadataV1 metadata = (SnowflakeFileTransferMetadataV1) @@ -278,6 +278,22 @@ protected JsonNode parseStageLocation(JsonNode stageLocation) { return responseNode; } + private JsonNode parseConfigureResponse(Map 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 @@ -301,7 +317,7 @@ synchronized SnowflakeFileTransferMetadataWithAge refreshCloudStorageMetadata(bo Map 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);