Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions src/catalog.jl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,21 @@ mutable struct NestedStringListResponse
NestedStringListResponse() = new(-1, C_NULL, 0, C_NULL, C_NULL, C_NULL)
end

# iceberg-rust's REST catalog client infers `rest.auth.type=oauth2` whenever `token`,
# `credential`, or `oauth2-server-uri` is set and `rest.auth.type` itself isn't -- and logs a
# WARN every time it does, specifically to nudge callers into setting `rest.auth.type`
# explicitly instead of relying on inference (see `RestCatalogConfig::auth_type` in
# iceberg-catalog-rest). Since we already have the same information available here, we can
# be that explicit caller ourselves and avoid the warning entirely, rather than pushing this
# onto every caller of `catalog_create_rest`.
const _REST_OAUTH2_INFERENCE_PROPS = ("token", "credential", "oauth2-server-uri")

function _with_inferred_rest_auth_type(properties::Dict{String,String})
haskey(properties, "rest.auth.type") && return properties
any(k -> haskey(properties, k), _REST_OAUTH2_INFERENCE_PROPS) || return properties
return merge(properties, Dict("rest.auth.type" => "oauth2"))
end

"""
catalog_create_rest(
uri::String;
Expand Down Expand Up @@ -252,6 +267,7 @@ function catalog_create_rest(
end

# Initialize the catalog with REST connection
properties = _with_inferred_rest_auth_type(properties)
# Convert properties dict to array of PropertyEntry structs
property_entries = [PropertyEntry(pointer(k), pointer(v)) for (k, v) in properties]
properties_len = length(property_entries)
Expand Down Expand Up @@ -369,6 +385,7 @@ function catalog_create_rest(
end

# Step 6: Initialize the catalog with REST connection
properties = _with_inferred_rest_auth_type(properties)
# Convert properties dict to array of PropertyEntry structs
property_entries = [PropertyEntry(pointer(k), pointer(v)) for (k, v) in properties]
properties_len = length(property_entries)
Expand Down
Loading