Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CONTRIB] Exclude null values no days missing metric #10517

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


class ColumnDistinctDates(ColumnAggregateMetricProvider):
"""Metric that get all unique dates from date column"""
"""Metric that get all unique dates from date column (excluding null values)"""

metric_name = "column.distinct_dates"

Expand All @@ -36,8 +36,13 @@ def _sqlalchemy(
column_name = accessor_domain_kwargs["column"]
column = sa.column(column_name)

# get all unique dates from timestamp
query = sa.select(sa.func.Date(column).distinct()).select_from(selectable)
# get all unique dates from timestamp (excluding null values)
query = (
sa.select(sa.func.Date(column).distinct())
.select_from(selectable)
.where(column.is_not(None))
)

all_unique_dates = [i[0] for i in execution_engine.execute_query(query).fetchall()]

# Only sqlite returns as strings, so make date objects be strings
Expand Down
Loading