eric-maynard commented on code in PR #433: URL: https://github.com/apache/polaris/pull/433#discussion_r1833657512
########## polaris-core/src/main/java/org/apache/polaris/core/entity/TableMetadataEntity.java: ########## @@ -0,0 +1,75 @@ +/* + * 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.entity; + +import com.fasterxml.jackson.annotation.JsonIgnore; + +/** + * A {@link PolarisEntity} for storing table metadata. This can contain the raw content of the + * `metadata.json` or more granular information + */ +public class TableMetadataEntity extends PolarisEntity { + private static final String CONTENT_KEY = "content"; + private static final String METADATA_LOCATION_KEY = "metadata_location"; + + public TableMetadataEntity(PolarisBaseEntity sourceEntity) { + super(sourceEntity); + } + + public static TableMetadataEntity of(PolarisBaseEntity sourceEntity) { + if (sourceEntity != null) { + return new TableMetadataEntity(sourceEntity); + } + return null; + } + + @JsonIgnore + public String getContent() { + return getInternalPropertiesAsMap().get(CONTENT_KEY); Review Comment: There are a couple of reasons why I chose not to put this in TableLikeEntity 1. If the metadata is too large to fit in a string (happens on mysql), then it's problematic if the persistence layer rejects writes to TableLikeEntity. On the other hand, it's fairly innocuous if the persistence layer rejects a TableMetadata 2. This properly captures the parent-child / 1:N relationship between tables and their metadata -- in theory, you can have multiple metadata files cached for a given table 3. This better supports future extensions that structure the metadata. It's one thing to stick the JSON in the internalProperties of a TableLikeEntity, but it's another to start adding fields for the partition scheme, the schema, etc. -- 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]
