Unable to Validate Expectation Suit with PostgresSQL (No execute Attribute for Engine Object)

Good Day GEX Community,

We have been testing Great Expectation for PostgresSQL for our organisation. We are successfully able to creating data source and expectation suit but upon performing the validation, we are facing the issue of not having execute attribute for the Engine object sqlalchemy_batch_data.py of the library. {code ends up at line 295 with error}

Validation code: validator = context.get_validator( batch_request=batch_request, expectation_suite_name="pgsql_exp_suite" )

The file is missing implementation for the GXSqlDialect.POSTGRESQL. which is generating the following error stack.

Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/great_expectations/core/usage_statistics/usage_statistics.py", line 307, in usage_statistics_wrapped_method
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/great_expectations/data_context/data_context/abstract_data_context.py", line 1924, in get_batch_list
    return datasource.get_batch_list_from_batch_request(batch_request=batch_request)
  File "/usr/local/lib/python3.10/site-packages/great_expectations/datasource/new_datasource.py", line 178, in get_batch_list_from_batch_request
    ) = data_connector.get_batch_data_and_metadata(  # type: ignore[call-arg]
  File "/usr/local/lib/python3.10/site-packages/great_expectations/datasource/data_connector/runtime_data_connector.py", line 204, in get_batch_data_and_metadata
    batch_data, batch_markers = self._execution_engine.get_batch_data_and_markers(
  File "/usr/local/lib/python3.10/site-packages/great_expectations/execution_engine/sqlalchemy_execution_engine.py", line 1241, in get_batch_data_and_markers
    batch_data = SqlAlchemyBatchData(
  File "/usr/local/lib/python3.10/site-packages/great_expectations/execution_engine/sqlalchemy_batch_data.py", line 161, in __init__
  File "/usr/local/lib/python3.10/site-packages/great_expectations/execution_engine/sqlalchemy_batch_data.py", line 295, in _create_temporary_table
AttributeError: 'Engine' object has no attribute 'execute'

We have been using exact code as specified in the PgSQL Documentation for GEX

A quick help to work around or suggested fix will be highly appreciated from the team or any user.

Kind Regards
Bilal Zaidi

Hi Bilal,

I ran into the same issue and this is happening because the latest versio.n of great_expectations has incompatibility issues with the latest sqlalchemy version(2.0). Please downgrade your sqlalchemy version using and try

pip uninstall sqlalchemy
pip install sqlalchemy==1.4.4