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

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion server/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ tasks.jacocoTestCoverageVerification {
violationRules {
rule {
limit {
minimum = BigDecimal.valueOf(0.76)
minimum = BigDecimal.valueOf(0.80)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,12 @@ public static TableResponseMetadata toTableResponseMetadata(
.protocol(new ProtocolResponseProtocol().minReaderVersion(new BigDecimal(1))),
new MetadataResponse()
.metadata(new MetadataResponseMetadata()
.id(deltaTableMetadata.getMetadata().getId())
.id(deltaTableMetadata.getMetadata().id())
.format(new MetadataResponseMetadataFormat()
.provider(deltaTableMetadata.getMetadata().getFormat().getProvider()))
.schemaString(deltaTableMetadata.getMetadata().getSchema().toJson())
.partitionColumns(deltaTableMetadata.getMetadata().getPartitionColumns())));
.provider(deltaTableMetadata.getMetadata().format().provider()))
.schemaString(
deltaTableMetadata.getMetadata().tableSchema().structType().toJson())
.partitionColumns(deltaTableMetadata.getMetadata().partitionColumns())));
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package io.whitefox.api.deltasharing.model;

import io.delta.standalone.actions.Metadata;
import io.whitefox.annotations.SkipCoverageGenerated;
import io.whitefox.core.Metadata;
import java.util.Objects;

public class DeltaTableMetadata {
Expand Down
78 changes: 78 additions & 0 deletions server/src/main/java/io/whitefox/core/Metadata.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package io.whitefox.core;

import io.whitefox.annotations.SkipCoverageGenerated;
import java.util.List;
import java.util.Objects;

public class Metadata {
private final String id;
private final Format format;
private final TableSchema tableSchema;
private final List<String> partitionColumns;

public enum Format {
PARQUET("parquet");

private final String provider;

private Format(final String provider) {
this.provider = provider;
}

public String provider() {
return this.provider;
}
}

public Metadata(
String id, Format format, TableSchema tableSchema, List<String> partitionColumns) {
this.id = id;
this.format = format;
this.tableSchema = tableSchema;
this.partitionColumns = partitionColumns;
}

public String id() {
return id;
}

public Format format() {
return format;
}

public TableSchema tableSchema() {
return tableSchema;
}

public List<String> partitionColumns() {
return partitionColumns;
}

@Override
@SkipCoverageGenerated
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Metadata metadata = (Metadata) o;
return Objects.equals(id, metadata.id)
&& format == metadata.format
&& Objects.equals(tableSchema, metadata.tableSchema)
&& Objects.equals(partitionColumns, metadata.partitionColumns);
}

@Override
@SkipCoverageGenerated
public int hashCode() {
return Objects.hash(id, format, tableSchema, partitionColumns);
}

@Override
@SkipCoverageGenerated
public String toString() {
return "Metadata{" + "id='"
+ id + '\'' + ", format="
+ format + ", tableSchema="
+ tableSchema + ", partitionColumns="
+ partitionColumns + '}';
}
}
38 changes: 38 additions & 0 deletions server/src/main/java/io/whitefox/core/TableSchema.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package io.whitefox.core;

import io.delta.standalone.types.StructType;
import io.whitefox.annotations.SkipCoverageGenerated;
import java.util.Objects;

public class TableSchema {
private final StructType structType;

public TableSchema(StructType structType) {
this.structType = structType;
}

public StructType structType() {
return structType;
}

@Override
@SkipCoverageGenerated
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
TableSchema that = (TableSchema) o;
return Objects.equals(structType, that.structType);
}

@Override
@SkipCoverageGenerated
public int hashCode() {
return Objects.hash(structType);
}

@Override
@SkipCoverageGenerated
public String toString() {
return "TableSchema{" + "structType=" + structType + '}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

import io.delta.standalone.DeltaLog;
import io.delta.standalone.Snapshot;
import io.delta.standalone.actions.Metadata;
import io.whitefox.core.Metadata;
import io.whitefox.core.Table;
import io.whitefox.core.TableSchema;
import java.nio.file.Paths;
import java.sql.Timestamp;
import java.time.OffsetDateTime;
Expand Down Expand Up @@ -33,7 +34,12 @@ public static DeltaSharedTable of(Table table) {
}

public Optional<Metadata> getMetadata(Optional<String> startingTimestamp) {
return getSnapshot(startingTimestamp).map(Snapshot::getMetadata);
return getSnapshot(startingTimestamp)
.map(snapshot -> new Metadata(
snapshot.getMetadata().getId(),
Metadata.Format.PARQUET,
new TableSchema(snapshot.getMetadata().getSchema()),
snapshot.getMetadata().getPartitionColumns()));
}

public Optional<Long> getTableVersion(Optional<String> startingTimestamp) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.whitefox.core.services;

import io.delta.standalone.actions.Metadata;
import io.whitefox.core.Metadata;
import io.whitefox.core.Schema;
import io.whitefox.core.Share;
import io.whitefox.core.Table;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package io.whitefox.core.services;

import io.delta.standalone.actions.Metadata;
import io.whitefox.core.Metadata;
import io.whitefox.core.Schema;
import io.whitefox.core.Share;
import io.whitefox.core.Table;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void getTableMetadata() {
var DTable = DeltaSharedTable.of(PTable);
var metadata = DTable.getMetadata(Optional.empty());
assertTrue(metadata.isPresent());
assertEquals("56d48189-cdbc-44f2-9b0e-2bded4c79ed7", metadata.get().getId());
assertEquals("56d48189-cdbc-44f2-9b0e-2bded4c79ed7", metadata.get().id());
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ public void getTableMetadata() {
DeltaSharesService deltaSharesService = new DeltaSharesServiceImpl(storageManager, 100, loader);
var tableMetadata = deltaSharesService.getTableMetadata("name", "default", "table1", null);
assertTrue(tableMetadata.isPresent());
assertEquals("56d48189-cdbc-44f2-9b0e-2bded4c79ed7", tableMetadata.get().getId());
assertEquals("56d48189-cdbc-44f2-9b0e-2bded4c79ed7", tableMetadata.get().id());
}

@Test
Expand Down