RjLi13 commented on code in PR #13979:
URL: https://github.com/apache/iceberg/pull/13979#discussion_r3220256673
##########
core/src/main/java/org/apache/iceberg/rest/RESTUtil.java:
##########
@@ -386,4 +390,53 @@ public static Map<String, String>
configHeaders(Map<String, String> properties)
public static Map<String, String> idempotencyHeaders() {
return ImmutableMap.of(IDEMPOTENCY_KEY_HEADER,
UUIDUtil.generateUuidV7().toString());
}
+
+ /**
+ * Builds query parameters for credential endpoints, including planId and
referenced-by if
+ * present.
+ *
+ * @param planId the scan plan ID, or null if not set
+ * @param properties configuration properties that may contain a
referenced-by value
+ * @return a map of query parameters, or null if no parameters are needed
+ */
+ public static Map<String, String> credentialsQueryParams(
+ String planId, Map<String, String> properties) {
+ Map<String, String> queryParams = Maps.newHashMap();
+ if (planId != null) {
+ queryParams.put(RESTCatalogProperties.PLAN_ID_QUERY_PARAMETER, planId);
+ }
+
+ String referencedBy =
properties.get(RESTCatalogProperties.REFERENCED_BY_QUERY_PARAMETER);
+ if (referencedBy != null) {
+ queryParams.put(RESTCatalogProperties.REFERENCED_BY_QUERY_PARAMETER,
referencedBy);
+ }
+
+ return queryParams.isEmpty() ? null : queryParams;
+ }
+
+ /**
+ * Encode a view identifier chain as a referenced-by query parameter.
+ *
+ * @param referencedBy ordered list of view identifiers from outermost to
innermost
+ * @param namespaceSeparator the separator to use between namespace levels
and name
+ * @return a map with the referenced-by query parameter, or an empty map if
no chain is present
+ */
+ public static Map<String, String> referencedByToQueryParam(
+ List<TableIdentifier> referencedBy, String namespaceSeparator) {
+ if (referencedBy == null || referencedBy.isEmpty()) {
+ return Map.of();
+ }
+
+ List<String> encoded =
+ referencedBy.stream()
+ .map(
+ ident ->
+ encodeNamespace(ident.namespace(), namespaceSeparator)
+ + namespaceSeparator
Review Comment:
Should the namespaceSeparator be url decoded first like in
namespaceToQueryParam? Otherwise server would receive
prod%251F%251Fanalytics%251Fquarterly_view with %1F being url-encoded again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]