diff --git a/dtable_events/tests/sql/test_reference.py b/dtable_events/tests/sql/test_reference.py index 0eba2a9b..85083a56 100644 --- a/dtable_events/tests/sql/test_reference.py +++ b/dtable_events/tests/sql/test_reference.py @@ -266,7 +266,7 @@ def get_expected_sql_for_modifier(filter_modifier, column_name): "filter_predicate": 'And', "sorts":[], }, - "expected_sql": "SELECT * FROM `Table1` WHERE `createTime` <= '2021-12-20' and `createTime` is not null LIMIT 0, 100", + "expected_sql": "SELECT * FROM `Table1` WHERE `createTime` < '2021-12-21' and `createTime` is not null LIMIT 0, 100", "by_group": False, }, { diff --git a/dtable_events/utils/sql_generator.py b/dtable_events/utils/sql_generator.py index 5c9db79c..c53ea16c 100644 --- a/dtable_events/utils/sql_generator.py +++ b/dtable_events/utils/sql_generator.py @@ -846,9 +846,11 @@ def op_is_on_or_before(self): target_date, _ = self._other_date() if not target_date: return "" - return "`%(column_name)s` <= '%(target_date)s' and `%(column_name)s` is not null" % ({ + + next_date = self._format_date(target_date + timedelta(days=1)) + return "`%(column_name)s` < '%(target_date)s' and `%(column_name)s` is not null" % ({ "column_name": self.column_name, - "target_date": self._format_date(target_date) + "target_date": next_date }) def op_is_on_or_after(self):