Skip to content

Commit a70e3f3

Browse files
authored
Move computation of end_date to create_tableau_parquet (#687)
1 parent 0434432 commit a70e3f3

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lamp_py/tableau/jobs/filtered_hyper.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,22 @@ def __init__(
3434
parquet_filter: pc.Expression | None = None,
3535
dataframe_filter: Callable[[pl.DataFrame], pl.DataFrame] | None = None,
3636
) -> None:
37-
"""Validate start_date and end_date and assign properties if so."""
37+
"""Validate start_date and end_date and assign properties if valid."""
3838
HyperJob.__init__(
3939
self,
4040
hyper_file_name=remote_output_location.prefix.rsplit("/")[-1].replace(".parquet", ".hyper"),
4141
remote_parquet_path=remote_output_location.s3_uri,
4242
lamp_version=remote_output_location.version,
4343
project_name=tableau_project_name,
4444
)
45-
if end_date is not None:
46-
assert isinstance(start_date, date)
47-
elif isinstance(start_date, int):
48-
end_date = date.today()
49-
start_date = end_date - timedelta(days=start_date)
5045

5146
self.remote_input_location = remote_input_location
5247
self.remote_output_location = remote_output_location
5348
self.processed_schema = processed_schema # expected output schema passed in
5449
self.partition_template = partition_template
5550

5651
if start_date is not None and end_date is not None:
52+
assert isinstance(start_date, date)
5753
assert start_date <= end_date
5854

5955
self.start_date = start_date
@@ -87,6 +83,10 @@ def create_tableau_parquet(self, partition_template: str) -> bool:
8783
-------
8884
True if parquet created, False otherwise
8985
"""
86+
if isinstance(self.start_date, int):
87+
self.end_date = date.today()
88+
self.start_date = self.end_date - timedelta(days=self.start_date)
89+
9090
if self.start_date is not None and self.end_date is not None:
9191
# limitation of filtered hyper only does whole days.
9292
# update to allow start/end set by hour, to get the entire

0 commit comments

Comments
 (0)