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
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
03-15-2018
04:46 PM
1 Kudo
I'll try to explain the problem !
GetHDFS-->ValidateXML--->TransformXMLToJson--->JoltTransformation--->SplitJson--> EvaluteJsonPath---->ReplaceText--->PutHiveQL.
Till the 5 step, it works perfectly for me , but when trying to EvaluteJsonPath , it doesn't work
So how can I evaluate the hol content of the flowfile cos I need to push it completely in the hive , and please how can I use ReplaceText to insert query into hive.
thnks for giving help
... View more
Labels:
- Labels:
-
Apache Hive
-
Apache NiFi
-
HDFS