-
Notifications
You must be signed in to change notification settings - Fork 28.9k
[SPARK-18284][SQL] Make ExpressionEncoder.serializer.nullable precise #15780
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
43d08c7
0129d2d
05ac1e3
d679b65
f877d8f
f35cef0
7352b3b
bd25130
300647b
d45775e
b3dac38
3a1a8b5
d5f6e6a
725db33
d69a234
214c6bb
2a1287a
3ca7669
b7bf966
d409d46
39e4930
93d4354
737b21f
c925666
296b5af
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 |
|---|---|---|
|
|
@@ -171,15 +171,18 @@ case class StaticInvoke( | |
| * @param arguments An optional list of expressions, whos evaluation will be passed to the function. | ||
| * @param propagateNull When true, and any of the arguments is null, null will be returned instead | ||
| * of calling the function. | ||
| * @param returnNullable When false, indicating the invoked method will always return | ||
| * non-null value. | ||
| */ | ||
| case class Invoke( | ||
| targetObject: Expression, | ||
| functionName: String, | ||
| dataType: DataType, | ||
| arguments: Seq[Expression] = Nil, | ||
| propagateNull: Boolean = true) extends InvokeLike { | ||
| propagateNull: Boolean = true, | ||
| returnNullable : Boolean = true) extends InvokeLike { | ||
|
Member
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. Add a
Member
Author
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. sure, done |
||
|
|
||
| override def nullable: Boolean = true | ||
| override def nullable: Boolean = targetObject.nullable || needNullCheck || returnNullable | ||
| override def children: Seq[Expression] = targetObject +: arguments | ||
|
|
||
| override def eval(input: InternalRow): Any = | ||
|
|
@@ -405,13 +408,15 @@ case class WrapOption(child: Expression, optType: DataType) | |
| * A place holder for the loop variable used in [[MapObjects]]. This should never be constructed | ||
| * manually, but will instead be passed into the provided lambda function. | ||
| */ | ||
| case class LambdaVariable(value: String, isNull: String, dataType: DataType) extends LeafExpression | ||
| case class LambdaVariable( | ||
| value: String, | ||
| isNull: String, | ||
| dataType: DataType, | ||
| nullable: Boolean = true) extends LeafExpression | ||
|
Contributor
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. nit: code style should be
Member
Author
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. done |
||
| with Unevaluable with NonSQLExpression { | ||
|
|
||
| override def nullable: Boolean = true | ||
|
|
||
| override def genCode(ctx: CodegenContext): ExprCode = { | ||
| ExprCode(code = "", value = value, isNull = isNull) | ||
| ExprCode(code = "", value = value, isNull = if (nullable) isNull else "false") | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -592,7 +597,8 @@ object ExternalMapToCatalyst { | |
| keyType: DataType, | ||
| keyConverter: Expression => Expression, | ||
| valueType: DataType, | ||
| valueConverter: Expression => Expression): ExternalMapToCatalyst = { | ||
| valueConverter: Expression => Expression, | ||
| valueNullable: Boolean): ExternalMapToCatalyst = { | ||
| val id = curId.getAndIncrement() | ||
| val keyName = "ExternalMapToCatalyst_key" + id | ||
| val valueName = "ExternalMapToCatalyst_value" + id | ||
|
|
@@ -601,11 +607,11 @@ object ExternalMapToCatalyst { | |
| ExternalMapToCatalyst( | ||
| keyName, | ||
| keyType, | ||
| keyConverter(LambdaVariable(keyName, "false", keyType)), | ||
| keyConverter(LambdaVariable(keyName, "false", keyType, false)), | ||
| valueName, | ||
| valueIsNull, | ||
| valueType, | ||
| valueConverter(LambdaVariable(valueName, valueIsNull, valueType)), | ||
| valueConverter(LambdaVariable(valueName, valueIsNull, valueType, valueNullable)), | ||
|
Contributor
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. shall we update the
Member
Author
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. Yeah, done |
||
| inputMap | ||
| ) | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -86,7 +86,7 @@ class FileStreamSinkSuite extends StreamTest { | |
|
|
||
| val outputDf = spark.read.parquet(outputDir) | ||
| val expectedSchema = new StructType() | ||
| .add(StructField("value", IntegerType)) | ||
| .add(StructField("value", IntegerType, nullable = false)) | ||
| .add(StructField("id", IntegerType)) | ||
|
Member
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. BTW, do you know why
Member
Author
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. Unfortunately, this code makes 'id' nullable. The column specified by
Member
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. I see, thanks. |
||
| assert(outputDf.schema === expectedSchema) | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
does it work for primitive types in complex types? e.g.
Seq(1, 2, 3), should have data typeArrayType(IntegerType, containsNull = false)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.
Yes, it works. I have just added a new test for this.
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.
ping @cloud-fan