-
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
Conversation
Apologies - seems to compile fine but there is some more work to do with integration tests. |
- func: "upload test results" | ||
- func: "cleanup" | ||
|
||
variables: |
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
* @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 comment
The reason will be displayed to describe this comment to others. Learn more.
dropNamespace(namespace)
was removed in 3.4
dropNamespace(namespace, cascade)
was added in 3.4 - probably with a default value for cascade.
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.
Not sure what you mean by a default value for cascade.
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.
Scala allows default values for parameters - so they may have just done that.
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
Declare both dropNamespace
methods then both can be overridden
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.
It's crazy that this works! Ingenious.
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.
This is clever💡
throw new ExceptionInInitializerError("Unsupported version of Spark: " + sparkVersion); | ||
} | ||
|
||
MODULE_STATIC = moduleStatic; |
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.
Cache the methods that we looked up.
@Override | ||
public ExpressionEncoder<Row> apply(final StructType schema) { | ||
ExpressionEncoder<Row> rowEncoder = MethodInvoker.invoke(APPLY_METHOD, MODULE_STATIC, schema); | ||
return rowEncoder.resolveAndBind(ATTRIBUTE_FUNCTION.apply(schema), SimpleAnalyzer$.MODULE$); |
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.
Get the resolved ExpressionEncoder which can create valid serializers and deserializers
|
||
/** 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 comment
The 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.
SPARK-413
@jyemin & @stIncMale this is now ready for review :) |
* @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 comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean by a default value for cascade.
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
It's crazy that this works! Ingenious.
src/main/java/com/mongodb/spark/sql/connector/schema/SchemaToExpressionEncoderFunction.java
Outdated
Show resolved
Hide resolved
src/main/java/com/mongodb/spark/sql/connector/schema/SchemaToExpressionEncoderFunction.java
Outdated
Show resolved
Hide resolved
/** | ||
* 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 comment
The reason will be displayed to describe this comment to others. Learn more.
This is clever💡
src/main/java/com/mongodb/spark/sql/connector/schema/SchemaToExpressionEncoderFunction.java
Outdated
Show resolved
Hide resolved
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.
LGTM
Two core fixes:
SupportsNamespaces
which addedcascade
todropNamespace
.InternalRow
toRow
SPARK-413