I am curious to know, how can i implement sql like exists clause in spark Dataframe way.
            Asked
            
        
        
            Active
            
        
            Viewed 6,495 times
        
    2
            
            
        - 
                    Possible duplicate of [Spark replacement for EXISTS and IN](https://stackoverflow.com/questions/34861516/spark-replacement-for-exists-and-in) – pault Jan 08 '20 at 15:35
 
2 Answers
4
            LEFT SEMI JOIN is equivalent to the EXISTS function in Spark.   
val cityDF= Seq(("Delhi","India"),("Kolkata","India"),("Mumbai","India"),("Nairobi","Kenya"),("Colombo","Srilanka")).toDF("City","Country")
val CodeDF= Seq(("011","Delhi"),("022","Mumbai"),("033","Kolkata"),("044","Chennai")).toDF("Code","City")
val finalDF= cityDF.join(CodeDF, cityDF("City") === CodeDF("City"), "left_semi")
        venus
        
- 1,188
 - 9
 - 18
 
- 
                    Any other way instead of join operation? Since I have too many joins in my Sql query and I don't want to make it more complex using this join syntax. Any other way will be appreciated – Sagar patro Jan 07 '20 at 11:27
 - 
                    sorry bro :(.. this is what I know..post another question with good explanation. – venus Jan 07 '20 at 11:36
 


