I have a schema in spark as
root
|-- atom: array (nullable = true)
| |-- element: struct (containsNull = true)
| | |-- dailydata: array (nullable = true)
| | | |-- element: struct (containsNull = true)
| | | | |-- datatimezone: string (nullable = true)
| | | | |-- intervaltime: long (nullable = true)
| | | | |-- intervalvalue: long (nullable = true)
| | | | |-- utcacquisitiontime: string (nullable = true)
| | |-- usage: string (nullable = true)
| -- titlename: string (nullable = true)
I have extracted the utcacquisitiontime
and datatimezone
as below from above schema
val result=q.selectExpr("explode(dailydata) as r").select("r.utcacquisitiontime","r.datatimezone")
+--------------------+------------+
| utcacquisitiontime|datatimezone|
+--------------------+------------+
|2017-03-27T22:00:00Z| +02:00|
|2017-03-27T22:15:00Z| +02:00|
|2017-03-27T22:30:00Z| +02:00|
|2017-03-27T22:45:00Z| +02:00|
|2017-03-27T23:00:00Z| +02:00|
|2017-03-27T23:15:00Z| +02:00|
|2017-03-27T23:30:00Z| +02:00|
|2017-03-27T23:45:00Z| +02:00|
|2017-03-28T00:00:00Z| +02:00|
|2017-03-28T00:15:00Z| +02:00|
|2017-03-28T00:30:00Z| +02:00|
|2017-03-28T00:45:00Z| +02:00|
|2017-03-28T01:00:00Z| +02:00|
|2017-03-28T01:15:00Z| +02:00|
|2017-03-28T01:30:00Z| +02:00|
|2017-03-28T01:45:00Z| +02:00|
|2017-03-28T02:00:00Z| +02:00|
|2017-03-28T02:15:00Z| +02:00|
|2017-03-28T02:30:00Z| +02:00|
|2017-03-28T02:45:00Z| +02:00|
+--------------------+------------+
I need to calculate localtime
using these two columns and replace them by the localtime
after calculations. How shall I calculate localtime
and replace the same?