Github user gatorsmile commented on a diff in the pull request: https://github.com/apache/spark/pull/17666#discussion_r115318006 --- Diff: sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/analysis/ResolveTableValuedFunctions.scala --- @@ -78,37 +80,52 @@ object ResolveTableValuedFunctions extends Rule[LogicalPlan] { private val builtinFunctions: Map[String, TVF] = Map( "range" -> Map( /* range(end) */ - tvf("end" -> LongType) { case Seq(end: Long) => - Range(0, end, 1, None) + tvf("end" -> LongType) { case (tvf, args @ Seq(end: Long)) => + validateInputDimension(tvf, 1) + Range(0, end, 1, None, tvf.outputNames.headOption) }, /* range(start, end) */ - tvf("start" -> LongType, "end" -> LongType) { case Seq(start: Long, end: Long) => - Range(start, end, 1, None) + tvf("start" -> LongType, "end" -> LongType) { + case (tvf, args @ Seq(start: Long, end: Long)) => + validateInputDimension(tvf, 1) + Range(start, end, 1, None, tvf.outputNames.headOption) }, /* range(start, end, step) */ tvf("start" -> LongType, "end" -> LongType, "step" -> LongType) { - case Seq(start: Long, end: Long, step: Long) => - Range(start, end, step, None) + case (tvf, args @ Seq(start: Long, end: Long, step: Long)) => + validateInputDimension(tvf, 1) + Range(start, end, step, None, tvf.outputNames.headOption) }, /* range(start, end, step, numPartitions) */ tvf("start" -> LongType, "end" -> LongType, "step" -> LongType, "numPartitions" -> IntegerType) { - case Seq(start: Long, end: Long, step: Long, numPartitions: Int) => - Range(start, end, step, Some(numPartitions)) + case (tvf, args @ Seq(start: Long, end: Long, step: Long, numPartitions: Int)) => + validateInputDimension(tvf, 1) + Range(start, end, step, Some(numPartitions), tvf.outputNames.headOption) }) ) + private def validateInputDimension(tvf: UnresolvedTableValuedFunction, expectedNumCols: Int) --- End diff -- BTW, we need to add comments to this function.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org