rish0097
rish0097

Reputation: 1094

RexCall cannot be cast to RexInputRef exception in Apache Beam SQL

I'm trying to do a simple join using Beam SQL but I'm getting an exception while compilation:

Exception in thread "main" java.lang.ClassCastException: org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.rex.RexCall cannot be cast to org.apache.beam.repackaged.beam_sdks_java_extensions_sql.org.apache.calcite.rex.RexInputRef

The join is something like:

select T1.x from table1 T1 join table2 T2
on 
(case when T1.a = 'ABC' then 'ABC' else T1.b end = T2.c)

This condition works fine when executed in BigQuery (tried as a sanity check). Not sure why it's breaking in Beam SQL. I even tried using Beam SQL UDF but it did not help either. I assume it's because of Apache Calcite and the format it follows but I do not know how to handle it.

Can someone please help with this.

Upvotes: 0

Views: 270

Answers (1)

saifuddin778
saifuddin778

Reputation: 7277

Interesting. Can you try the IF conditioning? I hope this will work:

select T1.x from table T1 join table T2 on IF(T1.a = 'ABC', 'ABC',T1.b) = T2.c

Upvotes: 0

Related Questions