Skip to content

Commit

Permalink
db/python/tables/bq/billing_gcp_daily.py add DATE_FORMAT constant
Browse files Browse the repository at this point in the history
  • Loading branch information
violetbrina committed Oct 7, 2024
1 parent 697bb5d commit a642e5a
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions db/python/tables/bq/billing_gcp_daily.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
from db.python.tables.bq.generic_bq_filter import GenericBQFilter
from models.models import BillingColumn, BillingTotalCostQueryModel

DATE_FORMAT = '%Y-%m-%d'


class BillingGcpDailyTable(BillingBaseTable):
"""Billing GCP Daily Big Query table"""
Expand All @@ -37,21 +39,25 @@ def _query_to_partitioned_filter(

# initial partition filter
billing_filter.part_time = GenericBQFilter[datetime](
gte=datetime.strptime(query.start_date, '%Y-%m-%d')
if query.start_date
else None,
lte=(datetime.strptime(query.end_date, '%Y-%m-%d') + timedelta(days=7))
if query.end_date
else None,
gte=datetime.strptime(query.start_date, '') if query.start_date else None,
lte=(
(datetime.strptime(query.end_date, DATE_FORMAT) + timedelta(days=7))
if query.end_date
else None
),
)
# add day filter after partition filter is applied
billing_filter.day = GenericBQFilter[datetime](
gte=datetime.strptime(query.start_date, '%Y-%m-%d')
if query.start_date
else None,
lte=datetime.strptime(query.end_date, '%Y-%m-%d')
if query.end_date
else None,
gte=(
datetime.strptime(query.start_date, DATE_FORMAT)
if query.start_date
else None
),
lte=(
datetime.strptime(query.end_date, DATE_FORMAT)
if query.end_date
else None
),
)
return billing_filter

Expand Down

0 comments on commit a642e5a

Please sign in to comment.