Skip to content

Commit ac9ed8a

Browse files
committed
check Iceberg catalog URL for GCP connections at plan time
1 parent 059dc7d commit ac9ed8a

3 files changed

Lines changed: 14 additions & 2 deletions

File tree

src/sql/src/plan/statement/ddl/connection.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,18 @@ impl ConnectionOptionExtracted {
729729
credential,
730730
scope: self.scope.clone(),
731731
},
732-
(None, Some(gcp_connection)) => IcebergCatalogAuth::Gcp(gcp_connection),
732+
(None, Some(gcp_connection)) => {
733+
/// All BigLake Iceberg REST Catalogs use the same catalog URI.
734+
const BIGLAKE_CATALOG_URI: &str =
735+
"https://biglake.googleapis.com/iceberg/v1/restcatalog";
736+
if uri.to_string() != BIGLAKE_CATALOG_URI {
737+
sql_bail!(
738+
"GCP connection can only be used with '{}'",
739+
BIGLAKE_CATALOG_URI
740+
);
741+
}
742+
IcebergCatalogAuth::Gcp(gcp_connection)
743+
}
733744
(None, None) => sql_bail!(
734745
"invalid CONNECTION: ICEBERG rest connections require a CREDENTIAL or GCP CONNECTION"
735746
),

src/storage-types/src/connections.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,7 @@ impl IcebergCatalogConnection<InlinedConnection> {
915915
GCS_CREDENTIALS_JSON.to_owned(),
916916
base64::engine::general_purpose::STANDARD.encode(creds_json),
917917
);
918+
// We supplied a service account key. Don't look elsewhere for GCP credentials.
918919
props.insert(GCS_DISABLE_VM_METADATA.to_owned(), "true".to_owned());
919920
props.insert(GCS_DISABLE_CONFIG_LOAD.to_owned(), "true".to_owned());
920921
if let Some(project_id) = service_account.project_id() {

test/iceberg/gcp-connection-validation.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ ALTER SYSTEM SET enable_default_connection_validation = false
2929
GCP CONNECTION = gcpconn,
3030
WAREHOUSE = 'gs://anything'
3131
)
32-
contains:must point URL at a *.googleapis.com host
32+
contains:GCP connection can only be used with 'https://biglake.googleapis.com/iceberg/v1/restcatalog'
3333

3434
# Positive control: a real BigLake host is accepted, so the allowlist doesn't
3535
# break the feature.

0 commit comments

Comments
 (0)