-
Notifications
You must be signed in to change notification settings - Fork 318
Provide Spark 3.1 - 3.5 support #114
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
Changes from all commits
1798e73
b4bf50b
12acd75
d85867c
9b31f18
c3aa717
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
|
||
set -o xtrace # Write all commands first to stderr | ||
set -o errexit # Exit the script with error if any of the commands fail | ||
|
||
# Supported/used environment variables: | ||
# MONGODB_URI Set the suggested connection MONGODB_URI (including credentials and topology info) | ||
# SCALA_VERSION The Scala version to compile with | ||
# SPARK_VERSION The spark version to test against | ||
MONGODB_URI=${MONGODB_URI:-} | ||
SCALA_VERSION=${SCALA_VERSION:-2.12} | ||
SPARK_VERSION=${SPARK_VERSION:-3.1.2} | ||
stIncMale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
export JAVA_HOME="/opt/java/jdk11" | ||
|
||
############################################ | ||
# Main Program # | ||
############################################ | ||
|
||
|
||
echo "Running tests connecting to $MONGODB_URI on JDK${JAVA_VERSION}" | ||
|
||
./gradlew -version | ||
./gradlew -Dorg.mongodb.test.uri=${MONGODB_URI} --stacktrace --info integrationTest --tests "com.mongodb.spark.sql.connector.read.partitioner.ShardedPartitionerTest" -DscalaVersion=$SCALA_VERSION -DsparkVersion=$SPARK_VERSION |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,7 +50,7 @@ | |
import org.jetbrains.annotations.VisibleForTesting; | ||
|
||
/** Spark Catalog methods for working with namespaces (databases) and tables (collections). */ | ||
public class MongoCatalog implements TableCatalog, SupportsNamespaces { | ||
public class MongoCatalog implements TableCatalog, SupportsNamespaces, SupportsNamespacesAdapter { | ||
private static final Bson NOT_SYSTEM_NAMESPACE = | ||
Filters.not(Filters.regex("name", "^system\\..*")); | ||
private static final Bson IS_COLLECTION = | ||
|
@@ -178,12 +178,11 @@ public void alterNamespace(final String[] namespace, final NamespaceChange... ch | |
throw new UnsupportedOperationException("Altering databases is currently not supported"); | ||
} | ||
|
||
/** | ||
* Drop a database. | ||
* | ||
* @param namespace (database) a multi-part namespace | ||
* @return true if the namespace (database) was dropped | ||
*/ | ||
@Override | ||
public boolean dropNamespace(final String[] namespace, final boolean cascade) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what you mean by a default value for cascade. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scala allows default values for parameters - so they may have just done that. |
||
return dropNamespace(namespace); | ||
} | ||
|
||
@Override | ||
public boolean dropNamespace(final String[] namespace) { | ||
assertInitialized(); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright 2008-present MongoDB, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
package com.mongodb.spark.sql.connector; | ||
|
||
/** | ||
* An adapter for SupportsNamespaces as the API for dropNamespace changed between versions | ||
*/ | ||
interface SupportsNamespacesAdapter { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Declare both There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's crazy that this works! Ingenious. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is clever💡 |
||
|
||
/** | ||
* Drop a database. | ||
* | ||
* @param namespace (database) a multi-part namespace | ||
* @return true if the namespace (database) was dropped | ||
*/ | ||
boolean dropNamespace(String[] namespace); | ||
|
||
/** | ||
* Drop a namespace from the catalog with cascade mode | ||
* | ||
* @param namespace a multi-part namespace | ||
* @param cascade ignored for mongodb | ||
* @return true if the namespace was dropped | ||
*/ | ||
boolean dropNamespace(String[] namespace, boolean cascade); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,8 @@ | |
|
||
/** Shared converter helper methods and statics */ | ||
public final class ConverterHelper { | ||
static final SchemaToExpressionEncoderFunction SCHEMA_TO_EXPRESSION_ENCODER_FUNCTION = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make static the function that is used to convert a schema to an expression encoder. |
||
new SchemaToExpressionEncoderFunction(); | ||
static final Codec<BsonValue> BSON_VALUE_CODEC = new BsonValueCodec(); | ||
|
||
static final JsonWriterSettings RELAXED_JSON_WRITER_SETTINGS = JsonWriterSettings.builder() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
variables ftw