gaborkaszab commented on code in PR #15991:
URL: https://github.com/apache/iceberg/pull/15991#discussion_r3093244994
##########
bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryProperties.java:
##########
@@ -101,11 +101,37 @@ List<String> expandScopes(List<String> inputScopes) {
BigQueryProperties(Map<String, String> properties) {
Preconditions.checkNotNull(properties, "Properties cannot be null");
- this.projectId = properties.get(PROJECT_ID);
+ Preconditions.checkArgument(
+ !(properties.containsKey(PROJECT_ID)
+ && properties.containsKey(HistoricalPropertyNames.PROJECT_ID)),
+ "Invalid GCP project configuration. "
+ + "Found both properties '%s' and '%s', only one must be used.",
+ PROJECT_ID,
+ HistoricalPropertyNames.PROJECT_ID);
+ Preconditions.checkArgument(
Review Comment:
Probably no need for this check because seem to overlap with the one at L129
##########
bigquery/src/main/java/org/apache/iceberg/gcp/bigquery/BigQueryProperties.java:
##########
@@ -101,11 +101,37 @@ List<String> expandScopes(List<String> inputScopes) {
BigQueryProperties(Map<String, String> properties) {
Preconditions.checkNotNull(properties, "Properties cannot be null");
- this.projectId = properties.get(PROJECT_ID);
+ Preconditions.checkArgument(
+ !(properties.containsKey(PROJECT_ID)
+ && properties.containsKey(HistoricalPropertyNames.PROJECT_ID)),
+ "Invalid GCP project configuration. "
+ + "Found both properties '%s' and '%s', only one must be used.",
+ PROJECT_ID,
+ HistoricalPropertyNames.PROJECT_ID);
+ Preconditions.checkArgument(
+ properties.containsKey(PROJECT_ID)
+ || properties.containsKey(HistoricalPropertyNames.PROJECT_ID),
+ "Invalid GCP project: %s must be specified",
+ PROJECT_ID);
+
+ Preconditions.checkArgument(
+ !(properties.containsKey(GCP_LOCATION)
+ && properties.containsKey(HistoricalPropertyNames.GCP_LOCATION)),
+ "Invalid warehouse location configuration. "
+ + "Found both properties '%s' and '%s', only one must be used.",
+ GCP_LOCATION,
+ HistoricalPropertyNames.GCP_LOCATION);
+
+ this.projectId =
+ properties.containsKey(PROJECT_ID)
+ ? properties.get(PROJECT_ID)
+ : properties.get(HistoricalPropertyNames.PROJECT_ID);
Preconditions.checkArgument(
projectId != null, "Invalid GCP project: %s must be specified",
PROJECT_ID);
- this.location = properties.getOrDefault(GCP_LOCATION,
DEFAULT_GCP_LOCATION);
+ String fallbackLocation =
Review Comment:
`this.location` could be populated the same way as `this.projectId` by using
a ternary operator to handle the fallback.
You might want to consider using PropertyUtil too:
```
PropertyUtil.propertyAsString(
mergedProps,
RESTCatalogProperties.NAMESPACE_SEPARATOR,
RESTUtil.NAMESPACE_SEPARATOR_URLENCODED_UTF_8);
```
--
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]