olsoloviov commented on code in PR #3293: URL: https://github.com/apache/polaris/pull/3293#discussion_r2632070902
########## runtime/service/src/main/java/org/apache/polaris/service/events/EventAttributes.java: ########## @@ -0,0 +1,248 @@ +/* + * 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.service.events; + +import java.util.Map; +import org.apache.iceberg.TableMetadata; +import org.apache.iceberg.catalog.Namespace; +import org.apache.iceberg.catalog.TableIdentifier; +import org.apache.iceberg.rest.requests.CommitTransactionRequest; +import org.apache.iceberg.rest.requests.CreateNamespaceRequest; +import org.apache.iceberg.rest.requests.CreateTableRequest; +import org.apache.iceberg.rest.requests.CreateViewRequest; +import org.apache.iceberg.rest.requests.RegisterTableRequest; +import org.apache.iceberg.rest.requests.RenameTableRequest; +import org.apache.iceberg.rest.requests.UpdateNamespacePropertiesRequest; +import org.apache.iceberg.rest.requests.UpdateTableRequest; +import org.apache.iceberg.rest.responses.ConfigResponse; +import org.apache.iceberg.rest.responses.LoadTableResponse; +import org.apache.iceberg.rest.responses.LoadViewResponse; +import org.apache.iceberg.rest.responses.UpdateNamespacePropertiesResponse; +import org.apache.iceberg.view.ViewMetadata; +import org.apache.polaris.core.admin.model.AddGrantRequest; +import org.apache.polaris.core.admin.model.Catalog; +import org.apache.polaris.core.admin.model.CatalogRole; +import org.apache.polaris.core.admin.model.CreatePrincipalRequest; +import org.apache.polaris.core.admin.model.CreatePrincipalRoleRequest; +import org.apache.polaris.core.admin.model.GrantResource; +import org.apache.polaris.core.admin.model.Principal; +import org.apache.polaris.core.admin.model.PrincipalRole; +import org.apache.polaris.core.admin.model.PrincipalWithCredentials; +import org.apache.polaris.core.admin.model.RevokeGrantRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRequest; +import org.apache.polaris.core.admin.model.UpdateCatalogRoleRequest; +import org.apache.polaris.core.admin.model.UpdatePrincipalRequest; +import org.apache.polaris.core.admin.model.UpdatePrincipalRoleRequest; +import org.apache.polaris.core.entity.PolarisPrivilege; +import org.apache.polaris.service.types.AttachPolicyRequest; +import org.apache.polaris.service.types.CommitViewRequest; +import org.apache.polaris.service.types.CreateGenericTableRequest; +import org.apache.polaris.service.types.CreatePolicyRequest; +import org.apache.polaris.service.types.DetachPolicyRequest; +import org.apache.polaris.service.types.GenericTable; +import org.apache.polaris.service.types.GetApplicablePoliciesResponse; +import org.apache.polaris.service.types.LoadPolicyResponse; +import org.apache.polaris.service.types.NotificationRequest; +import org.apache.polaris.service.types.UpdatePolicyRequest; + +/** + * Standard attribute keys for Polaris events. These keys provide type-safe access to common event + * attributes and enable automatic pruning/filtering logic. + */ +public final class EventAttributes { + private EventAttributes() {} + + // Catalog attributes + public static final AttributeKey<String> CATALOG_NAME = + AttributeKey.of("catalog_name", String.class); + public static final AttributeKey<Catalog> CATALOG = AttributeKey.of("catalog", Catalog.class); + public static final AttributeKey<UpdateCatalogRequest> UPDATE_CATALOG_REQUEST = + AttributeKey.of("update_catalog_request", UpdateCatalogRequest.class); + + // Namespace attributes + public static final AttributeKey<Namespace> NAMESPACE = + AttributeKey.of("namespace", Namespace.class); + public static final AttributeKey<String> NAMESPACE_STRING = + AttributeKey.of("namespace_string", String.class); + public static final AttributeKey<String> PARENT_NAMESPACE = + AttributeKey.of("parent_namespace", String.class); + public static final AttributeKey<CreateNamespaceRequest> CREATE_NAMESPACE_REQUEST = + AttributeKey.of("create_namespace_request", CreateNamespaceRequest.class); + public static final AttributeKey<UpdateNamespacePropertiesRequest> + UPDATE_NAMESPACE_PROPERTIES_REQUEST = + AttributeKey.of( + "update_namespace_properties_request", UpdateNamespacePropertiesRequest.class); + public static final AttributeKey<UpdateNamespacePropertiesResponse> + UPDATE_NAMESPACE_PROPERTIES_RESPONSE = + AttributeKey.of( + "update_namespace_properties_response", UpdateNamespacePropertiesResponse.class); + + @SuppressWarnings("unchecked") + public static final AttributeKey<Map<String, String>> NAMESPACE_PROPERTIES = + (AttributeKey<Map<String, String>>) + (AttributeKey<?>) AttributeKey.of("namespace_properties", Map.class); Review Comment: Shouldn't it be handled during serialization phase? We will have pruning anyway. Also, not sure if it is a desirable scenario, but some non-serializable helper context could be passed with an event. If you strongly prefer to restrict the types, we could whitelist the types during attributes creation, wdyt @adutra? -- 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]
