代码之家  ›  专栏  ›  技术社区  ›  ChiMo

“spark.sql.execution.id已设置”使用sparksql和futures的异常

  •  0
  • ChiMo  · 技术社区  · 6 年前

    使用火花 2.0.2.6条 还有斯卡拉 2.11.8条 :我遇到了一个例外 java.lang.IllegalArgumentException: spark.sql.execution.id is already set 当试图通过 Future 是的。

    import scala.concurrent.duration._
    import scala.concurrent.ExecutionContext.Implicits.global
    import scala.concurrent.{Await, Future}
    
    def printTable(query: String): Unit = {
      try { 
        spark.sql(query).show 
      }
      catch { case e: Exception => println(e) }
    }
    
    Future {
      printTable("SELECT key1, key2 FROM schema.table1 LIMIT 1")
    }
    
    Future {
      printTable("SELECT key1, key2 FROM schema.table2 LIMIT 1")
    }
    
    Future {
      printTable("SELECT key1, key2 FROM schema.table3 LIMIT 1")
    }
    

    另外:这个错误完全不一致,代码有时会打印出正确的答案。

    这是怎么回事,我该怎么办?

    0 回复  |  直到 6 年前