Last active
September 17, 2016 08:38
-
-
Save pavlov99/6ccd8f806f072d2faf221b8d609b3483 to your computer and use it in GitHub Desktop.
Medium blog: lookup-table-maintenance-in-hive snippets
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
val schedule = sqlContext.read | |
.format("com.databricks.spark.csv") | |
.option("header", "true") | |
.option("inferSchema", "true") | |
.load("lookup-example/san-jose-schedule-2016-2017.csv") | |
.select( | |
to_date( | |
unix_timestamp($"START_DATE", "MM/dd/yyyy").cast("timestamp") | |
) as "date", | |
when( | |
locate("San Jose", $"SUBJECT") === 1, | |
regexp_extract($"SUBJECT", "^San Jose at (.*)$", 1) | |
).otherwise( | |
regexp_extract($"SUBJECT", "^(.*) at San Jose$", 1) | |
) as "competitor" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment