I loaded csv file in sql table databricks, which is using apache spark. I need to extract sql table column which has content:
01.01.2018,15:25
01.01.2018,00:10
01.01.2018,13:20
...
...
on data which represent only working days and time between 8.30 and 9.30 a.m. How should I do that? Should I first extract column on two columns? I found how I can do some parts with data which I enter into databricks, but this data are part of sql table.
Also some commands from classical sql does not work on apache spark, it means databricks.
This is query for reading data:
# File location and type
file_location = "/FileStore/tables/NEZ_OPENDATA_2018_20190125-1.csv"
file_type = "csv"
# CSV options
infer_schema = "false"
first_row_is_header = "false"
delimiter = ","
# The applied options are for CSV files. For other file types, these will be ignored.
df = spark.read.format(file_type) \
.option("inferSchema", infer_schema) \
.option("header", first_row_is_header) \
.option("sep", delimiter) \
.load(file_location)
display(df)
# Create a view or table
temp_table_name = "NEZ_OPENDATA_2018_20190125"
df.createOrReplaceTempView(temp_table_name)
%sql
/* Query the created temp table in a SQL cell */
select * from `NEZ_OPENDATA_2018_20190125`
permanent_table_name = "NEZ_OPENDATA_2018_20190125"
df.write.format("parquet").saveAsTable(permanent_table_name)