Skip to content

Instantly share code, notes, and snippets.

@1ambda
Created December 20, 2021 11:35
Embed
What would you like to do?
case class DeviceIoTData (
battery_level: Long,
c02_level: Long,
cca2: String,
cca3: String,
cn: String,
device_id: Long,
device_name: String,
humidity: Long,
ip: String,
latitude: Double,
lcd: String,
longitude: Double,
scale:String,
temp: Long,
timestamp: Long)
val ds = spark.read(...).as[DeviceIoTData]
val dsAvgTmp = ds
.filter(d => {d.temp > 25})
.map(d => (d.temp, d.humidity, d.cca3))
.groupBy($"_3").avg()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment