Skip to content

Spark sql function  #27

Description

@liu0013

@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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions