diff --git a/lib/dl_formula_ref/dl_formula_ref/categories/type_conversion.py b/lib/dl_formula_ref/dl_formula_ref/categories/type_conversion.py index aa3cf6221..f3898f0f6 100644 --- a/lib/dl_formula_ref/dl_formula_ref/categories/type_conversion.py +++ b/lib/dl_formula_ref/dl_formula_ref/categories/type_conversion.py @@ -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")), } ), diff --git a/lib/dl_formula_ref/dl_formula_ref/example_data.json b/lib/dl_formula_ref/dl_formula_ref/example_data.json index f13a61c8c..62d1938b0 100644 --- a/lib/dl_formula_ref/dl_formula_ref/example_data.json +++ b/lib/dl_formula_ref/dl_formula_ref/example_data.json @@ -98,13 +98,16 @@ { "columns": [ { - "name": "Warmest Month", - "type": "STRING" + "name": "Warmest Day", + "type": "DATE" } ], "rows": [ [ - "July" + { + "__type__": "date", + "__value__": "2019-03-01" + } ] ] } @@ -114,13 +117,16 @@ { "columns": [ { - "name": "Coldest Month", - "type": "STRING" + "name": "Coldest Day", + "type": "DATE" } ], "rows": [ [ - "January" + { + "__type__": "date", + "__value__": "2019-03-08" + } ] ] } @@ -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", { @@ -3790,9 +3849,9 @@ ], "rows": [ [ - -1.0, - 7.0, - 18.0 + -3.0, + 0.0, + 4.0 ] ] } @@ -5441,7 +5500,7 @@ ], "rows": [ [ - 10.205464964983964 + 3.8954129979043843 ] ] } @@ -5457,7 +5516,7 @@ ], "rows": [ [ - 9.770988804733236 + 3.7295740001000413 ] ] } diff --git a/lib/dl_formula_ref/dl_formula_ref/functions/aggregation.py b/lib/dl_formula_ref/dl_formula_ref/functions/aggregation.py index 8ea1fd9b8..277e97c2a 100644 --- a/lib/dl_formula_ref/dl_formula_ref/functions/aggregation.py +++ b/lib/dl_formula_ref/dl_formula_ref/functions/aggregation.py @@ -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 ( @@ -14,6 +16,8 @@ _ = get_gettext() +_d = datetime.date + _SOURCE_INT_FLOAT_1 = ExampleSource( columns=[ ("City", DataType.STRING), @@ -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], ], ) @@ -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])"), ], ), ), @@ -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])"), ], ), ), diff --git a/lib/dl_formula_ref/dl_formula_ref/functions/date.py b/lib/dl_formula_ref/dl_formula_ref/functions/date.py index b54e09370..047bd012f 100644 --- a/lib/dl_formula_ref/dl_formula_ref/functions/date.py +++ b/lib/dl_formula_ref/dl_formula_ref/functions/date.py @@ -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, + ) + ), ], ) diff --git a/lib/dl_formula_ref/dl_formula_ref/functions/string.py b/lib/dl_formula_ref/dl_formula_ref/functions/string.py index 0863237ee..519db91ed 100644 --- a/lib/dl_formula_ref/dl_formula_ref/functions/string.py +++ b/lib/dl_formula_ref/dl_formula_ref/functions/string.py @@ -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'), ], ) diff --git a/lib/dl_formula_ref/dl_formula_ref/locales/en/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po b/lib/dl_formula_ref/dl_formula_ref/locales/en/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po index 0fa5ba3a4..03c881a20 100644 --- a/lib/dl_formula_ref/dl_formula_ref/locales/en/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po +++ b/lib/dl_formula_ref/dl_formula_ref/locales/en/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po @@ -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" diff --git a/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.mo b/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.mo index 484f9f3a9..0b3ebe4b8 100644 Binary files a/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.mo and b/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.mo differ diff --git a/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po b/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po index 7cba08880..bb1595ad4 100644 --- a/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po +++ b/lib/dl_formula_ref/dl_formula_ref/locales/ru/LC_MESSAGES/dl_formula_ref_dl_formula_ref.po @@ -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-время" @@ -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 "