Github user gatorsmile commented on a diff in the pull request:

    https://github.com/apache/spark/pull/18580#discussion_r127625865
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/rules.scala 
---
    @@ -409,6 +409,42 @@ object HiveOnlyCheck extends (LogicalPlan => Unit) {
       }
     }
     
    +
    +/**
    + * A rule to do various checks before reading a table.
    + */
    +object PreReadCheck extends (LogicalPlan => Unit) {
    +  def apply(plan: LogicalPlan): Unit = {
    +    plan.foreach {
    +      case operator: LogicalPlan =>
    +        operator transformExpressionsUp {
    +          case e @ (_: InputFileName | _: InputFileBlockLength | _: 
InputFileBlockStart) =>
    +            checkNumInputFileBlockSources(e, operator)
    +            e
    +        }
    +    }
    +  }
    +
    +  private def checkNumInputFileBlockSources(e: Expression, operator: 
LogicalPlan): Int = {
    +    operator match {
    +      case _: CatalogRelation => 1
    +      case _ @ LogicalRelation(_: HadoopFsRelation, _, _) => 1
    +      case _: LeafNode => 0
    +      // UNION ALL has multiple children, but these children do not 
concurrently use InputFileBlock.
    +      case u: Union =>
    +        if (u.children.map(checkNumInputFileBlockSources(e, _)).sum >= 1) 
1 else 0
    +      case o =>
    +        val numInputFileBlockSources = 
o.children.map(checkNumInputFileBlockSources(e, _)).sum
    +        if (numInputFileBlockSources > 1) {
    +          e.failAnalysis(s"'${e.prettyName}' does not support more than 
one sources")
    --- End diff --
    
    Need to check it as early as possible; otherwise, `Union` might eat it.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to