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__
    self._create_temporary_table(
  File "/usr/local/lib/python3.10/site-packages/great_expectations/execution_engine/sqlalchemy_batch_data.py", line 295, in _create_temporary_table
    self._engine.execute(stmt)
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

Hi there,

I’m coming across a similar issue. After activating a python virtual environment the first time I execute my suite it works but the next times I’m getting this error:

MetricResolutionError: great_expectations.exceptions.exceptions.MetricResolutionError: ‘Engine’ object has no attribute ‘cursor’

Downgroading sqlalchemy doesn’t work for me.

Any hints?

@ardlema Could you provide some more information about this?

I.e. code that produces this error, stack trace of the error, what version of GX are you using and what operating system are you using?