dimas-b commented on code in PR #4050:
URL: https://github.com/apache/polaris/pull/4050#discussion_r3087623134


##########
polaris-core/src/main/java/org/apache/polaris/core/connection/bigquery/BigQueryMetastoreConnectionConfigInfoDpo.java:
##########
@@ -0,0 +1,155 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.polaris.core.connection.bigquery;
+
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.google.common.base.MoreObjects;
+import jakarta.annotation.Nonnull;
+import jakarta.annotation.Nullable;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Optional;
+import org.apache.iceberg.CatalogProperties;
+import 
org.apache.polaris.core.admin.model.BigQueryMetastoreConnectionConfigInfo;
+import org.apache.polaris.core.admin.model.ConnectionConfigInfo;
+import org.apache.polaris.core.connection.AuthenticationParametersDpo;
+import org.apache.polaris.core.connection.ConnectionConfigInfoDpo;
+import org.apache.polaris.core.connection.ConnectionType;
+import org.apache.polaris.core.credentials.PolarisCredentialManager;
+import org.apache.polaris.core.credentials.connection.ConnectionCredentials;
+import org.apache.polaris.core.identity.dpo.ServiceIdentityInfoDpo;
+import org.apache.polaris.core.identity.provider.ServiceIdentityProvider;
+
+/**
+ * The internal persistence-object counterpart to {@link
+ * org.apache.polaris.core.admin.model.BigQueryMetastoreConnectionConfigInfo} 
defined in the API
+ * model.
+ */
+public class BigQueryMetastoreConnectionConfigInfoDpo extends 
ConnectionConfigInfoDpo {
+
+  public static final String DEFAULT_URI = "https://bigquery.googleapis.com";;
+
+  // BigQuery Metastore catalog property keys
+  private static final String GCP_BIGQUERY_PROJECT_ID = 
"gcp.bigquery.project-id";
+
+  private final String warehouse;
+  private final String gcpProjectId;
+
+  public BigQueryMetastoreConnectionConfigInfoDpo(
+      @JsonProperty(value = "uri", required = true) @Nonnull String uri,
+      @JsonProperty(value = "authenticationParameters", required = false) 
@Nullable
+          AuthenticationParametersDpo authenticationParameters,
+      @JsonProperty(value = "warehouse", required = true) @Nonnull String 
warehouse,
+      @JsonProperty(value = "gcpProjectId", required = true) @Nonnull String 
gcpProjectId,
+      @JsonProperty(value = "properties", required = false) @Nullable
+          Map<String, String> properties,
+      @JsonProperty(value = "serviceIdentity", required = false) @Nullable
+          ServiceIdentityInfoDpo serviceIdentity) {
+    super(
+        ConnectionType.BIGQUERY.getCode(),
+        uri,
+        authenticationParameters,
+        serviceIdentity,
+        properties);
+    this.warehouse = warehouse;
+    this.gcpProjectId = gcpProjectId;
+  }
+
+  public String getWarehouse() {
+    return warehouse;
+  }
+
+  public String getGcpProjectId() {
+    return gcpProjectId;
+  }
+
+  @Override
+  public String toString() {
+    return MoreObjects.toStringHelper(this)
+        .add("connectionTypeCode", getConnectionTypeCode())
+        .add("uri", getUri())
+        .add("warehouse", warehouse)
+        .add("gcpProjectId", gcpProjectId)
+        .add(
+            "authenticationParameters",
+            getAuthenticationParameters() != null
+                ? getAuthenticationParameters().toString()
+                : "null")
+        .toString();
+  }
+
+  @Override
+  public @Nonnull Map<String, String> asIcebergCatalogProperties(
+      PolarisCredentialManager polarisCredentialManager) {
+    HashMap<String, String> properties = new HashMap<>();
+
+    // Required properties for BigQueryMetastoreCatalog
+    properties.put(GCP_BIGQUERY_PROJECT_ID, gcpProjectId);
+    properties.put(CatalogProperties.WAREHOUSE_LOCATION, warehouse);

Review Comment:
   Retracting API changes is not ideal (in a follow-up). 
   
   I'd propose to remove `gcpProjectId` and `warehouse` from OpenAPI _explicit_ 
properties and process corresponding Iceberg properties from the generic 
`properties` bag. Also, add description to OpenAPI YAML to list required 
properties.
   
   My rationale is that it is fine to accept pass-through properties destined 
to become Iceberg (federated) catalog properties. Yet, specific processing / 
validate is a feature of the implementation and can change in new Polaris 
versions without requiring API changes.
   
   I wonder what other reviewers think about this.



-- 
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]

Reply via email to