Spark SQL like returns no results spark version 1.5.1/1.5.2 using sqlContext select

48 Views Asked by At

It doesn't seem spark sql with hive supports "sql like". Here is the example code that I use for testing in spark-shell

case class Department(id: String, name: String)
val department1 = new Department("123456", "Computer Science")
val department2 = new Department("789012", "Mechanical Engineering")
val department3 = new Department("345678", "Theater and Drama")
val department4 = new Department("901234", "Indoor Recreation")
val dSeq = Seq(department1, department2, department3, department4)
val dfd = dSeq.toDF()
dfd.registerTempTable("departments")
val re=sqlContext.sql("select * from departments where name like '*Rec*'")
re.show()

It will show no result. and I check the sqlContext and it is hiveContext

scala> sqlContext
res15: org.apache.spark.sql.SQLContext =org.apache.spark.sql.hive.HiveContext@4f03729f

Does any one know why?

0

There are 0 best solutions below