diff --git a/tap_suiteql/query_builder.py b/tap_suiteql/query_builder.py index 5de58e3..51be908 100644 --- a/tap_suiteql/query_builder.py +++ b/tap_suiteql/query_builder.py @@ -36,12 +36,14 @@ def _build_from_statement(self): def _build_where_statement(self): where_clauses = ["1=1"] where_statement = "where " - - if self.stream.year_date_field: # Filter added due to the limit of 100 thousand records that the Sensedata API returns + + if ( + self.stream.year_date_field + ): # Filter added due to the limit of 100 thousand records that the Sensedata API returns # noqa:E501 where_clauses.append( - f"TO_CHAR({self.stream.year_date_field}, 'YYYY') >= 2023 and {self.stream.year_date_field} < ADD_MONTHS(SYSDATE, 3)" #noqa:E501 - ) - + f"TO_CHAR({self.stream.year_date_field}, 'YYYY') >= 2023 and {self.stream.year_date_field} < ADD_MONTHS(SYSDATE, 3)" # noqa:E501 + ) + if self.stream.replication_key: where_clauses.append( f"{self.stream.replication_key} >= TO_DATE(:{self.stream.replication_key}, 'YYYY-MM-DD\"T\"HH24:MI:SS')" # noqa:E501 diff --git a/tap_suiteql/tests/test_query_builder.py b/tap_suiteql/tests/test_query_builder.py index 1007a41..f4912c1 100644 --- a/tap_suiteql/tests/test_query_builder.py +++ b/tap_suiteql/tests/test_query_builder.py @@ -92,12 +92,11 @@ class DummyStreamWithFilter: "col_id": {}, "col_1": {}, "col_2": {}, - "year_date_field": {"format": "date-time"}, + "year_date_field": {"format": "date-time"}, }, } - def test_sql_builder_with_replication_key(): expected = """select col_id,col_1,col_2,TO_CHAR(date_col, 'YYYY-MM-DD\"T\"HH24:MI:SS') date_col,TO_CHAR(replication_key_col, 'YYYY-MM-DD\"T\"HH24:MI:SS') replication_key_col from dummy