7.15.28. time_classify_day
#
7.15.28.1. Summary#
New in version 6.0.3.
time_classify_day
rounds time to a day unit.
This rounded 2020-01-30 11:50:11.000000
and 2020-01-30 22:50:11.000000
to 2020-01-30 00:00:00.000000
.
To enable this function, register functions/time
plugin by the
following command:
plugin_register functions/time
7.15.28.2. Syntax#
This function has only one parameter:
time_classify_day(time)
7.15.28.3. Usage#
Here are a schema definition and sample data to show usage.
You need to register functions/time
plugin at first:
Execution example:
plugin_register functions/time
# [[0,1337566253.89858,0.000355720520019531],true]
Here is a schema definition and sample data.
Sample schema:
Execution example:
table_create Sales TABLE_NO_KEY
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Sales name COLUMN_SCALAR ShortText
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Sales price COLUMN_SCALAR UInt32
# [[0,1337566253.89858,0.000355720520019531],true]
column_create Sales timestamp COLUMN_SCALAR Time
# [[0,1337566253.89858,0.000355720520019531],true]
Sample data:
Execution example:
load --table Sales
[
{"name": "Apple" , "price": "256", "timestamp": "2020-05-01 11:50:11.000000"},
{"name": "Apple" , "price": "256", "timestamp": "2020-05-01 10:20:00.000000"},
{"name": "Orange", "price": "122", "timestamp": "2020-05-01 11:44:12.000001"},
{"name": "Apple" , "price": "256", "timestamp": "2020-05-01 19:50:23.000020"},
{"name": "Banana", "price": "88" , "timestamp": "2020-05-01 11:00:02.000000"},
{"name": "Banana", "price": "88" , "timestamp": "2020-05-01 21:34:12.000001"}
]
# [[0,1337566253.89858,0.000355720520019531],6]
Here is a simple usage of time_classify_day
:
Execution example:
select \
--table Sales \
--output_columns 'name, time_classify_day(timestamp)'
# [
# [
# 0,
# 1337566253.89858,
# 0.000355720520019531
# ],
# [
# [
# [
# 6
# ],
# [
# [
# "name",
# "ShortText"
# ],
# [
# "time_classify_day",
# null
# ]
# ],
# [
# "Apple",
# 1588258800.0
# ],
# [
# "Apple",
# 1588258800.0
# ],
# [
# "Orange",
# 1588258800.0
# ],
# [
# "Apple",
# 1588258800.0
# ],
# [
# "Banana",
# 1588258800.0
# ],
# [
# "Banana",
# 1588258800.0
# ]
# ]
# ]
# ]
7.15.28.4. Parameters#
7.15.28.4.1. Required parameters#
There is only one required parameter.
7.15.28.4.1.1. column
#
Specify a target column.
7.15.28.5. Return value#
It returns a value that rounded time to a day unit.
The return value is UNIX time.