gengliangwang commented on code in PR #37430:
URL: https://github.com/apache/spark/pull/37430#discussion_r946014943
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveDefaultColumns.scala:
##########
@@ -265,17 +265,19 @@ case class ResolveDefaultColumns(catalog: SessionCatalog)
extends Rule[LogicalPl
*/
private def addMissingDefaultValuesForInsertFromInlineTable(
node: LogicalPlan,
- insertTableSchemaWithoutPartitionColumns: StructType): LogicalPlan = {
+ insertTableSchemaWithoutPartitionColumns: StructType,
+ numUserSpecifiedFields: Integer): LogicalPlan = {
val numQueryOutputs: Int = node match {
case table: UnresolvedInlineTable => table.rows(0).size
case local: LocalRelation => local.data(0).numFields
}
val schema = insertTableSchemaWithoutPartitionColumns
val newDefaultExpressions: Seq[Expression] =
- getDefaultExpressionsForInsert(numQueryOutputs, schema)
+ getDefaultExpressionsForInsert(numQueryOutputs, schema,
numUserSpecifiedFields, node)
val newNames: Seq[String] = schema.fields.drop(numQueryOutputs).map {
_.name }
node match {
case _ if newDefaultExpressions.isEmpty => node
+ case _ if numUserSpecifiedFields > 0 && numUserSpecifiedFields !=
numQueryOutputs => node
Review Comment:
This line is not reachable. There is such a check in the method
`getDefaultExpressionsForInsert` already
##########
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveDefaultColumns.scala:
##########
@@ -265,17 +265,19 @@ case class ResolveDefaultColumns(catalog: SessionCatalog)
extends Rule[LogicalPl
*/
private def addMissingDefaultValuesForInsertFromInlineTable(
node: LogicalPlan,
- insertTableSchemaWithoutPartitionColumns: StructType): LogicalPlan = {
+ insertTableSchemaWithoutPartitionColumns: StructType,
+ numUserSpecifiedFields: Integer): LogicalPlan = {
val numQueryOutputs: Int = node match {
case table: UnresolvedInlineTable => table.rows(0).size
case local: LocalRelation => local.data(0).numFields
}
val schema = insertTableSchemaWithoutPartitionColumns
val newDefaultExpressions: Seq[Expression] =
- getDefaultExpressionsForInsert(numQueryOutputs, schema)
+ getDefaultExpressionsForInsert(numQueryOutputs, schema,
numUserSpecifiedFields, node)
val newNames: Seq[String] = schema.fields.drop(numQueryOutputs).map {
_.name }
node match {
case _ if newDefaultExpressions.isEmpty => node
+ case _ if numUserSpecifiedFields > 0 && numUserSpecifiedFields !=
numQueryOutputs => node
Review Comment:
```suggestion
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]