From 92e1098a87333f105a364b1dc4a1b670a216de73 Mon Sep 17 00:00:00 2001 From: Paul Holser Date: Mon, 15 Jul 2024 11:53:32 -0500 Subject: [PATCH 1/2] ISO 8601 date should accept 24-hr times --- soda/core/soda/execution/data_source.py | 2 +- soda/core/tests/data_source/test_formats.py | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/soda/core/soda/execution/data_source.py b/soda/core/soda/execution/data_source.py index e48fd658d..988fffd39 100644 --- a/soda/core/soda/execution/data_source.py +++ b/soda/core/soda/execution/data_source.py @@ -86,7 +86,7 @@ def build_default_formats(): "date inverse": rf"^{s}{year}[-\./]{month}[-\./]{day}{s}$", "date iso 8601": f"^{s}" rf"{year4}-?({month2}-?{day2}|W[0-5]\d(-?[1-7])?|[0-3]\d\d)" - rf"([ T]{hour2}(:?{minute2}(:?{second2}([.,]\d+)?)?)?([+-]{hour2}:?{minute2}|Z)?)?" + rf"([ T]{hour24}(:?{minute2}(:?{second2}([.,]\d+)?)?)?([+-]{hour24}:?{minute2}|Z)?)?" f"{s}$", "time 24h": f"^{s}{hour24}:{minute}(:{second})?{s}$", "time 24h nosec": f"^{s}{hour24}:{minute}{s}$", diff --git a/soda/core/tests/data_source/test_formats.py b/soda/core/tests/data_source/test_formats.py index 54fed586f..f813567e6 100644 --- a/soda/core/tests/data_source/test_formats.py +++ b/soda/core/tests/data_source/test_formats.py @@ -56,6 +56,8 @@ def test_formats(data_source_fixture: DataSourceFixture): "07-04-1776", "08-15-1620", "09-20-1519", + "01-01-2100", + "01-01-1899", ], "failing_values": [ "", @@ -121,6 +123,9 @@ def test_formats(data_source_fixture: DataSourceFixture): "2020-02-08 09Z", "2020-04-30", "2020-04-30T00:00:00.000", + "2020-10-11 11:34", + "2100-01-01 14:36", + "1899-01-01 21:55", ], "failing_values": [ "", @@ -129,6 +134,8 @@ def test_formats(data_source_fixture: DataSourceFixture): "9999-01-01", "2000-13-01", "2000-01-32", + "2020-10-11 90:34", + "2100-01-01 14:67", ], }, } From a6a9ed4e4678c965eee943d2ba575c565e6047bf Mon Sep 17 00:00:00 2001 From: Paul Holser Date: Tue, 16 Jul 2024 13:26:25 -0500 Subject: [PATCH 2/2] Adjust mysql iso 8601 date regex --- soda/core/tests/data_source/test_formats.py | 1 + soda/mysql/soda/data_sources/mysql_data_source.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/soda/core/tests/data_source/test_formats.py b/soda/core/tests/data_source/test_formats.py index f813567e6..76ff11dd3 100644 --- a/soda/core/tests/data_source/test_formats.py +++ b/soda/core/tests/data_source/test_formats.py @@ -126,6 +126,7 @@ def test_formats(data_source_fixture: DataSourceFixture): "2020-10-11 11:34", "2100-01-01 14:36", "1899-01-01 21:55", + "1623-10-11T10:10:10.0000+01:00", ], "failing_values": [ "", diff --git a/soda/mysql/soda/data_sources/mysql_data_source.py b/soda/mysql/soda/data_sources/mysql_data_source.py index 484f2d5e2..beda97e7f 100644 --- a/soda/mysql/soda/data_sources/mysql_data_source.py +++ b/soda/mysql/soda/data_sources/mysql_data_source.py @@ -71,7 +71,7 @@ def __init__(self, logs: Logs, data_source_name: str, data_source_properties: di "integer": r"^[[:blank:]]*[-+]?[[:blank:]]*[[:digit:]]+$", "positive integer": r"^[[:blank:]]*[+]?[[:blank:]]*[[:digit:]]+$", "negative integer": r"^[[:blank:]]*(-[[:blank:]]*[[:digit:]]+|0)[[:blank:]]*$", - "date iso 8601": r"^ *(19|20)[[:digit:]][[:digit:]]-?((0[0-9]|1[12])-?([012][0-9]|3[01])|W[0-5][[:digit:]](-?[1-7])?|[0-3][[:digit:]][[:digit:]])([ T](0[0-9]|1[012])(:?[0-5][0-9](:?[0-5][0-9]([.,][[:digit:]]+)?)?)?([+-](0[0-9]|1[012]):?[0-5][0-9]|Z)?)? *$", + "date iso 8601": r"^ *[12][[:digit:]][[:digit:]][[:digit:]]-?((0[1-9]|1[012])-?((0[1-9]|[12][0-9]|3[01]))|W[0-5][[:digit:]](-?[1-7])?|[0-3][[:digit:]][[:digit:]])([ T](0?[0-9]|[01][[:digit:]]|2[0-3])(:?[0-5][0-9](:?[0-5][0-9]([.,][[:digit:]]+)?)?)?([+-](0[0-9]|1[012]):?[0-5][0-9]|Z)?)? *$", } )