Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove NessieApiV1 support from spark extensions #9518

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
package org.apache.spark.sql.execution.datasources.v2;

import org.apache.spark.sql.connector.catalog.CatalogPlugin;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.error.NessieReferenceNotFoundException;
import org.projectnessie.model.Reference;

public interface CatalogBridge extends AutoCloseable {
CatalogPlugin currentCatalog();

NessieApiV1 api();
NessieApiV2 api();

void setCurrentRefForSpark(Reference ref, boolean configureRefAtHash);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.client.NessieClientBuilder;
import org.projectnessie.client.NessieConfigConstants;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.client.config.NessieClientConfigSource;

Expand Down Expand Up @@ -76,22 +75,20 @@ public static CatalogBridge buildBridge(CatalogPlugin currentCatalog, String cat
}
}

static NessieApiV1 buildApi(NessieClientConfigSource nessieClientConfigMapper) {
static NessieApiV2 buildApi(NessieClientConfigSource nessieClientConfigMapper) {
NessieClientBuilder nessieClientBuilder =
NessieClientBuilder.createClientBuilderFromSystemSettings(nessieClientConfigMapper);
String clientApiVer = nessieClientConfigMapper.getValue("nessie.client-api-version");
if (clientApiVer == null) {
clientApiVer = "1";
clientApiVer = "2";
}
switch (clientApiVer) {
case "1":
return nessieClientBuilder.build(NessieApiV1.class);
case "2":
return nessieClientBuilder.build(NessieApiV2.class);
default:
throw new IllegalArgumentException(
String.format(
"Unsupported client-api-version value: %s. Can only be 1 or 2", clientApiVer));
"Unsupported client-api-version value: %s. Can only be '2'", clientApiVer));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import org.apache.spark.SparkContext;
import org.apache.spark.sql.connector.catalog.CatalogPlugin;
import org.apache.spark.sql.util.CaseInsensitiveStringMap;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.error.NessieReferenceNotFoundException;
import org.projectnessie.model.Branch;
Expand All @@ -33,7 +33,7 @@

final class NessieCatalogBridge implements CatalogBridge {
private final SparkContext sparkContext;
private final NessieApiV1 api;
private final NessieApiV2 api;
private final CatalogPlugin currentCatalog;
private final String catalogName;
private final String confPrefix;
Expand Down Expand Up @@ -106,7 +106,7 @@ public void setCurrentRefForSpark(Reference ref, boolean configureRefAtHash) {
}

@Override
public NessieApiV1 api() {
public NessieApiV2 api() {
return api;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
import org.apache.spark.sql.util.CaseInsensitiveStringMap;
import org.projectnessie.api.v2.params.ParsedReference;
import org.projectnessie.client.NessieConfigConstants;
import org.projectnessie.client.api.NessieApiV1;
import org.projectnessie.client.api.NessieApiV2;
import org.projectnessie.client.config.NessieClientConfigSource;
import org.projectnessie.error.NessieNotFoundException;
import org.projectnessie.error.NessieReferenceNotFoundException;
Expand All @@ -41,7 +41,7 @@

final class RestCatalogBridge implements CatalogBridge {
private final SparkContext sparkContext;
private final NessieApiV1 api;
private final NessieApiV2 api;
private final CatalogPlugin currentCatalog;
private final String catalogName;
private final String confPrefix;
Expand Down Expand Up @@ -188,7 +188,7 @@ private static String encode(String s) {
}

@Override
public NessieApiV1 api() {
public NessieApiV2 api() {
return api;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package org.apache.spark.sql.execution.datasources.v2

import org.projectnessie.client.api.NessieApiV1
import org.projectnessie.client.api.NessieApiV2
import org.projectnessie.error.NessieReferenceNotFoundException
import org.projectnessie.model._

Expand All @@ -36,7 +36,7 @@ object NessieUtils {
def calculateRef(
branch: String,
tsOrHash: Option[String],
api: NessieApiV1
api: NessieApiV2
): Reference = {
val refName = unquoteRefName(branch)

Expand Down Expand Up @@ -76,7 +76,7 @@ object NessieUtils {
private def findReferenceFromHash(
branch: String,
requestedHash: String,
api: NessieApiV1
api: NessieApiV2
) = {
val commit = Option(
api.getCommitLog
Expand Down Expand Up @@ -105,7 +105,7 @@ object NessieUtils {

private def findReferenceFromTimestamp(
branch: String,
api: NessieApiV1,
api: NessieApiV2,
timestamp: Instant
) = {
val commit = Option(
Expand Down