ebyhr commented on code in PR #16069:
URL: https://github.com/apache/iceberg/pull/16069#discussion_r3120741631
##########
core/src/main/java/org/apache/iceberg/rest/RESTCatalog.java:
##########
@@ -93,9 +99,56 @@ protected RESTSessionCatalog newSessionCatalog(
@Override
public void initialize(String name, Map<String, String> props) {
Preconditions.checkArgument(props != null, "Invalid configuration: null");
+
+ this.caseInsensitive =
+ PropertyUtil.propertyAsBoolean(
+ props, CatalogProperties.CASE_INSENSITIVE,
CatalogProperties.CASE_INSENSITIVE_DEFAULT);
+ this.caseType =
+ PropertyUtil.propertyAsString(
+ props,
+ CatalogProperties.CASE_INSENSITIVE_TYPE,
+ CatalogProperties.CASE_INSENSITIVE_TYPE_DEFAULT);
+ Preconditions.checkArgument(
+ "lower_case".equals(caseType) || "upper_case".equals(caseType),
+ "Invalid value for '%s': %s. Allowed values are: lower_case,
upper_case",
+ CatalogProperties.CASE_INSENSITIVE_TYPE,
+ caseType);
+
sessionCatalog.initialize(name, props);
}
+ @VisibleForTesting
+ Namespace convertCase(Namespace ns) {
+ if (!caseInsensitive) {
+ return ns;
+ }
+
+ String[] levels = ns.levels();
+ String[] converted = new String[levels.length];
+ for (int i = 0; i < levels.length; i++) {
+ converted[i] =
+ "upper_case".equals(caseType)
+ ? levels[i].toUpperCase(Locale.ROOT)
+ : levels[i].toLowerCase(Locale.ROOT);
+ }
+
+ return Namespace.of(converted);
+ }
+
+ @VisibleForTesting
+ TableIdentifier convertCase(TableIdentifier ident) {
+ if (!caseInsensitive) {
+ return ident;
+ }
+
+ Namespace convertedNs = convertCase(ident.namespace());
+ String convertedName =
+ "upper_case".equals(caseType)
+ ? ident.name().toUpperCase(Locale.ROOT)
+ : ident.name().toLowerCase(Locale.ROOT);
+ return TableIdentifier.of(convertedNs, convertedName);
Review Comment:
Trino Iceberg connector supports the
`iceberg.rest-catalog.case-insensitive-name-matching` configuration property,
but its behavior differs from the approach in this PR. I'm commenting here
because the PR description refers to Trino.
The connector attempts to locate remote objects in a case-insensitive way by
iterating over namespaces and tables and comparing their lowercase forms. If it
encounters an ambiguous situation (for example, both ORDERS and orders exist),
it throws an exception. This logic correctly handles mixed-case names, whereas
this PR appears to address only the uppercase case.
--
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]