Spark SQL doesn't allow empty IN in clauses

16 views
Skip to first unread message

Igor Markiewicz

unread,
Nov 6, 2021, 12:35:49 PM11/6/21
to DataStax Spark Connector for Apache Cassandra
If we use an empty IN clause in sparkSession.sql("SELECT ... FROM ... WHERE ... IN ()") we're given org.apache.spark.sql.catalyst.ParseException (despite that the DataStax driver is fine with such query). Is it possible to use empty IN clauses with the spark-cassandra connector while selecting records and at the same time read them as a Dataframe?

Alex Ott

unread,
Nov 6, 2021, 1:44:49 PM11/6/21
to DataStax Spark Connector for Apache Cassandra
from the name of exception I would say that it's the Spark parser error, not related to connector... IIRC, SQL standard doesn't support such queries

On Sat, Nov 6, 2021 at 5:35 PM Igor Markiewicz <igom...@gmail.com> wrote:
If we use an empty IN clause in sparkSession.sql("SELECT ... FROM ... WHERE ... IN ()") we're given org.apache.spark.sql.catalyst.ParseException (despite that the DataStax driver is fine with such query). Is it possible to use empty IN clauses with the spark-cassandra connector while selecting records and at the same time read them as a Dataframe?

--
To unsubscribe from this group and stop receiving emails from it, send an email to spark-connector-...@lists.datastax.com.


--
With best wishes,                    Alex Ott
http://alexott.net/
Twitter: alexott_en (English), alexott (Russian)

Igor Markiewicz

unread,
Nov 6, 2021, 2:24:48 PM11/6/21
to DataStax Spark Connector for Apache Cassandra, ale...@gmail.com
I have the same impression, but
  1. Isn't the spark-cassandra connector rewriting those Spark SQL rules?
  2. Maybe there is another way to achive that, using the connector?

Alex Ott

unread,
Nov 6, 2021, 2:43:55 PM11/6/21
to Igor Markiewicz, DataStax Spark Connector for Apache Cassandra
Cassandra connector works on already parsed expression...

Create query programmatically, using Spark API

df = df.select(....)
if len(lst) > 0:
  df = df.filter(col("col1").isin(lst)

...

Reply all
Reply to author
Forward
0 new messages