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/rule_based_profiler/data_assistant/data_assistant.py b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
--- a/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
+++ b/great_expectations/rule_based_profiler/data_assistant/data_assistant.py
@@ -681,6 +681,7 @@ def run_profiler_on_data(
 
 
 def build_map_metric_rule(
+    data_assistant_class_name: str,
     rule_name: str,
     expectation_type: str,
     map_metric_name: str,
@@ -727,17 +728,40 @@ def build_map_metric_rule(
         )
     )
 
-    # Step-2: Declare "ParameterBuilder" for every metric of interest.
+    # Step-2: Declare "ParameterBuilder" for every relevant metric of interest.
 
-    column_values_unique_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
-        DataAssistant.commonly_used_parameter_builders.get_column_values_unique_unexpected_count_metric_multi_batch_parameter_builder()
-    )
-    column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
-        DataAssistant.commonly_used_parameter_builders.get_column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder()
-    )
-    column_values_null_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
-        DataAssistant.commonly_used_parameter_builders.get_column_values_null_unexpected_count_metric_multi_batch_parameter_builder()
-    )
+    parameter_builders: List[ParameterBuilder] = []
+
+    column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_evaluations: Optional[
+        ParameterBuilder
+    ] = None
+
+    if map_metric_name == "column_values.unique":
+        column_values_unique_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
+            DataAssistant.commonly_used_parameter_builders.get_column_values_unique_unexpected_count_metric_multi_batch_parameter_builder()
+        )
+        parameter_builders.append(
+            column_values_unique_unexpected_count_metric_multi_batch_parameter_builder_for_metrics
+        )
+    elif map_metric_name == "column_values.null":
+        column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
+            DataAssistant.commonly_used_parameter_builders.get_column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder()
+        )
+        column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_evaluations = column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_metrics
+        parameter_builders.append(
+            column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_metrics
+        )
+    elif map_metric_name == "column_values.nonnull":
+        column_values_null_unexpected_count_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
+            DataAssistant.commonly_used_parameter_builders.get_column_values_null_unexpected_count_metric_multi_batch_parameter_builder()
+        )
+        parameter_builders.append(
+            column_values_null_unexpected_count_metric_multi_batch_parameter_builder_for_metrics
+        )
+    else:
+        raise ValueError(
+            f"""Metric "{map_metric_name}" is not supported as part of "{data_assistant_class_name}" implementation."""
+        )
 
     # Step-3: Set up "MeanUnexpectedMapMetricMultiBatchParameterBuilder" to compute "condition" for emitting "ExpectationConfiguration" (based on "Domain" data).
 
@@ -746,9 +770,14 @@ def build_map_metric_rule(
             DataAssistant.commonly_used_parameter_builders.get_table_row_count_metric_multi_batch_parameter_builder()
         )
 
-    column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_evaluations: ParameterBuilder = (
-        DataAssistant.commonly_used_parameter_builders.get_column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder()
-    )
+    if (
+        column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_evaluations
+        is None
+    ):
+        column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_evaluations = (
+            DataAssistant.commonly_used_parameter_builders.get_column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder()
+        )
+
     evaluation_parameter_builder_configs: Optional[List[ParameterBuilderConfig]] = [
         ParameterBuilderConfig(
             **total_count_metric_multi_batch_parameter_builder_for_evaluations.to_json_dict()
@@ -791,11 +820,6 @@ def build_map_metric_rule(
         "success_ratio": 7.5e-1,
     }
 
-    parameter_builders: List[ParameterBuilder] = [
-        column_values_unique_unexpected_count_metric_multi_batch_parameter_builder_for_metrics,
-        column_values_nonnull_unexpected_count_metric_multi_batch_parameter_builder_for_metrics,
-        column_values_null_unexpected_count_metric_multi_batch_parameter_builder_for_metrics,
-    ]
     expectation_configuration_builders: List[ExpectationConfigurationBuilder] = [
         expect_column_values_to_be_attribute_expectation_configuration_builder,
     ]
diff --git a/great_expectations/rule_based_profiler/data_assistant/onboarding_data_assistant.py b/great_expectations/rule_based_profiler/data_assistant/onboarding_data_assistant.py
--- a/great_expectations/rule_based_profiler/data_assistant/onboarding_data_assistant.py
+++ b/great_expectations/rule_based_profiler/data_assistant/onboarding_data_assistant.py
@@ -76,6 +76,7 @@ def get_rules(self) -> Optional[List[Rule]]:
         )
 
         column_value_uniqueness_rule: Rule = build_map_metric_rule(
+            data_assistant_class_name=self.__class__.__name__,
             rule_name="column_value_uniqueness_rule",
             expectation_type="expect_column_values_to_be_unique",
             map_metric_name="column_values.unique",
@@ -93,6 +94,7 @@ def get_rules(self) -> Optional[List[Rule]]:
             min_max_unexpected_values_proportion=9.75e-1,
         )
         column_value_nullity_rule: Rule = build_map_metric_rule(
+            data_assistant_class_name=self.__class__.__name__,
             rule_name="column_value_nullity_rule",
             expectation_type="expect_column_values_to_be_null",
             map_metric_name="column_values.null",
@@ -110,6 +112,7 @@ def get_rules(self) -> Optional[List[Rule]]:
             min_max_unexpected_values_proportion=9.75e-1,
         )
         column_value_nonnullity_rule: Rule = build_map_metric_rule(
+            data_assistant_class_name=self.__class__.__name__,
             rule_name="column_value_nonnullity_rule",
             expectation_type="expect_column_values_to_not_be_null",
             map_metric_name="column_values.nonnull",
@@ -613,19 +616,12 @@ def _build_datetime_columns_rule() -> Rule:
 
         # Step-2: Declare "ParameterBuilder" for every metric of interest.
 
-        column_partition_parameter_builder_for_metrics: ParameterBuilder = DataAssistant.commonly_used_parameter_builders.build_partition_parameter_builder(
-            name="column_values.partition",
-            bucketize_data=False,
-        )
         column_min_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
             DataAssistant.commonly_used_parameter_builders.get_column_min_metric_multi_batch_parameter_builder()
         )
         column_max_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
             DataAssistant.commonly_used_parameter_builders.get_column_max_metric_multi_batch_parameter_builder()
         )
-        column_quantile_values_metric_multi_batch_parameter_builder_for_metrics: ParameterBuilder = (
-            DataAssistant.commonly_used_parameter_builders.get_column_quantile_values_metric_multi_batch_parameter_builder()
-        )
 
         # Step-3: Declare "ParameterBuilder" for every "validation" need in "ExpectationConfigurationBuilder" objects.
 
@@ -653,20 +649,6 @@ def _build_datetime_columns_rule() -> Rule:
             evaluation_parameter_builder_configs=evaluation_parameter_builder_configs,
         )
 
-        evaluation_parameter_builder_configs = [
-            ParameterBuilderConfig(
-                **column_quantile_values_metric_multi_batch_parameter_builder_for_metrics.to_json_dict()
-            ),
-        ]
-        column_quantile_values_range_parameter_builder_for_validations: ParameterBuilder = DataAssistant.commonly_used_parameter_builders.build_numeric_metric_range_multi_batch_parameter_builder(
-            metric_name=None,
-            metric_value_kwargs={
-                "quantiles": f"{VARIABLES_KEY}quantiles",
-                "allow_relative_error": f"{VARIABLES_KEY}allow_relative_error",
-            },
-            evaluation_parameter_builder_configs=evaluation_parameter_builder_configs,
-        )
-
         # Step-4: Pass "validation" "ParameterBuilderConfig" objects to every "DefaultExpectationConfigurationBuilder", responsible for emitting "ExpectationConfiguration" (with specified "expectation_type").
 
         validation_parameter_builder_configs: Optional[List[ParameterBuilderConfig]]
@@ -732,37 +714,12 @@ def _build_datetime_columns_rule() -> Rule:
             },
         )
 
-        validation_parameter_builder_configs = [
-            ParameterBuilderConfig(
-                **column_quantile_values_range_parameter_builder_for_validations.to_json_dict(),
-            ),
-        ]
-        expect_column_quantile_values_to_be_between_expectation_configuration_builder = DefaultExpectationConfigurationBuilder(
-            expectation_type="expect_column_quantile_values_to_be_between",
-            validation_parameter_builder_configs=validation_parameter_builder_configs,
-            column=f"{DOMAIN_KWARGS_PARAMETER_FULLY_QUALIFIED_NAME}{FULLY_QUALIFIED_PARAMETER_NAME_SEPARATOR_CHARACTER}column",
-            quantile_ranges={
-                "quantiles": f"{VARIABLES_KEY}quantiles",
-                "value_ranges": f"{column_quantile_values_range_parameter_builder_for_validations.json_serialized_fully_qualified_parameter_name}{FULLY_QUALIFIED_PARAMETER_NAME_SEPARATOR_CHARACTER}{FULLY_QUALIFIED_PARAMETER_NAME_VALUE_KEY}",
-            },
-            allow_relative_error=f"{VARIABLES_KEY}allow_relative_error",
-            meta={
-                "profiler_details": f"{column_quantile_values_range_parameter_builder_for_validations.json_serialized_fully_qualified_parameter_name}{FULLY_QUALIFIED_PARAMETER_NAME_SEPARATOR_CHARACTER}{FULLY_QUALIFIED_PARAMETER_NAME_METADATA_KEY}",
-            },
-        )
-
         # Step-5: Instantiate and return "Rule" object, comprised of "variables", "domain_builder", "parameter_builders", and "expectation_configuration_builders" components.
 
         variables: dict = {
             "mostly": 1.0,
             "strict_min": False,
             "strict_max": False,
-            "quantiles": [
-                0.25,
-                0.5,
-                0.75,
-            ],
-            "allow_relative_error": False,
             "false_positive_rate": 0.05,
             "estimator": "bootstrap",
             "n_resamples": 9999,
@@ -778,16 +735,13 @@ def _build_datetime_columns_rule() -> Rule:
             "round_decimals": 1,
         }
         parameter_builders: List[ParameterBuilder] = [
-            column_partition_parameter_builder_for_metrics,
             column_min_metric_multi_batch_parameter_builder_for_metrics,
             column_max_metric_multi_batch_parameter_builder_for_metrics,
-            column_quantile_values_metric_multi_batch_parameter_builder_for_metrics,
         ]
         expectation_configuration_builders: List[ExpectationConfigurationBuilder] = [
             expect_column_min_to_be_between_expectation_configuration_builder,
             expect_column_max_to_be_between_expectation_configuration_builder,
             expect_column_values_to_be_between_expectation_configuration_builder,
-            expect_column_quantile_values_to_be_between_expectation_configuration_builder,
         ]
         rule = Rule(
             name="datetime_columns_rule",


Test patch:
diff --git a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
--- a/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
+++ b/tests/rule_based_profiler/data_assistant/test_onboarding_data_assistant.py
@@ -284,7 +284,7 @@ def test_onboarding_data_assistant_metrics_count(
     ) in bobby_onboarding_data_assistant_result.metrics_by_domain.items():
         num_metrics += len(parameter_values_for_fully_qualified_parameter_names)
 
-    assert num_metrics == 184
+    assert num_metrics == 150
 
 
 @pytest.mark.integration