You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by premdass <pr...@yahoo.co.in> on 2014/07/10 15:15:09 UTC

SparkSQL - Language Integrated query - OR clause and IN clause

Hi,

any suggestions on how to implement OR clause and IN clause in the SparkSQL
language integrated queries.

For example:

 'SELECT name FROM people WHERE age >= 10 AND month = 2' can be written as 
val teenagers = people.where('age >= 10).where('month === 2).select('name)

How do we write  'SELECT name FROM people WHERE age >= 10 OR month = 2' ?

Also how do we write  'SELECT name FROM people WHERE month in ( 2,6)' ??

Any suggestions will be greatly appreciated.

Thanks,
Prem



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/SparkSQL-Language-Integrated-query-OR-clause-and-IN-clause-tp9298.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

Re: SparkSQL - Language Integrated query - OR clause and IN clause

Posted by Michael Armbrust <mi...@databricks.com>.
I'll add that the SQL parser is very limited right now, and that you'll get
much wider coverage using hql inside of HiveContext.  We are working on
bringing sql() much closer to SQL-92 though in the future.


On Thu, Jul 10, 2014 at 7:28 AM, premdass <pr...@yahoo.co.in> wrote:

> Thanks Takuya . works like a Charm
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/SparkSQL-Language-Integrated-query-OR-clause-and-IN-clause-tp9298p9303.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>

Re: SparkSQL - Language Integrated query - OR clause and IN clause

Posted by premdass <pr...@yahoo.co.in>.
Thanks Takuya . works like a Charm



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/SparkSQL-Language-Integrated-query-OR-clause-and-IN-clause-tp9298p9303.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

Re: SparkSQL - Language Integrated query - OR clause and IN clause

Posted by Takuya UESHIN <ue...@happy-camper.st>.
Hi Prem,

You can write like:

  people.where('age >= 10 && 'month === 2).select('name)
  people.where('age >= 10 || 'month === 2).select('name)
  people.where(In('month, Seq(2, 6))).select('name)

The last one needs to import catalyst.expressions package.


Thanks.


2014-07-10 22:15 GMT+09:00 premdass <pr...@yahoo.co.in>:
> Hi,
>
> any suggestions on how to implement OR clause and IN clause in the SparkSQL
> language integrated queries.
>
> For example:
>
>  'SELECT name FROM people WHERE age >= 10 AND month = 2' can be written as
> val teenagers = people.where('age >= 10).where('month === 2).select('name)
>
> How do we write  'SELECT name FROM people WHERE age >= 10 OR month = 2' ?
>
> Also how do we write  'SELECT name FROM people WHERE month in ( 2,6)' ??
>
> Any suggestions will be greatly appreciated.
>
> Thanks,
> Prem
>
>
>
> --
> View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/SparkSQL-Language-Integrated-query-OR-clause-and-IN-clause-tp9298.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.



-- 
Takuya UESHIN
Tokyo, Japan

http://twitter.com/ueshin