Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spark sql function #27

Open
liu0013 opened this issue Aug 16, 2018 · 2 comments
Open

Spark sql function #27

liu0013 opened this issue Aug 16, 2018 · 2 comments

Comments

@liu0013
Copy link

liu0013 commented Aug 16, 2018

@liancheng I want to consult a question about spark sql function: from_utc_timestamp(ts: Column, tz: String)
I am using mongo-spark to load "member" collection from mongodb which is included three fields: memberId, date, timezone.
case class Member(memberId: String, date: Timestamp, timezone: String)
val memberDF: Dataframe = load [ Member ] ("member")
I want to invoke from_utc_timestamp to get member's timezone timestamp, memberDF.select(memberId, from_utc_timestamp(date, timezone)), however, tz type is String, it is not a column type. how to implement from_utc_timestamp(ts:Column, tz:Column)?

def from_utc_timestamp(ts: Column, tz: String): Column = withExpr {
FromUTCTimestamp(ts.expr, Literal(tz))
}

withExpr is private method......

Thanks,
Aaron

@Seidzi
Copy link

Seidzi commented Aug 26, 2018

Hello!
The timestamp always has UTC+0, You need the member's location to deduct the time zone

@liu0013
Copy link
Author

liu0013 commented Sep 3, 2018

Thanks @Seidzi ! I want to create daily report by local date, so if from_utc_timestamp(ts:Column, tz:Column) is implemented then I can get the local date by timezone:
to_date(from_utc_timestamp(current_timestamp, timezoneId))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants