Skip to content

Commit

Permalink
Merge branch 'main' into feature/94-comply-with-latest-delta-sharing-…
Browse files Browse the repository at this point in the history
…protocol
  • Loading branch information
agilelab-tmnd1991 authored Jan 10, 2024
2 parents db96c66 + 37edf36 commit 318a98f
Show file tree
Hide file tree
Showing 19 changed files with 340 additions and 612 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/build_doc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
cache: 'gradle'
distribution: temurin
Expand All @@ -18,13 +18,13 @@ jobs:
- name: Execute npm run build
run: |
cp -r protocol docsite/static/protocol
./gradlew docsite:npm_run_build --no-daemon
./gradlew docsite:npm_install docsite:npm_run_build --no-daemon
chmod -c -R +rX "docsite/build" | while read line; do
echo "::warning title=Invalid file permissions automatically fixed::$line"
done
shell: bash
- name: Upload gh-pages artifact
uses: actions/upload-pages-artifact@v2
uses: actions/upload-pages-artifact@v3
with:
path: docsite/build
deploy:
Expand All @@ -43,5 +43,5 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v4

2 changes: 1 addition & 1 deletion .github/workflows/compile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}
- uses: actions/setup-java@v3
- uses: actions/setup-java@v4
with:
cache: 'gradle'
distribution: temurin
Expand Down
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ build/
.gradle
.env
client/bin
server/bin
server/bin
.terraform
.terraform.*
*.tfstate
*.tfstate.backup
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
group = "io.whitefox"
plugins {
id("co.uzzu.dotenv.gradle").version("3.0.0")
id("co.uzzu.dotenv.gradle").version("4.0.0")
}
2 changes: 1 addition & 1 deletion buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ repositories {

dependencies {
implementation("org.openapi.generator:org.openapi.generator.gradle.plugin:6.6.0")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.23.1")
implementation("com.diffplug.spotless:spotless-plugin-gradle:6.23.3")
implementation("com.palantir.gradle.gitversion:gradle-git-version:3.0.0")
}
9 changes: 4 additions & 5 deletions client-spark/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,14 @@ dependencies {

// DELTA
testImplementation("org.apache.hadoop:hadoop-common:3.3.6")
testImplementation("io.delta:delta-sharing-spark_2.12:1.0.2")
testImplementation("io.delta:delta-sharing-spark_2.13:1.0.3")

//SPARK
testImplementation("org.apache.spark:spark-core_2.12:3.3.2")
testImplementation("org.apache.spark:spark-sql_2.12:3.3.2")
testImplementation("com.github.mrpowers:spark-fast-tests_2.12:1.3.0")
testImplementation("org.apache.spark:spark-sql_2.13:3.5.0")
testImplementation("com.github.mrpowers:spark-fast-tests_2.13:1.3.0")

//JUNIT
testImplementation("org.junit.jupiter:junit-jupiter:5.8.1")
testImplementation("org.junit.jupiter:junit-jupiter:5.10.1")
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,34 +4,31 @@

import com.github.mrpowers.spark.fast.tests.DatasetComparer;
import io.whitefox.api.client.model.CreateMetastore;
import io.whitefox.api.client.model.Metastore;
import io.whitefox.api.client.model.Provider;
import io.whitefox.api.models.MrFoxDeltaTableSchema;
import io.whitefox.api.utils.SparkUtil;
import io.whitefox.api.utils.ScalaUtils;
import io.whitefox.api.utils.StorageManagerInitializer;
import io.whitefox.api.utils.TablePath;
import io.whitefox.api.utils.TestSparkSession;
import java.util.List;
import org.apache.spark.sql.SparkSession;
import org.apache.spark.sql.types.DataType;
import org.apache.spark.sql.types.Metadata;
import org.apache.spark.sql.types.StructField;
import org.apache.spark.sql.types.StructType;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Tag;
import org.junit.jupiter.api.Test;
import scala.collection.GenMap;

@Tag("clientSparkTest")
public class ITDeltaSharingClient implements DatasetComparer, SparkUtil {
public class ITDeltaSharingClient implements DatasetComparer, ScalaUtils {

private final StorageManagerInitializer storageManagerInitializer;
private final String deltaTablePath;
private final SparkSession spark;

public ITDeltaSharingClient() {
this.storageManagerInitializer = new StorageManagerInitializer();
this.deltaTablePath =
TablePath.getDeltaTablePath(getClass().getClassLoader().getResource("MrFoxProfile.json"));
this.spark = newSparkSession();
}

@BeforeAll
Expand All @@ -41,10 +38,11 @@ static void initStorageManager() {

@Test
void showS3Table1withQueryTableApi() {
var spark = TestSparkSession.newSparkSession();
storageManagerInitializer.createS3DeltaTable();
var ds = spark.read().format("deltaSharing").load(deltaTablePath);
var expectedSchema = new StructType(new StructField[] {
new StructField("id", DataType.fromDDL("long"), true, new Metadata(GenMap.empty()))
new StructField("id", DataType.fromDDL("long"), true, new Metadata(emptyScalaMap()))
});
var expectedData = spark
.createDataFrame(
Expand All @@ -57,15 +55,16 @@ void showS3Table1withQueryTableApi() {
MrFoxDeltaTableSchema.class)
.toDF();

assertEquals(expectedSchema.json(), ds.schema().json());
assertEquals(expectedSchema, ds.schema());
assertEquals(5, ds.count());
assertSmallDatasetEquality(ds, expectedData, true, false, false, 500);
}

@Test
void createGlueMetastore() {
Metastore metastore = storageManagerInitializer.createGlueMetastore();
assertEquals(metastore.getName(), "MrFoxMetastore");
assertEquals(metastore.getType(), CreateMetastore.TypeEnum.GLUE.getValue());
void createProviderWithGlueMetastore() {
Provider provider = storageManagerInitializer.createProviderWithGlueMetastore();
assertEquals(provider.getStorage().getName(), "MrFoxStorage");
assertEquals(provider.getMetastore().getName(), "MrFoxMetastore");
assertEquals(provider.getMetastore().getType(), CreateMetastore.TypeEnum.GLUE.getValue());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.whitefox.api.utils;

public interface ScalaUtils {
default <K, V> scala.collection.immutable.Map<K, V> emptyScalaMap() {
return scala.collection.immutable.Map$.MODULE$.empty();
}
}
14 changes: 0 additions & 14 deletions client-spark/src/test/java/io/whitefox/api/utils/SparkUtil.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,15 @@ public void createS3DeltaTable() {
addTableToSchemaRequest(providerRequest.getName(), createTableRequest.getName())));
}

public Metastore createGlueMetastore() {
public Provider createProviderWithGlueMetastore() {
var metastoreRequest = createMetastoreRequest(s3TestConfig, CreateMetastore.TypeEnum.GLUE);
return ApiUtils.recoverConflictLazy(
var metastore = ApiUtils.recoverConflictLazy(
() -> metastoreV1Api.createMetastore(metastoreRequest),
() -> metastoreV1Api.describeMetastore(metastoreRequest.getName()));
var providerRequest = addProviderRequest(Optional.of(metastore.getName()), TableFormat.iceberg);
return ApiUtils.recoverConflictLazy(
() -> providerV1Api.addProvider(providerRequest),
() -> providerV1Api.getProvider(providerRequest.getName()));
}

private String createSchemaRequest(TableFormat tableFormat) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.whitefox.api.utils;

import org.apache.spark.sql.SparkSession;

public class TestSparkSession {

private static final class SparkHolder {
private static final SparkSession spark = SparkSession.builder()
.appName("delta sharing client test")
.config("spark.driver.host", "localhost")
.master("local[1, 4]")
.getOrCreate();
}

public static SparkSession newSparkSession() {
return SparkHolder.spark.newSession();
}
}
4 changes: 2 additions & 2 deletions docsite/docs/development_guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ not run properly on newer versions of the JVM.

As soon as you clone the project you should verify that you are able to build and test locally, to do so you need to
run the `check` command of Gradle, you can achieve that using either `gradlew` script in the project root (`.
/gradlew check`) or run the same [gradle task from intellij](https://www.jetbrains.com/help/idea/work-with-gradle-tasks.
html). If you're default jvm is not version 11, you can run `gradlew` passing another java home as follows:
/gradlew check`) or run the same [gradle task from intellij](https://www.jetbrains.com/help/idea/work-with-gradle-tasks.html).
If you're default jvm is not version 11, you can run `gradlew` passing another java home as follows:
`./gradlew -Dorg.gradle.java.home=<PATH_TO_JAVA_HOME> build`.

Sometimes IntelliJ will tell you have build errors, especially when moving from one branch to the other. The problem
Expand Down
Loading

0 comments on commit 318a98f

Please sign in to comment.