Member since
03-15-2018
16
Posts
2
Kudos Received
0
Solutions
05-28-2018
08:58 AM
Hello people ! Could anyone help me out! my datset contains a timestamp field and I need to extract the year, the month, the day and the hour from it. I taped these lines ! training.createOrReplaceTempView("df")
spark.udf.register("getCurrentHour", getCurrentHour _)
val hour = spark.sql("select getCurrentHour(payload_MeterReading_IntervalBlock_IReading_endTime) as hour from df")
spark.udf.register("assignTod", assignTod _)
timestamps_df.createOrReplaceTempView("timestamps")
val tod = spark.sql("select assignTod(hour) as tod from timestamps")
the problem is am not good in scala so I couldn't figure out the best solution ! the two fonctions i used to extract hour and assign it as day part def assignToDay(hr : Integer) : String = {
if(hr >= 7 && hr < 12){
return "morning"
}else if ( hr >= 12 && hr < 14) {
return "lunch"
} else if ( hr >= 14 && hr < 18) {
return "afternoon"
} else if ( hr >= 18 && hr.<(23)) {
return "evening"
} else if ( hr >= 23 && hr <= 24) {
return "night"
} else if ( hr < 7) {
return "night"
} else {
return "error"
}
}
def getCurrentHour(dateStr: String) : Integer = {
var currentHour = 0
try {
val date = new Date(dateStr.toLong)
return int2Integer(date.getHours)
} catch {
case _ => return currentHour
}
return 1
}
... View more
05-23-2018
12:25 PM
hello sir How can I handle the TimeStamps fields using spark. please I need help !
... View more
04-03-2018
02:05 PM
Hello Sir ! here they are !
... View more
04-03-2018
11:10 AM
No Sir they are empties !
... View more
04-03-2018
11:10 AM
No Sir they are empties !
... View more
04-03-2018
10:30 AM
@Geoffrey Shelton Okot Hello Sir here it is !
... View more
04-03-2018
09:22 AM
@Ted Yu
hello Sir ! Can you help me out please , am trying to install the Cassandra for my HDP cluster ! The link below didn't help me https://hadoopbuzz.wordpress.com/2017/08/22/configuring-cassandra-service-in-hdp-2-6/
... View more
03-27-2018
08:39 AM
@Shu Hello 😄 from the other side XD Am so grateful sir , you helped me out !!
Thanks a lot :D
I highly recommend you
... View more
03-19-2018
10:39 AM
Good morning sir @Rahul Soni ^^ thanks for replying me , Mr @Shu gave me the solution I was looking for !
... View more
03-19-2018
10:36 AM
1 Kudo
hello @Shu it works perfectly 😄 big thanks for you ^^
... View more