Skip to content
Closed
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 @@ -304,8 +304,6 @@ class QueryExecution(
}

private def stringWithStats(maxFields: Int, append: String => Unit): Unit = {
val maxFields = SQLConf.get.maxToStringFields

// trigger to compute stats for logical plans
try {
// This will trigger to compute stats for all the nodes in the plan, including subqueries,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,4 +264,22 @@ class QueryExecutionSuite extends SharedSparkSession {
assert(cmdResultExec.commandPhysicalPlan.asInstanceOf[ExecutedCommandExec]
.cmd.isInstanceOf[ShowTablesCommand])
}

test("SPARK-38198: check specify maxFields when call toFile method") {
withTempDir { dir =>
val path = dir.getCanonicalPath + "/plans.txt"
// Define a dataset with 6 columns
val ds = spark.createDataset(Seq((0, 1, 2, 3, 4, 5), (6, 7, 8, 9, 10, 11)))
// `CodegenMode` and `FormattedMode` doesn't use the maxFields, so not tested in this case
Seq(SimpleMode.name, ExtendedMode.name, CostMode.name).foreach { modeName =>
val maxFields = 3
ds.queryExecution.debug.toFile(path, explainMode = Some(modeName), maxFields = maxFields)
Utils.tryWithResource(Source.fromFile(path)) { source =>
val tableScan = source.getLines().filter(_.contains("LocalTableScan"))
assert(tableScan.exists(_.contains("more fields")),
s"Specify maxFields = $maxFields doesn't take effect when explainMode is $modeName")
}
}
}
}
}