Created
November 16, 2019 04:27
-
-
Save nkkarthik/8964f80a944ab7ca5f1c4711cbd432e9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
select ts, | |
seats, | |
sum(seats) over(order by rownum) as usage | |
from ( | |
select | |
row_number() over(order by '1') as rownum, | |
to_timestamp(columns[0], 'yyyy-MM-dd HH:mm:ss Z z') as ts, | |
case | |
when columns[1] = 'out' then cast(columns[3] as int) | |
when columns[1] = 'in' then -1 * cast(columns[3] as int) | |
else 0 | |
end as seats | |
from dfs.tmp.`test1.csv` | |
where columns[1] = 'out' or columns[1] = 'in' | |
) | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment