Skip to content

Commit

Permalink
Throw error when respondedFormat doesn't match requested responseForm…
Browse files Browse the repository at this point in the history
…at (#393)

* throw error when respondedFormat doesn't match requested responseFormat

* fix
  • Loading branch information
linzhou-db authored Sep 14, 2023
1 parent 63854e1 commit bbb5908
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,12 @@ class DeltaSharingRestClient(
if (responseFormat != respondedFormat) {
// This could only happen when the asked format is delta and the server doesn't support
// the requested format.
logWarning(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
logError(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
s"$responseFormat) for getMetadata.${table.share}.${table.schema}.${table.name}.")
throw new IllegalArgumentException("The responseFormat returned from the delta sharing " +
s"server doesn't match the requested responseFormat: respondedFormat($respondedFormat)" +
s" != requestedFormat($responseFormat)." +
s"This is likely because the server is not upgraded to support delta format sharing.")
}
// To ensure that it works with delta sharing server that doesn't support the requested format.
if (respondedFormat == RESPONSE_FORMAT_DELTA) {
Expand Down Expand Up @@ -313,9 +317,13 @@ class DeltaSharingRestClient(
}

if (responseFormat != respondedFormat) {
logWarning(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
logError(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
s"$responseFormat) for getFiles(versionAsOf-$versionAsOf, timestampAsOf-$timestampAsOf " +
s"for table ${table.share}.${table.schema}.${table.name}.")
throw new IllegalArgumentException("The responseFormat returned from the delta sharing " +
s"server doesn't match the requested responseFormat: respondedFormat($respondedFormat)" +
s" != requestedFormat($responseFormat)." +
s"This is likely because the server is not upgraded to support delta format sharing.")
}
// To ensure that it works with delta sharing server that doesn't support the requested format.
if (respondedFormat == RESPONSE_FORMAT_DELTA) {
Expand Down Expand Up @@ -363,9 +371,13 @@ class DeltaSharingRestClient(
getNDJson(target, request)
}
if (responseFormat != respondedFormat) {
logWarning(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
logError(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
s"$responseFormat) for getFiles(startingVersion-$startingVersion, endingVersion-" +
s"$endingVersion) for table ${table.share}.${table.schema}.${table.name}.")
throw new IllegalArgumentException("The responseFormat returned from the delta sharing " +
s"server doesn't match the requested responseFormat: respondedFormat($respondedFormat)" +
s" != requestedFormat($responseFormat)." +
s"This is likely because the server is not upgraded to support delta format sharing.")
}
// To ensure that it works with delta sharing server that doesn't support the requested format.
if (respondedFormat == RESPONSE_FORMAT_DELTA) {
Expand Down Expand Up @@ -481,9 +493,13 @@ class DeltaSharingRestClient(
getNDJson(target, requireVersion = false)
}
if (responseFormat != respondedFormat) {
logWarning(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
logError(s"RespondedFormat($respondedFormat) is different from requested responseFormat(" +
s"$responseFormat) for getCDFFiles(cdfOptions-$cdfOptions) for table " +
s"${table.share}.${table.schema}.${table.name}.")
throw new IllegalArgumentException("The responseFormat returned from the delta sharing " +
s"server doesn't match the requested responseFormat: respondedFormat($respondedFormat)" +
s" != requestedFormat($responseFormat)." +
s"This is likely because the server is not upgraded to support delta format sharing.")
}
// To ensure that it works with delta sharing server that doesn't support the requested format.
if (respondedFormat == RESPONSE_FORMAT_DELTA) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,12 @@ class DeltaSharingService(serverConfig: ServerConfig) {
if (headerString == null) {
return Map.empty[String, String]
}
headerString.toLowerCase().split(",").map { capability =>
val splits = capability.split("=")
if (splits.size == 2) {
headerString.toLowerCase().split(";")
.map(_.split("="))
.filter(_.size == 2)
.map { splits =>
(splits(0), splits(1))
} else {
("", "")
}
}.toMap
}.toMap
}

@Get("/shares/{share}/schemas/{schema}/tables/{table}/metadata")
Expand Down

0 comments on commit bbb5908

Please sign in to comment.