You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Hao Ren <in...@gmail.com> on 2014/12/09 14:30:49 UTC

registerTempTable: Table not found

Hi, 

I am using Spark SQL on 1.2.1-snapshot.

Here is problem I encountered. Bacially, I want to save a schemaRDD to
HiveContext

val scm = StructType(
      Seq(
        StructField("name", StringType, nullable = false),
        StructField("cnt", IntegerType, nullable = false)
      ))

val schRdd = hiveContext.applySchema(ranked, scm)
// ranked above is RDD[Row] whose row contains 2 fields
schRdd.registerTempTable("schRdd")

hiveContext sql "select count(name) from schRdd limit 20" // => ok

hiveContext sql "create table t as select * from schRdd" // => table not
found


A query like "select" works well and gives the correct answer, but when I
try to save the temple table into Hive Context by createTableAsSelect, it
does not work.

*Caused by: org.apache.hadoop.hive.ql.parse.SemanticException: Line 1:32
Table not found 'schRdd'
	at
org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.getMetaData(SemanticAnalyzer.java:1243)*

I thought that was caused by registerTempTable, so I replace it by
saveAsTable. It does not work neither.

*Exception in thread "main" java.lang.AssertionError: assertion failed: No
plan for CreateTableAsSelect Some(sephcn), schRdd, false, None
 LogicalRDD [name#6,cnt#7], MappedRDD[3] at map at Creation.scala:70

	at scala.Predef$.assert(Predef.scala:179)
	at
org.apache.spark.sql.catalyst.planning.QueryPlanner.apply(QueryPlanner.scala:59)*

I also checked source code of QueryPlanner:

 def apply(plan: LogicalPlan): Iterator[PhysicalPlan] = {
    // Obviously a lot to do here still...
    val iter = strategies.view.flatMap(_(plan)).toIterator
    assert(iter.hasNext, s"No plan for $plan")
    iter
  }

The comment shows that there are some works to do with it. 

Any help is appreciated.

Thx.

Hao



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/registerTempTable-Table-not-found-tp20592.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Re: registerTempTable: Table not found

Posted by Hao Ren <in...@gmail.com>.
Thank you.



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/registerTempTable-Table-not-found-tp20592p20594.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org


Re: registerTempTable: Table not found

Posted by nitin <ni...@gmail.com>.
Looks like this issue has been fixed very recently and should be available in
next RC :-

http://apache-spark-developers-list.1001551.n3.nabble.com/CREATE-TABLE-AS-SELECT-does-not-work-with-temp-tables-in-1-2-0-td9662.html



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/registerTempTable-Table-not-found-tp20592p20593.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
For additional commands, e-mail: user-help@spark.apache.org