Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions runtime/defaults/src/main/resources/application.properties
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ polaris.event-listener.type=no-op
# polaris.event-listener.aws-cloudwatch.log-stream=polaris-cloudwatch-default-stream
# polaris.event-listener.aws-cloudwatch.region=us-east-1
# polaris.event-listener.aws-cloudwatch.synchronous-mode=false
# polaris.event-listener.aws-cloudwatch.event-types= // the absence of this property would result in processing all Polaris event types.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You may want to add an example of how to actually specify events here:

Suggested change
# polaris.event-listener.aws-cloudwatch.event-types= // the absence of this property would result in processing all Polaris event types.
# The absence of the property below would result in processing all Polaris event types (default).
# polaris.event-listener.aws-cloudwatch.event-types=\
# org.apache.polaris.service.events.IcebergRestCatalogEvents$BeforeCreateNamespaceEvent,\
# org.apache.polaris.service.events.IcebergRestCatalogEvents$AfterCreateNamespaceEvent


polaris.log.request-id-header-name=Polaris-Request-Id
# polaris.log.mdc.aid=polaris
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@
import io.smallrye.config.WithConverter;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import org.apache.iceberg.catalog.Namespace;
import org.apache.iceberg.catalog.TableIdentifier;
import org.apache.iceberg.rest.RESTSerializers;
import org.apache.polaris.service.events.PolarisEvent;
import org.apache.polaris.service.events.json.mixins.IcebergMixins;
import org.apache.polaris.service.events.json.mixins.PolarisEventBaseMixin;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -56,6 +61,10 @@ public void customize(ObjectMapper objectMapper) {
objectMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.setPropertyNamingStrategy(new PropertyNamingStrategies.KebabCaseStrategy());
objectMapper.addMixIn(PolarisEvent.class, PolarisEventBaseMixin.class);
objectMapper.addMixIn(TableIdentifier.class, IcebergMixins.TableIdentifierMixin.class);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought these are taken care of by the RESTSerializers below?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, RESTSerializers have serializers for TableIdentifier and Namespace already.

objectMapper.addMixIn(Namespace.class, IcebergMixins.NamespaceMixin.class);

RESTSerializers.registerAll(objectMapper);
Serializers.registerSerializers(objectMapper);
objectMapper
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
* 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.json.mixins;

import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.iceberg.catalog.Namespace;

/** Mixins for Iceberg classes we don't control, to keep JSON concise. */
public final class IcebergMixins {

// Private constructor to prevent instantiation
private IcebergMixins() {}

/** Serializes Namespace as an object like: "namespace": ["sales", "north.america"] */
public abstract static class NamespaceMixin {
@JsonProperty("namespace")
public abstract String[] levels();
}

/**
* Serializes TableIdentifier as a scalar string like: {"namespace": ["sales", "north.america"],
* "name": "transactions"}
*/
public abstract static class TableIdentifierMixin {
@JsonProperty("namespace")
public abstract Namespace namespace();

@JsonProperty("name")
public abstract String name();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.json.mixins;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.PropertyNamingStrategies;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonNaming(PropertyNamingStrategies.SnakeCaseStrategy.class)
public abstract class PolarisEventBaseMixin {}

This file was deleted.

Loading