From 49e81b097e2844223ff465aad79e8f5eb9367b74 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Thu, 7 Feb 2019 13:44:33 +0100 Subject: [PATCH 1/4] Allow passing schema as parameter in SqlAlchemyDataContext --- great_expectations/data_context/sqlalchemy_context.py | 4 ++-- tests/test_data_contexts/test_data_contexts.py | 8 +++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/great_expectations/data_context/sqlalchemy_context.py b/great_expectations/data_context/sqlalchemy_context.py index 0d0276b075b7..91e41a561616 100644 --- a/great_expectations/data_context/sqlalchemy_context.py +++ b/great_expectations/data_context/sqlalchemy_context.py @@ -24,5 +24,5 @@ def list_datasets(self): tables = [str(table) for table in self.meta.sorted_tables] return tables - def get_dataset(self, dataset_name, custom_sql=None): - return SqlAlchemyDataset(table_name=dataset_name, engine=self.engine, custom_sql=custom_sql) + def get_dataset(self, dataset_name, custom_sql=None, schema=None): + return SqlAlchemyDataset(table_name=dataset_name, engine=self.engine, custom_sql=custom_sql, schema=schema) diff --git a/tests/test_data_contexts/test_data_contexts.py b/tests/test_data_contexts/test_data_contexts.py index 0be70fb86e9b..8d763f4cf3b0 100644 --- a/tests/test_data_contexts/test_data_contexts.py +++ b/tests/test_data_contexts/test_data_contexts.py @@ -17,7 +17,7 @@ def test_db_connection_string(tmpdir_factory): path = tmpdir_factory.mktemp("db_context").join("test.db") engine = sa.create_engine('sqlite:///' + str(path)) df1.to_sql('table_1', con=engine, index=True) - df2.to_sql('table_2', con=engine, index=True) + df2.to_sql('table_2', con=engine, index=True, schema='main') # Return a connection string to this newly-created db return 'sqlite:///' + str(path) @@ -45,8 +45,10 @@ def test_sqlalchemy_data_context(test_db_connection_string): 'SqlAlchemy', test_db_connection_string, echo=False) assert context.list_datasets() == ['table_1', 'table_2'] - dataset = context.get_dataset('table_1') - assert isinstance(dataset, SqlAlchemyDataset) + dataset1 = context.get_dataset('table_1') + dataset2 = context.get_dataset('table_2', schema='main') + assert isinstance(dataset1, SqlAlchemyDataset) + assert isinstance(dataset2, SqlAlchemyDataset) def test_pandas_data_context(test_folder_connection_path): From 2c8a220885f49990395a3d2761b86d8220adc7d6 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Thu, 7 Feb 2019 13:56:32 +0100 Subject: [PATCH 2/4] Renamed get_data_set to get_dataset in DataContext base class to match the method name in subclasses --- great_expectations/data_context/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/great_expectations/data_context/base.py b/great_expectations/data_context/base.py index 30ad372fd546..9dce04b3aa03 100644 --- a/great_expectations/data_context/base.py +++ b/great_expectations/data_context/base.py @@ -14,5 +14,5 @@ def connect(self, options): def list_datasets(self): return NotImplementedError - def get_data_set(self, dataset_name): + def get_dataset(self, dataset_name): return NotImplementedError From 20756284b9261a07e63d2c7a82d7be39e50ac000 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Thu, 7 Feb 2019 16:47:00 +0100 Subject: [PATCH 3/4] Changed requirements for pytest_cov to pytest_cov >= 2.6 --- requirements-dev.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index b86cdc2e6945..7c934714aa84 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -11,5 +11,5 @@ pyarrow==0.11.0 sphinxcontrib-napoleon>=0.6.1 pypandoc>=1.4 pytest>=3.2.5 -pytest-cov>=2.5 +pytest-cov>=2.6 coveralls>=1.3 From fb170c2714d6aceaeea1c97720b1b733558f1821 Mon Sep 17 00:00:00 2001 From: Rahul Jain Date: Thu, 7 Feb 2019 16:52:11 +0100 Subject: [PATCH 4/4] Changed requirements for pytest_cov to pytest_cov >=2.6.1 to make the build pass --- requirements-dev.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements-dev.txt b/requirements-dev.txt index 7c934714aa84..b91ca3b9d059 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -10,6 +10,6 @@ xlrd>=1.1.0 pyarrow==0.11.0 sphinxcontrib-napoleon>=0.6.1 pypandoc>=1.4 -pytest>=3.2.5 -pytest-cov>=2.6 +pytest>=4.1.1 +pytest-cov>=2.6.1 coveralls>=1.3