From 8c6aa9518443a29ece0de25cd2fa80dba4f27873 Mon Sep 17 00:00:00 2001 From: Dmitriy Shamshin <79089543+shamshinds@users.noreply.github.com> Date: Fri, 4 Oct 2024 09:39:57 +0300 Subject: [PATCH] docs: DOCSUP-83022: Fixes in function ref texts (part 5) (#632) example updates --- .../categories/type_conversion.py | 4 +- .../dl_formula_ref/example_data.json | 81 +++++++++++++++--- .../dl_formula_ref/functions/aggregation.py | 34 ++++---- .../dl_formula_ref/functions/date.py | 20 ++++- .../dl_formula_ref/functions/string.py | 1 + .../dl_formula_ref_dl_formula_ref.po | 4 +- .../dl_formula_ref_dl_formula_ref.mo | Bin 139895 -> 139891 bytes .../dl_formula_ref_dl_formula_ref.po | 13 +-- 8 files changed, 120 insertions(+), 37 deletions(-) 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_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ygscm;Khyne*43Ae{lNH_k7aZ*eIN3O-@v8XnAN&EV!!Mmo`>%pdKdy#14L{(&**v_0!jVl3sP|JMk! zBM&f&^GBARu|4|}w{t_vFGen7IHye_1qT&SF!B8JMml2w>cLd|f^mLUr{PfI(ib@| zD0m#|>fU+DmfQNW(QgyEh&tr^uh?>8uj<-i%r|iHF*kT$vk%V0Zp2lu^MSwvNw@*W z{$|%m^_%vLKm5CqiQE_ehmi?bfbEO%d+(NgZgruN`=oEUZJghNtM6F-SU{N`bOkR5a^#Ge<>A&qusRQcCI2o&BGU`Ze#&CRu z`dkZfIp<3xRwEvQ?p9pP;G#7i#)VkQSXZMD4GDEw!;86`FP|>OUCv8s3YH*$GoInO zttDK}2TY2G%NfBds8bo@>2gNG&&%Z;Xl1=!@{siA-h6-Q`#hwiONKEdlhHZj%eb76 z$G~7kP(7GI3B}rRZ;pS)Kwf*&5poS)VJRkSOxP?U(=UR8~C&+ zem>9+eK2bJ>!@$X&VgLioLCrD}80kq>lHS=4xV6pZWP~p1;4p%ZyJAsdCz^+xA>Q=Z0Pbl12;| jG;;K))cCFe{|28PuV-G`w!Z7bbN?p&U;Zxg*WLLCY%l3( 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 "