Skip to content

Commit

Permalink
Merge branch 'develop' into m/_/mob_sim_rules
Browse files Browse the repository at this point in the history
  • Loading branch information
Kilo59 committed Apr 15, 2024
2 parents 4add27b + f293aa2 commit 4999769
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 15 deletions.
14 changes: 8 additions & 6 deletions great_expectations/datasource/fluent/sql_datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,31 +649,33 @@ def add_batch_definition_whole_table(self, name: str) -> BatchDefinition:

@public_api
def add_batch_definition_yearly(
self, name: str, column: str, sort_asc: bool = True
self, name: str, column: str, sort_ascending: bool = True
) -> BatchDefinition:
return self.add_batch_definition(
name=name,
partitioner=PartitionerYear(column_name=column),
partitioner=PartitionerYear(column_name=column, sort_ascending=sort_ascending),
batching_regex=None,
)

@public_api
def add_batch_definition_monthly(
self, name: str, column: str, sort_asc: bool = True
self, name: str, column: str, sort_ascending: bool = True
) -> BatchDefinition:
return self.add_batch_definition(
name=name,
partitioner=PartitionerYearAndMonth(column_name=column),
partitioner=PartitionerYearAndMonth(column_name=column, sort_ascending=sort_ascending),
batching_regex=None,
)

@public_api
def add_batch_definition_daily(
self, name: str, column: str, sort_asc: bool = True
self, name: str, column: str, sort_ascending: bool = True
) -> BatchDefinition:
return self.add_batch_definition(
name=name,
partitioner=PartitionerYearAndMonthAndDay(column_name=column),
partitioner=PartitionerYearAndMonthAndDay(
column_name=column, sort_ascending=sort_ascending
),
batching_regex=None,
)

Expand Down
39 changes: 30 additions & 9 deletions tests/datasource/fluent/data_asset/test_sql_asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,55 +97,76 @@ def test_add_batch_definition_fluent_sql__add_batch_definition_whole_table(datas


@pytest.mark.unit
def test_add_batch_definition_fluent_sql__add_batch_definition_yearly(datasource, asset):
@pytest.mark.parametrize("sort_ascending", (True, False))
def test_add_batch_definition_fluent_sql__add_batch_definition_yearly(
datasource, asset, sort_ascending
):
# arrange
name = "batch_def_name"
column = "test_column"
expected_batch_definition = BatchDefinition(
name=name, partitioner=PartitionerYear(column_name=column), batching_regex=None
name=name,
partitioner=PartitionerYear(column_name=column, sort_ascending=sort_ascending),
batching_regex=None,
)
datasource.add_batch_definition.return_value = expected_batch_definition

# act
batch_definition = asset.add_batch_definition_yearly(name=name, column=column)
batch_definition = asset.add_batch_definition_yearly(
name=name, column=column, sort_ascending=sort_ascending
)

# assert
assert batch_definition == expected_batch_definition
datasource.add_batch_definition.assert_called_once_with(expected_batch_definition)


@pytest.mark.unit
def test_add_batch_definition_fluent_sql__add_batch_definition_monthly(datasource, asset):
@pytest.mark.parametrize("sort_ascending", (True, False))
def test_add_batch_definition_fluent_sql__add_batch_definition_monthly(
datasource, asset, sort_ascending
):
# arrange
name = "batch_def_name"
column = "test_column"
expected_batch_definition = BatchDefinition(
name=name, partitioner=PartitionerYearAndMonth(column_name=column), batching_regex=None
name=name,
partitioner=PartitionerYearAndMonth(column_name=column, sort_ascending=sort_ascending),
batching_regex=None,
)
datasource.add_batch_definition.return_value = expected_batch_definition

# act
batch_definition = asset.add_batch_definition_monthly(name=name, column=column)
batch_definition = asset.add_batch_definition_monthly(
name=name, column=column, sort_ascending=sort_ascending
)

# assert
assert batch_definition == expected_batch_definition
datasource.add_batch_definition.assert_called_once_with(expected_batch_definition)


@pytest.mark.unit
def test_add_batch_definition_fluent_sql__add_batch_definition_daily(datasource, asset):
@pytest.mark.parametrize("sort_ascending", (True, False))
def test_add_batch_definition_fluent_sql__add_batch_definition_daily(
datasource, asset, sort_ascending
):
# arrange
name = "batch_def_name"
column = "test_column"
expected_batch_definition = BatchDefinition(
name=name,
partitioner=PartitionerYearAndMonthAndDay(column_name=column),
partitioner=PartitionerYearAndMonthAndDay(
column_name=column, sort_ascending=sort_ascending
),
batching_regex=None,
)
datasource.add_batch_definition.return_value = expected_batch_definition

# act
batch_definition = asset.add_batch_definition_daily(name=name, column=column)
batch_definition = asset.add_batch_definition_daily(
name=name, column=column, sort_ascending=sort_ascending
)

# assert
assert batch_definition == expected_batch_definition
Expand Down

0 comments on commit 4999769

Please sign in to comment.