Skip to content

Commit

Permalink
Move isDomainMetadataSupported() to TableFeatures.java
Browse files Browse the repository at this point in the history
  • Loading branch information
qiyuandong-db committed Nov 22, 2024
1 parent bf48c01 commit 0fc12a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,21 @@ public static Set<String> extractAutomaticallyEnabledWriterFeatures(
.collect(Collectors.toSet());
}

/**
* Checks if the table protocol supports the "domainMetadata" writer feature.
*
* @param protocol the protocol to check
* @return true if the "domainMetadata" feature is supported, false otherwise
*/
public static boolean isDomainMetadataSupported(Protocol protocol) {
List<String> writerFeatures = protocol.getWriterFeatures();
if (writerFeatures == null) {
return false;
}
return writerFeatures.contains(DOMAIN_METADATA_FEATURE_NAME)
&& protocol.getMinWriterVersion() >= TABLE_FEATURES_MIN_WRITER_VERSION;
}

/**
* Get the minimum reader version required for a feature.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,6 @@ public static void populateDomainMetadataMap(
}
}

/**
* Checks if the table protocol supports the "domainMetadata" writer feature.
*
* @param protocol the protocol to check
* @return true if the "domainMetadata" feature is supported, false otherwise
*/
public static boolean isDomainMetadataSupported(Protocol protocol) {
List<String> writerFeatures = protocol.getWriterFeatures();
if (writerFeatures == null) {
return false;
}
return writerFeatures.contains(TableFeatures.DOMAIN_METADATA_FEATURE_NAME)
&& protocol.getMinWriterVersion() >= TableFeatures.TABLE_FEATURES_MIN_WRITER_VERSION;
}

/**
* Validates the list of domain metadata actions before committing them. It ensures that
*
Expand All @@ -85,7 +70,7 @@ public static void validateDomainMetadatas(
if (domainMetadataActions.isEmpty()) return;

// The list of domain metadata is non-empty, so the protocol must support domain metadata
if (!isDomainMetadataSupported(protocol)) {
if (!TableFeatures.isDomainMetadataSupported(protocol)) {
throw DeltaErrors.domainMetadataUnsupported();
}

Expand Down

0 comments on commit 0fc12a7

Please sign in to comment.