Skip to content
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 @@ -157,4 +157,11 @@ enum ColumnarSupportMode {
default ColumnarSupportMode columnarSupportMode() {
return ColumnarSupportMode.PARTITION_DEFINED;
}

/**
* Return the canonicalized scan
*
* @since 4.1.0
*/
default Scan doCanonicalize() {return this;}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package org.apache.spark.sql.execution.datasources.v2
import org.apache.spark.SparkException
import org.apache.spark.sql.catalyst.analysis.{MultiInstanceRelation, NamedRelation}
import org.apache.spark.sql.catalyst.expressions.{Attribute, AttributeMap, AttributeReference, Expression, SortOrder}
import org.apache.spark.sql.catalyst.plans.QueryPlan
import org.apache.spark.sql.catalyst.plans.logical.{ColumnStat, ExposesMetadataColumns, Histogram, HistogramBin, LeafNode, LogicalPlan, Statistics}
import org.apache.spark.sql.catalyst.types.DataTypeUtils.toAttributes
import org.apache.spark.sql.catalyst.util.{quoteIfNeeded, truncatedString, CharVarcharUtils}
Expand Down Expand Up @@ -163,6 +164,17 @@ case class DataSourceV2ScanRelation(
Statistics(sizeInBytes = conf.defaultSizeInBytes)
}
}

override def doCanonicalize(): LogicalPlan = {
val canonicalized = this.copy(
relation = this.relation.copy(
output = this.relation.output.map(QueryPlan.normalizeExpressions(_, this.relation.output))
),
output = this.output.map(QueryPlan.normalizeExpressions(_, this.output)),
scan = this.scan.doCanonicalize()
)
canonicalized
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ case class BatchScanExec(

override def doCanonicalize(): BatchScanExec = {
this.copy(
scan = scan.doCanonicalize(),
output = output.map(QueryPlan.normalizeExpressions(_, output)),
runtimeFilters = QueryPlan.normalizePredicates(
runtimeFilters.filterNot(_ == DynamicPruningExpression(Literal.TrueLiteral)),
Expand Down