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/execution_engine/sqlalchemy_execution_engine.py b/great_expectations/execution_engine/sqlalchemy_execution_engine.py
--- a/great_expectations/execution_engine/sqlalchemy_execution_engine.py
+++ b/great_expectations/execution_engine/sqlalchemy_execution_engine.py
@@ -963,7 +963,7 @@ def _build_selectable_from_batch_spec(self, batch_spec) -> Union[Selectable, str
                         sa.table(table_name, schema=batch_spec.get("schema_name", None))
                     )
                     .where(split_clause)
-                ).one()[0]
+                ).scalar()
                 p: Optional[float] = batch_spec["sampling_kwargs"]["p"] or 1.0
                 sample_size: int = round(p * num_rows)
                 return (
diff --git a/great_expectations/expectations/metrics/map_metric_provider.py b/great_expectations/expectations/metrics/map_metric_provider.py
--- a/great_expectations/expectations/metrics/map_metric_provider.py
+++ b/great_expectations/expectations/metrics/map_metric_provider.py
@@ -2133,7 +2133,7 @@ def _sqlalchemy_column_pair_map_condition_filtered_row_count(
 
     return execution_engine.engine.execute(
         sa.select([sa.func.count()]).select_from(selectable)
-    ).one()[0]
+    ).scalar()
 
 
 def _sqlalchemy_multicolumn_map_condition_values(
@@ -2223,7 +2223,7 @@ def _sqlalchemy_multicolumn_map_condition_filtered_row_count(
 
     return execution_engine.engine.execute(
         sa.select([sa.func.count()]).select_from(selectable)
-    ).one()[0]
+    ).scalar()
 
 
 def _sqlalchemy_column_map_condition_value_counts(


Test patch:
diff --git a/tests/execution_engine/test_sqlalchemy_execution_engine.py b/tests/execution_engine/test_sqlalchemy_execution_engine.py
--- a/tests/execution_engine/test_sqlalchemy_execution_engine.py
+++ b/tests/execution_engine/test_sqlalchemy_execution_engine.py
@@ -766,7 +766,7 @@ def test_sample_using_random(sqlite_view_engine, test_df):
     batch_data = my_execution_engine.get_batch_data(batch_spec=batch_spec)
     num_rows = batch_data.execution_engine.engine.execute(
         sqlalchemy.select([sqlalchemy.func.count()]).select_from(batch_data.selectable)
-    ).one()[0]
+    ).scalar()
     assert num_rows == round(p * test_df_0.shape[0])
 
     rows_0: List[tuple] = batch_data.execution_engine.engine.execute(
@@ -776,7 +776,7 @@ def test_sample_using_random(sqlite_view_engine, test_df):
     batch_data = my_execution_engine.get_batch_data(batch_spec=batch_spec)
     num_rows = batch_data.execution_engine.engine.execute(
         sqlalchemy.select([sqlalchemy.func.count()]).select_from(batch_data.selectable)
-    ).one()[0]
+    ).scalar()
     assert num_rows == round(p * test_df_0.shape[0])
 
     rows_1: List[tuple] = batch_data.execution_engine.engine.execute(
@@ -803,7 +803,7 @@ def test_sample_using_random(sqlite_view_engine, test_df):
     batch_data = my_execution_engine.get_batch_data(batch_spec=batch_spec)
     num_rows = batch_data.execution_engine.engine.execute(
         sqlalchemy.select([sqlalchemy.func.count()]).select_from(batch_data.selectable)
-    ).one()[0]
+    ).scalar()
     assert num_rows == round(p * test_df_1.shape[0])
 
     rows_0 = batch_data.execution_engine.engine.execute(
@@ -813,7 +813,7 @@ def test_sample_using_random(sqlite_view_engine, test_df):
     batch_data = my_execution_engine.get_batch_data(batch_spec=batch_spec)
     num_rows = batch_data.execution_engine.engine.execute(
         sqlalchemy.select([sqlalchemy.func.count()]).select_from(batch_data.selectable)
-    ).one()[0]
+    ).scalar()
     assert num_rows == round(p * test_df_1.shape[0])
 
     rows_1 = batch_data.execution_engine.engine.execute(
diff --git a/tests/integration/docusaurus/connecting_to_your_data/how_to_introspect_and_partition_your_data/sql_database/yaml_example.py b/tests/integration/docusaurus/connecting_to_your_data/how_to_introspect_and_partition_your_data/sql_database/yaml_example.py
--- a/tests/integration/docusaurus/connecting_to_your_data/how_to_introspect_and_partition_your_data/sql_database/yaml_example.py
+++ b/tests/integration/docusaurus/connecting_to_your_data/how_to_introspect_and_partition_your_data/sql_database/yaml_example.py
@@ -170,7 +170,7 @@
 batch_data = batch_list[1].data  # 2-passenger sample of batch data
 num_rows = batch_data.execution_engine.engine.execute(
     sa.select([sa.func.count()]).select_from(batch_data.selectable)
-).one()[0]
+).scalar()
 assert num_rows < 200
 
 # NOTE: The following code is only for testing and can be ignored by users.