Skip to content

Commit

Permalink
docs: DOCSUP-83022: Fixes in function ref texts (part 5) (#632)
Browse files Browse the repository at this point in the history
example updates
  • Loading branch information
shamshinds authored Oct 4, 2024
1 parent d90c569 commit 8c6aa95
Show file tree
Hide file tree
Showing 8 changed files with 120 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"ch_toStartOfInterval": AliasedLinkResource(
url=_("https://clickhouse.com/docs/en/sql-reference/functions/date-time-functions#tostartofinterval")
),
"geopolygon_link": AliasedLinkResource(url=_("../concepts/data-types.md#geopolygon")),
"geopolygon_link": AliasedLinkResource(url=_("../dataset/data-types.md#geopolygon")),
"timezone_link": AliasedLinkResource(
url=_("https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List")
),
"tree_link": AliasedLinkResource(url=_("../concepts/data-types.md#tree-hierarchy")),
"tree_link": AliasedLinkResource(url=_("../dataset/data-types.md#tree-hierarchy")),
"unix_ts": AliasedLinkResource(url=_("https://en.wikipedia.org/wiki/Unix_time")),
}
),
Expand Down
81 changes: 70 additions & 11 deletions lib/dl_formula_ref/dl_formula_ref/example_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@
{
"columns": [
{
"name": "Warmest Month",
"type": "STRING"
"name": "Warmest Day",
"type": "DATE"
}
],
"rows": [
[
"July"
{
"__type__": "date",
"__value__": "2019-03-01"
}
]
]
}
Expand All @@ -114,13 +117,16 @@
{
"columns": [
{
"name": "Coldest Month",
"type": "STRING"
"name": "Coldest Day",
"type": "DATE"
}
],
"rows": [
[
"January"
{
"__type__": "date",
"__value__": "2019-03-08"
}
]
]
}
Expand Down Expand Up @@ -3568,6 +3574,59 @@
]
}
],
[
"MONTH.Example with custom first day of the week",
{
"columns": [
{
"name": "Date",
"type": "DATE"
},
{
"name": "Month",
"type": "INTEGER"
},
{
"name": "Month name",
"type": "STRING"
}
],
"rows": [
[
{
"__type__": "date",
"__value__": "2014-10-06"
},
10,
"October"
],
[
{
"__type__": "date",
"__value__": "2014-10-07"
},
10,
"October"
],
[
{
"__type__": "date",
"__value__": "2017-03-08"
},
3,
"March"
],
[
{
"__type__": "date",
"__value__": "2024-02-12"
},
2,
"February"
]
]
}
],
[
"MSUM.Example with ORDER BY",
{
Expand Down Expand Up @@ -3790,9 +3849,9 @@
],
"rows": [
[
-1.0,
7.0,
18.0
-3.0,
0.0,
4.0
]
]
}
Expand Down Expand Up @@ -5441,7 +5500,7 @@
],
"rows": [
[
10.205464964983964
3.8954129979043843
]
]
}
Expand All @@ -5457,7 +5516,7 @@
],
"rows": [
[
9.770988804733236
3.7295740001000413
]
]
}
Expand Down
34 changes: 19 additions & 15 deletions lib/dl_formula_ref/dl_formula_ref/functions/aggregation.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import datetime

from dl_formula.core.datatype import DataType
from dl_formula_ref.categories.aggregation import CATEGORY_AGGREGATION
from dl_formula_ref.examples.config import (
Expand All @@ -14,6 +16,8 @@

_ = get_gettext()

_d = datetime.date

_SOURCE_INT_FLOAT_1 = ExampleSource(
columns=[
("City", DataType.STRING),
Expand All @@ -35,22 +39,22 @@

_SOURCE_TEMP = ExampleSource(
columns=[
("Month", DataType.STRING),
("Date", DataType.DATE),
("Temperature", DataType.FLOAT),
],
data=[
["January", -8.0],
["February", -4.0],
["March", -1.0],
["April", 7.0],
["May", 14.0],
["June", 18.0],
["July", 22.0],
["August", 19.0],
["September", 13.0],
["October", 5.0],
["November", 1.0],
["December", -4.0],
[_d(2019, 3, 1), 5.0],
[_d(2019, 3, 2), 0.0],
[_d(2019, 3, 3), -3.0],
[_d(2019, 3, 4), 1.0],
[_d(2019, 3, 5), 4.0],
[_d(2019, 3, 6), 5.0],
[_d(2019, 3, 7), 1.0],
[_d(2019, 3, 8), -6.0],
[_d(2019, 3, 9), -6.0],
[_d(2019, 3, 10), -4.0],
[_d(2019, 3, 11), -2.0],
[_d(2019, 3, 12), 0.0],
],
)

Expand Down Expand Up @@ -372,7 +376,7 @@
show_source_table=True,
formulas_as_names=False,
formula_fields=[
("Coldest Month", "ARG_MIN([Month],[Temperature])"),
("Coldest Day", "ARG_MIN([Date],[Temperature])"),
],
),
),
Expand All @@ -394,7 +398,7 @@
show_source_table=True,
formulas_as_names=False,
formula_fields=[
("Warmest Month", "ARG_MAX([Month],[Temperature])"),
("Warmest Day", "ARG_MAX([Date],[Temperature])"),
],
),
),
Expand Down
20 changes: 19 additions & 1 deletion lib/dl_formula_ref/dl_formula_ref/functions/date.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,25 @@
category=CATEGORY_DATE,
description=_("Returns the number of the month in the year of the specified date {arg:0}."),
examples=[
SimpleExample("MONTH(#2019-01-23#) = 1"),
DataExample(
example_config=ExampleConfig(
name=_("Example with custom first day of the week"),
source=_SOURCE_DATE_1,
formula_fields=[
("Date", "[Date]"),
("Month", "MONTH([Date])"),
(
"Month name",
(
"CASE(MONTH([Date]), "
'1, "January", 2, "February", 3, "March", 4, "April", 5, "May", 6, "June", '
'7, "July", 8, "August", 9, "September", 10, "October", 11, "November", 12, "December", "Undefined")'
),
),
],
formulas_as_names=False,
)
),
],
)

Expand Down
1 change: 1 addition & 0 deletions lib/dl_formula_ref/dl_formula_ref/functions/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
description=_("Returns `TRUE` if {arg:0} contains {arg:1}. For case-insensitive searches, " "see {ref:ICONTAINS}."),
examples=[
SimpleExample('CONTAINS("RU0891923", "RU") = TRUE'),
SimpleExample('CONTAINS("RU0891923", "") = TRUE'),
SimpleExample('CONTAINS("Lorem ipsum", "abc") = FALSE'),
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -506,13 +506,13 @@ msgid ""
"functions#parsedatetime32besteffort"
msgstr ""

msgid "../concepts/data-types.md#geopolygon"
msgid "../dataset/data-types.md#geopolygon"
msgstr ""

msgid "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List"
msgstr ""

msgid "../concepts/data-types.md#tree-hierarchy"
msgid "../dataset/data-types.md#tree-hierarchy"
msgstr ""

msgid "https://en.wikipedia.org/wiki/Unix_time"
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -735,14 +735,14 @@ msgid ""
"functions#parsedatetime32besteffort"
msgstr ""

msgid "../concepts/data-types.md#geopolygon"
msgstr "../concepts/data-types.md#geopolygon"
msgid "../dataset/data-types.md#geopolygon"
msgstr "../dataset/data-types.md#geopolygon"

msgid "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List"
msgstr "https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List"

msgid "../concepts/data-types.md#tree-hierarchy"
msgstr "../concepts/data-types.md#tree-hierarchy"
msgid "../dataset/data-types.md#tree-hierarchy"
msgstr "../dataset/data-types.md#tree-hierarchy"

msgid "https://en.wikipedia.org/wiki/Unix_time"
msgstr "https://ru.wikipedia.org/wiki/Unix-время"
Expand Down Expand Up @@ -2422,8 +2422,9 @@ msgid ""
"Returns all {arg:0} substrings matching the {arg:1} regex. For regexes with "
"subgroups, it only works for the first subgroup."
msgstr ""
"Возвращает все подстроки {arg:0}, которые соответствуют регулярному выражению "
"{arg:1}. Для регулярных выражений с подгруппами работает только для первой подгруппы."
"Возвращает все подстроки {arg:0}, которые соответствуют регулярному "
"выражению {arg:1}. Для регулярных выражений с подгруппами работает только "
"для первой подгруппы."

msgid ""
"Returns a substring {arg:0} that matches the regular expression pattern "
Expand Down

0 comments on commit 8c6aa95

Please sign in to comment.