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
13 changes: 13 additions & 0 deletions cdap-metadata-ext-spanner/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cdap.cdap</groupId>
<artifactId>cdap-metadata-spi</artifactId>
<version>${project.version}</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cdap.cdap</groupId>
<artifactId>cdap-common-unit-test</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

<profiles>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public static FormattedMetadata from(MetadataEntity entity, Metadata metadata) t
}

private FormattedMetadata(MetadataEntity entity, Metadata metadata) throws IOException {
this.namespace = entity.getValue("namespace");
this.namespace = Optional.ofNullable(entity.getValue("namespace"))
.orElse("default");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is namespace is null, is it ok to use default value default or could it be system as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

namespace default value is default.

this.type = entity.getType().toLowerCase();
this.name = Objects.requireNonNull(entity.getValue(entity.getType())).toLowerCase();

Expand Down Expand Up @@ -142,12 +143,6 @@ private Map<String, Set<Property>> reformatProperties(Map<ScopedName, String> pr
String name = key.getName().toLowerCase();
String scope = key.getScope().name();
String value = entry.getValue().toLowerCase();

// If it's a schema key, reformat it.
if (MetadataConstants.SCHEMA_KEY.equals(name)) {
continue;
}

extracted.add(new Property(scope, name, value));
propertyNames.add(name);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,6 @@ private static Set<MetadataScope> determineAffectedScopes(Metadata metadata) {
private static ChangeRequest drop(MetadataEntity entity, VersionedMetadata before) {
List<Mutation> mutations = new ArrayList<>();
String metadataId = toMetadataId(entity);
if (before.getVersion() == null) {
throw new IllegalArgumentException("existingVersion cannot be null when deleting a "
+ "specific version of a metadata entity.");
}
mutations.add(Mutation.delete(METADATA_TABLE, Key.of(metadataId)));
return new ChangeRequest(mutations, new MetadataChange(entity, before.getMetadata(), Metadata.EMPTY));
}
Expand Down Expand Up @@ -288,8 +284,6 @@ private static List<Mutation> createMetadataPropsTableMutations(MetadataEntity e
for (FormattedMetadata.Property prop : formattedMetadata.getMetadataProps()) {
propMutations.add(Mutation.newInsertOrUpdateBuilder(METADATA_PROPS_TABLE)
.set(Tables.MetadataProps.METADATA_ID_FIELD).to(entityId)
.set(Tables.MetadataProps.NAMESPACE_FIELD).to(formattedMetadata.getNamespace())
.set(Tables.MetadataProps.TYPE_FIELD).to(formattedMetadata.getType())
.set(Tables.MetadataProps.NESTED_SCOPE_FIELD).to(prop.getScope())
.set(Tables.MetadataProps.NESTED_NAME_FIELD).to(prop.getName())
.set(Tables.MetadataProps.NESTED_VALUE_FIELD).to(prop.getValue())
Expand Down
Loading
Loading