Reputation: 177
I have a column in my database/dataframe which is a key value pair. I want to filter data based on certain value. Say only those rows with value 'DDD' for the key 'ddd'. How can this be achived in spark/spark sql?
"{'aaa': 'AAA', 'bbb': 'BBB', 'ccc': 'CCC', 'ddd': 'DDD', 'eee': 'EEE', 'fff': 'FFF', 'ggg': 'GGG'}"
"{'aaa': 'AAA1', 'bbb': 'BBB1', 'ccc': 'CCC1', 'ddd': 'DDD1', 'eee': 'EEE1', 'fff': 'FFF1', 'ggg': 'GGG1'}"
Upvotes: 0
Views: 1476
Reputation: 1175
We can do it like below using filter function
DataFrame inputDf= //read from database
DataFrame filteredDf=inputDf.filter("ddd='DDD'");
Upvotes: 2