Repository: great-expectations/great_expectations

Issue:
Use cleaner solution for non-truncating division in python 2
Prefer `from __future__ import division` to `1.*x/y`


Discussion:
Done inline during improve_partitions push.

Resolving patch:
diff --git a/great_expectations/datasource/data_connector/batch_filter.py b/great_expectations/datasource/data_connector/batch_filter.py
--- a/great_expectations/datasource/data_connector/batch_filter.py
+++ b/great_expectations/datasource/data_connector/batch_filter.py
@@ -195,6 +195,9 @@ def select_from_data_connector_query(
                 batch_definition_list,
             )
         )
+        if len(selected_batch_definitions) == 0:
+            return selected_batch_definitions
+
         if self.index is None:
             selected_batch_definitions = selected_batch_definitions[: self.limit]
         else:


Test patch:
diff --git a/tests/rule_based_profiler/bob_user_workflow_fixture.py b/tests/rule_based_profiler/bob_user_workflow_fixture.py
deleted file mode 100644
--- a/tests/rule_based_profiler/bob_user_workflow_fixture.py
+++ /dev/null
@@ -1,34 +0,0 @@
-from typing import List
-
-import pytest
-
-
-@pytest.fixture
-def bob_columnar_table_multi_batch():
-    """
-    About the "Bob" User Workflow Fixture
-
-    Bob is working with monthly batches of taxi fare data. His data has the following columns:vendor_id,pickup_datetime,dropoff_datetime,passenger_count,trip_distance,rate_code_id,store_and_fwd_flag,pickup_location_id,dropoff_location_id,payment_type,fare_amount,extra,mta_tax,tip_amount,tolls_amount,improvement_surcharge,total_amount,congestion_surcharge
-
-    He wants to check periodically and as new data is added. Similar to Alice:
-
-      - He knows what some of the columns mean, but not all - and there are MANY of them (only a subset currently shown in examples and fixtures).
-
-      - He can assume that all batches share the same structure.
-
-      - There are some columns which share characteristics so he would like to apply the same set of expectations to them.
-
-    But he also:
-
-      - Wants to verify that the latest batches are not so different from all of the batches last year, if they are he wants to be alerted as maybe there are data collection issues or fares have changed significantly.
-
-    Bob configures his Profiler using the yaml configurations and data file locations captured in this fixture.
-    """
-
-    with open("bob_user_workflow_verbose_profiler_config.yml") as f:
-        verbose_profiler_config = f.read()
-
-    profiler_configs: List[str] = []
-    profiler_configs.append(verbose_profiler_config)
-
-    return {"profiler_configs": profiler_configs}
diff --git a/tests/rule_based_profiler/bob_user_workflow_verbose_profiler_config.yml b/tests/rule_based_profiler/bob_user_workflow_verbose_profiler_config.yml
deleted file mode 100644
--- a/tests/rule_based_profiler/bob_user_workflow_verbose_profiler_config.yml
+++ /dev/null
@@ -1,224 +0,0 @@
-# TODO: <Alex>ALEX -- This example configuration is stale (and would need work prior to using and/or testing).</Alex>
-# Note the call to Profiler.profile() takes multiple batches
-# Unless filtered / specified this list of batches will be used for all metrics/parameters
-# This profiler is meant to be used on the NYC taxi data (yellow_tripdata_sample_2019-*.csv)
-variables:
-  max_amount: 99999.99
-  false_positive_threshold: 0.01
-  quantiles:
-    - 0.05
-    - 0.25
-    - 0.50
-    - 0.75
-    - 0.95
-rules:
-  # Here we define 3 rules showing various methods to handle multi-batch parameters
-  # 1. my_rule_for_ids uses a simple ParameterBuilder to build a list of parameters per batch to be aggregated in the referencing ExpectationConfigurationBuilder
-  # 2. my_rule_for_amounts uses an aggregating ParameterBuilder to build a list of parameters and then aggregate them using a specified aggregation function. (While this example is not sufficiently complex to warrant a custom ParameterBuilder, one could be created - alternatively the complexity could be handled in a custom ExpectationConfigurationBuilder)
-  # 3. my_rule_for_numeric_data uses MultiBatchBootstrappedMetricDistributionParameterBuilder to compute multiple parameters to supply ExpectationConfigurationBuilders with pre-computed parameters
-
-  my_rule_for_ids:
-    # Create a value_set based on prior batches (relative to when the profiler is run) and evaluate new batches using this value_set
-    # Rationale: I want alerts when new value_set items are added to my dataset
-    class_name: Rule
-    module_name: great_expectations.profiler.rule
-    domain_builder:
-      # Build list of domains from some categorical column domains: vendor_id, rate_code_id, pickup_location_id, dropoff_location_id, payment_type
-      class_name: SimpleColumnSuffixDomainBuilder
-      module_name: great_expectations.profiler.domain_builder
-      column_name_suffixes:
-        - _id
-        - _type
-    parameter_builders:
-      - parameter_name: my_value_set_for_ids
-        # This parameter is the union of all observed batch value_sets
-        # MultiBatchParameterBuilder does not aggregate Parameters, it returns a list of value_set for each batch
-        class_name: MultiBatchParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        metric_domain_kwargs: $domain.domain_kwargs
-        # Specify all batches prior to the 6 most recent to be used to create this set of Parameters using the below batch_request
-        batch_request:
-          data_connector_query:
-            index: ":-6"
-        # Note: To specify all batches explicitly use the below batch_request
-        # batch_request:
-        #  data_connector_query:
-        #    index: "0:"
-        metric_name: column.distinct_values
-    expectation_configuration_builders:
-      # Create union of value sets here in the expectation_configuration_builder
-      - expectation_type: expect_column_values_to_be_in_set
-        column: $domain.domain_kwargs.column
-        # MultiBatchParameterBuilder returns a list of value_sets for each batch it was computed on
-        # so take the union() here
-        value_set: union($parameter.my_value_set_for_ids.value)
-
-  my_rule_for_amounts:
-    # This rule creates expect_column_values_to_be_between & expect_column_mean_to_be_between for each of the _amount column domains
-    # Rationale: I want alerts when my current data varies from prior data (within some bounds)
-    class_name: Rule
-    module_name: great_expectations.profiler.rule
-    domain_builder:
-      # Build list of domains from "amount" column domains: fare_amount,tip_amount,tolls_amount,total_amount
-      class_name: SimpleColumnSuffixDomainBuilder
-      module_name: great_expectations.profiler.domain_builder
-      column_name_suffixes:
-        - _amount
-    parameter_builders:
-      - parameter_name: my_mean_parameter_for_batches_in_previous_full_year
-        # Parameter computes the mean of all batches in the previous full year
-
-        # Options for where to calculate aggregate (mean of batch means)
-        # 1. Preferred: MultiBatchParameterBuilder returns a list of parameters calculated on each batch (e.g. [mean_batch_1, mean_batch_2, ...]) and then aggregation is done in the ExpectationConfigurationBuilder
-        # 2. Medium complexity configs: MultiBatchAggregateFunctionParameterBuilder which takes a metric_configuration to compute on a list of batches, then "aggregate_fn" parameter which defines an aggregate function to be calculated on all of the computed metrics. (other parameter builders can be customized to calculate non-linear or other more complicated aggregations)
-        # MultiBatchAggregateFunctionParameterBuilder takes optional function, if no function specified then return list of metric values like MultiBatchParameterBuilder.
-        # 3. High complexity configs: Custom ParameterBuilders / ExpectationConfigurationBuilders can be referenced via plugins
-        class_name: MultiBatchAggregateFunctionParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        batch_request:
-          # Filter for batches for previous full year
-          #  using batch_filter_parameters with `year` as one of the parameters
-          #  `year` needs to be defined as a group by the data_connector
-          data_connector_query:
-            batch_filter_parameters:
-              year: 2020
-        metric_configuration:
-          metric_name: column.mean # per batch metric
-          # Domain kwargs here refer to the current domain being processed - the list of domains coming from the DomainBuilder (here the list of columns filtered by SimpleColumnSuffixDomainBuilder)
-          metric_domain_kwargs: $domain.domain_kwargs
-        aggregate_fn: mean # Not necessarily a metric, but some function to apply to all of the batches - can be different from metric_name
-      - parameter_name: my_stdev_of_means_parameter_for_batches_in_previous_full_year
-        # Parameter computes the stdev of means of all batches in the previous full year
-        class_name: MultiBatchAggregateFunctionParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        batch_request:
-          data_connector_query:
-            batch_filter_parameters:
-              year: 2020
-        metric_configuration:
-          metric_name: column.mean # per batch metric
-          metric_domain_kwargs: $domain.domain_kwargs
-        aggregate_fn: stdev # note different than metric computed in metric_configuration
-      - parameter_name: my_max_of_congestion_surcharge_outside_of_domain_builder_domains
-        # This parameter computes the max of the congestion_surcharge column domain, which is outside of the set of domains collected by this Rule's DomainBuilder
-        class_name: MetricParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        metric_name: column.max
-        metric_domain_kwargs:
-          column: congestion_surcharge
-
-    expectation_configuration_builders:
-      - expectation_type: expect_column_values_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        # Note: literals are supported (you do not have to add to "variables" first, unless you want named references or to reference in multiple locations):
-        min_value: 0
-        max_value: $variables.max_amount
-        column: $domain.domain_kwargs.column
-      - expectation_type: expect_column_mean_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        # Note: proposal to reference here in dot notation by the aggregate_fn name
-        min_value: $parameter.my_mean_parameter_for_batches_in_previous_full_year.value * 0.8
-        max_value: $parameter.my_mean_parameter_for_batches_in_previous_full_year.value * 1.2
-        # Alternatively, we could have used a MultiBatchParameterBuilder and processed the means in the ExpectationConfigurationBuilder as in my_rule_for_ids
-        # min_value: mean($parameter.my_mean_parameter_for_batches_in_previous_full_year.value) * 0.8
-        # max_value: mean($parameter.my_mean_parameter_for_batches_in_previous_full_year.value) * 1.2
-        # Note: this would need us to add `mean()` to our GE language parsing these evaluations
-      - expectation_type: expect_column_stdev_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        min_value: $parameter.my_stdev_of_means_parameter_for_batches_in_previous_full_year.value * 0.8
-        max_value: $parameter.my_stdev_of_means_parameter_for_batches_in_previous_full_year.value * 1.2
-        # Alternatively, we could have used a MultiBatchParameterBuilder and processed the means in the ExpectationConfigurationBuilder as in my_rule_for_ids
-        # min_value: stdev($parameter.my_stdev_of_means_parameter_for_batches_in_previous_full_year.value) * 0.8
-        # max_value: stdev($parameter.my_stdev_of_means_parameter_for_batches_in_previous_full_year.value) * 1.2
-        # Note: this would need us to add `stdev()` to our GE language parsing these evaluations
-      - expectation_type: expect_column_max_to_be_between
-        # expect that the column max of any columns collected by the DomainBuilder is greater than the column max of congestion_surcharge
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        min_value: $parameter.my_max_of_congestion_surcharge_outside_of_domain_builder_domains.value
-        max_value: null
-
-  my_rule_for_numeric_data:
-    # This rule creates several expectations for all numeric column domains. There is some overlap with the my_rule_for_amounts rule
-    # Rationale: I want alerts when my current numeric data varies from prior data (within some bounds, based on a confidence level)
-    class_name: Rule
-    module_name: great_expectations.profiler.rule
-    domain_builder:
-      # Build list of domains from all numeric column domains by checking column storage type using the configured execution engine
-      class_name: SimpleSemanticTypeColumnDomainBuilder
-      module_name: great_expectations.profiler.domain_builder
-      semantic_types:
-        - numeric
-    parameter_builders:
-      # Note: my_column_mean and my_column_min are added as parameters but unused in expectation_configuration_builders - this is OK, we should still accept this as a valid Profiler configuration.
-      - parameter_name: my_column_mean
-        class_name: MetricParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        metric_name: column.mean
-        metric_domain_kwargs: $domain.domain_kwargs
-      - parameter_name: my_column_min
-        class_name: MetricParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        metric_name: column.min
-        metric_domain_kwargs: $domain.domain_kwargs
-      - parameter_name: my_column_max
-        class_name: MetricParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        metric_name: column.max
-        metric_domain_kwargs: $domain.domain_kwargs
-
-      - parameter_name: false_positive_threshold_min
-        class_name: MultiBatchBootstrappedMetricDistributionParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        batch_request:
-          data_connector_query:
-            # Note: interpreted like python slices e.g. most recent 10 batches
-            index: "-10:"
-        metric_configuration:
-          metric_name: column.min
-          # Process this metric on each of the domains in the list generated by the DomainBuilder:
-          metric_domain_kwargs: $domain.domain_kwargs
-        p_values:
-          min_value: $variables.false_positive_threshold
-          max_value: 1.0
-
-      - parameter_name: quantile_ranges
-        class_name: MultiBatchBootstrappedMetricDistributionParameterBuilder
-        module_name: great_expectations.profiler.parameter_builder
-        batch_request:
-          data_connector_query:
-            index: "-10:"
-        metric_configuration:
-          metric_name: column.quantile_values
-          metric_domain_kwargs: $domain.domain_kwargs
-          metric_value_kwargs:
-            quantiles: $variables.quantiles
-        p_values:
-          min_value: ($variables.false_positive_threshold / 2)
-          max_value: 1 - ($variables.false_positive_threshold / 2)
-
-    expectation_configuration_builders:
-      - expectation_type: expect_column_min_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        min_value: $parameter.false_positive_threshold_min.value.min_value
-        max_value: $parameter.false_positive_threshold_min.value.max_value
-      - expectation_type: expect_column_quantile_values_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        quantiles: $variables.quantiles
-        value_ranges: $parameter.quantile_ranges.value.ranges
-      - expectation_type: expect_column_max_to_be_between
-        class_name: DefaultExpectationConfigurationBuilder
-        module_name: great_expectations.profiler.expectation_configuration_builder
-        column: $domain.domain_kwargs.column
-        min_value: 0.9 * $parameter.my_column_max.value
-        max_value: 1.1 * $parameter.my_column_max.value
diff --git a/tests/rule_based_profiler/conftest.py b/tests/rule_based_profiler/conftest.py
--- a/tests/rule_based_profiler/conftest.py
+++ b/tests/rule_based_profiler/conftest.py
@@ -28,11 +28,6 @@
     alice_columnar_table_single_batch,
 )
 
-# noinspection PyUnresolvedReferences
-from tests.rule_based_profiler.bob_user_workflow_fixture import (
-    bob_columnar_table_multi_batch,
-)
-
 # noinspection PyUnresolvedReferences
 from tests.rule_based_profiler.bobby_user_workflow_fixture import (
     bobby_columnar_table_multi_batch,