org.apache.spark.sql.AnalysisException: Reference 'dattim' is ambiguous, could be: dattim#6, event_dattim#55.;

Viewed 4423

I have a joined dataframes with a where clause that the dataStampe is within a range:

val startTime = new 
Timestamp(NewDate.atStartOfDay.toEpochSecond(ZoneOffset.UTC) * 1000)
val endTime = new 
Timestamp(NewDate.plusDays(1).atStartOfDay.toEpochSecond(ZoneOffset.UTC) * 
1000)

val joinedTable = table1.join(table2,
table1("date") === table1("key")
&& ....).where(table1("dattim") >= startTimestamp && table1("dattim") < endTimestamp)

it complains that Reference 'dattim' is ambiguous, I tried to use range:

table1("tattim") === (startTime to endTime) 

it still not taking it. any suggestions?

1 Answers

Seems like you have the same column name in both datframes. Just use alias for one of the column.

Related