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/core/config_peer.py b/great_expectations/core/config_peer.py
--- a/great_expectations/core/config_peer.py
+++ b/great_expectations/core/config_peer.py
@@ -24,8 +24,8 @@ class ConfigPeer(ABC):
     """
     A ConfigPeer is an object, whose subclasses can be instantiated using instantiate_class_from_config() (located in
     great_expectations/util.py).  Its immediate descendant subclass must use a subclass of BaseYamlConfig as an argument
-    to its constructor, and the subsequent descentants must use only primitive types as their constructor arguments,
-    whereever keys correspond to the keys of the "BaseYamlConfig" configuration object counterpart. The name ConfigPeer
+    to its constructor, and the subsequent descendants must use only primitive types as their constructor arguments,
+    wherever keys correspond to the keys of the "BaseYamlConfig" configuration object counterpart. The name ConfigPeer
     means: Every immediate descendant subclass must have Marshmallow Schema validated configuration class as its peer.
 
     # TODO: <Alex>2/11/2022</Alex>
diff --git a/great_expectations/expectations/metrics/column_aggregate_metrics/column_median.py b/great_expectations/expectations/metrics/column_aggregate_metrics/column_median.py
--- a/great_expectations/expectations/metrics/column_aggregate_metrics/column_median.py
+++ b/great_expectations/expectations/metrics/column_aggregate_metrics/column_median.py
@@ -1,6 +1,7 @@
 from typing import Any, Dict, Optional
 
 import numpy as np
+import pandas as pd
 
 from great_expectations.core import ExpectationConfiguration
 from great_expectations.execution_engine import (
@@ -27,12 +28,9 @@ class ColumnMedian(ColumnAggregateMetricProvider):
     @column_aggregate_value(engine=PandasExecutionEngine)
     def _pandas(cls, column, **kwargs):
         """Pandas Median Implementation"""
-        metrics: Dict[str, Any] = kwargs.get("metrics", {})
-        nonnull_count = metrics.get("column_values.nonnull.count")
-        if not nonnull_count:
-            return 0.0
-
-        return column.median()
+        column_null_elements_cond: pd.Series = column.isnull()
+        column_nonnull_elements: pd.Series = column[~column_null_elements_cond]
+        return column_nonnull_elements.median()
 
     @metric_value(engine=SqlAlchemyExecutionEngine, metric_fn_type="value")
     def _sqlalchemy(
@@ -53,12 +51,10 @@ def _sqlalchemy(
         column_name = accessor_domain_kwargs["column"]
         column = sa.column(column_name)
         sqlalchemy_engine = execution_engine.engine
-
         """SqlAlchemy Median Implementation"""
         nonnull_count = metrics.get("column_values.nonnull.count")
         if not nonnull_count:
             return None
-
         element_values = sqlalchemy_engine.execute(
             sa.select([column])
             .order_by(column)
@@ -113,10 +109,6 @@ def _spark(
         # in the degenerate case when n_values = 0
 
         """Spark Median Implementation"""
-        nonnull_count = metrics.get("column_values.nonnull.count")
-        if not nonnull_count:
-            return None
-
         table_row_count = metrics.get("table.row_count")
         result = df.approxQuantile(
             column, [0.5, 0.5 + (1 / (2 + (2 * table_row_count)))], 0
@@ -144,9 +136,10 @@ def _get_evaluation_dependencies(
             runtime_configuration=runtime_configuration,
         )
 
-        dependencies["column_values.nonnull.count"] = MetricConfiguration(
-            metric_name="column_values.nonnull.count",
-            metric_domain_kwargs=metric.metric_domain_kwargs,
-        )
+        if isinstance(execution_engine, SqlAlchemyExecutionEngine):
+            dependencies["column_values.nonnull.count"] = MetricConfiguration(
+                metric_name="column_values.nonnull.count",
+                metric_domain_kwargs=metric.metric_domain_kwargs,
+            )
 
         return dependencies
diff --git a/great_expectations/rule_based_profiler/rule_based_profiler.py b/great_expectations/rule_based_profiler/rule_based_profiler.py
--- a/great_expectations/rule_based_profiler/rule_based_profiler.py
+++ b/great_expectations/rule_based_profiler/rule_based_profiler.py
@@ -896,6 +896,9 @@ def _get_effective_domain_builder_property_value(
         dest_property_value: Optional[Any] = None,
         source_property_value: Optional[Any] = None,
     ) -> Optional[Any]:
+        if source_property_value is None:
+            return dest_property_value
+
         if dest_property_value is None:
             return source_property_value
 


Test patch: