I'm using CDAP and Cloud Data Fusion 6.6.0 I have a column called ts with a long representing a timestamp in milliseconds. The type is long.
In the next step, I need to group by year and month, so I need to create two new fields year and month or truncate ts to month.
What is the set of Wrangler directives to do it?
The next example is not working because it is a long so I suppose that I need to transform ts to ZoneDateTime, but no idea how to do it:
Tested directives:
parse-as-simple-date:ts
set-column year date:YEAR(ts)
set-column month date:MONTH(ts)
Error
Improper usage of directive 'parse-as-simple-date', usage - 'parse-as-simple-date :column 'format''
These are the wrangler directives to use:
timestamp-to-datetimeparse-timestampThe directive that you are currently using needs to have a date format such as
yyyy.MM.ddit would be something like:parse-as-simple-date :ts yyyy.MM.ddbut this function parse aDATE STRINGto aDATE.The wrangler directive
timestamp-to-datetimeconverts a timestamp to a datetime.Another possible solution is to use
parse-timestampthis directive parses column values representing unix timestamp as date and then you could format the result to aDATEpattern that you like.