Problem connecting with Apache Superset


When trying to connect to CrateDB from Apache Superset on pq protocol I get an io.crate.exception.

superset             | superset.databases.commands.exceptions.DatabaseTestConnectionFailedError: [SupersetError(message="(psycopg2.errors.InternalError_) line 1:1: mismatched input 'ROLLBACK' expecting {'SELECT', 'DEALLOCATE', 'FETCH', 'END', 'WITH', 'CREATE', 'ALTER', 'KILL', 'CLOSE', 'BEGIN', 'START', 'COMMIT', 'ANALYZE', 'DISCARD', 'EXPLAIN', 'SHOW', 'OPTIMIZE', 'REFRESH', 'RESTORE', 'DROP', 'INSERT', 'VALUES', 'DELETE', 'UPDATE', 'SET', 'RESET', 'COPY', 'GRANT', 'DENY', 'REVOKE', 'DECLARE'}\nCONTEXT:  io.crate.exceptions.SQLExceptions.esToCrateException(\nio.crate.exceptions.SQLExceptions.prepareForClientTransmission(\nio.crate.protocols.postgres.Messages.sendErrorResponse(\nio.crate.protocols.postgres.PostgresWireProtocol.handleSimpleQuery(\nio.crate.protocols.postgres.PostgresWireProtocol$MessageHandler.dispatchMessage(\nio.crate.protocols.postgres.PostgresWireProtocol$MessageHandler.dispatchState(\nio.crate.protocols.postgres.PostgresWireProtocol$MessageHandler.channelRead0(\nio.crate.protocols.postgres.PostgresWireProtocol$MessageHandler.channelRead0(\\\\\nio.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(\nio.netty.handler.codec.ByteToMessageDecoder.channelRead(\\\\$HeadContext.channelRead(\\\n\n\n(Background on this error at:", error_type=<SupersetErrorType.GENERIC_DB_ENGINE_ERROR: 'GENERIC_DB_ENGINE_ERROR'>, level=<ErrorLevel.ERROR: 'error'>, extra={'engine_name': 'PostgreSQL', 'issue_codes': [{'code': 1002, 'message': 'Issue 1002 - The database returned an unexpected error.'}]})]

Has anyone encounter a similar case? I’m tying to figure it out if this is related with how CrateDB cluster is configured, or it’s caused by the Crate connector.

I’m running Apache Superset inside docker containers. I’m using the latest version of Crate connector and SQLAlchemy 1.4.32

RUN pip install sqlalchemy==1.4.32
RUN pip install crate

The same connection parameters work just fine from Grafana. Any help is appreciated.

Dear Alin,

thank you for writing in. Apache Superset 3.0 was released yesterday, and we did not validate it with CrateDB yet. Are you using it already?

In general, you should use the CrateDB SQLAlchemy dialect to connect from Apache Superset, which reflects in using such a database connection string in URI format:


We confirmed this connection URI style worked on Apache Superset 2.x.

With kind regards,

Hi Andreas,
thank you for the reply.

I’m using apache/superset:2.1.0

When trying to make the connection using SQLAlchemy dialect I’m getting a SSL connection Error

superset             | 2023-09-19 12:26:44,619:WARNING:urllib3.connectionpool:Retrying (Retry(total=8, connect=None, read=0, redirect=None, status=None)) after connection broken by 'SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1131)'))': /_sql?types=true

Hi Alin,

if you are connecting to a non TLS/SSL peer, you will probably need to omit the ssl=true parameter.

If you need to turn off certificate verification, in order to connect to a host using self-signed certificates, you may need to use the verify_ssl_cert connection option within custom connection arguments, like outlined at SQLAlchemy » Getting Started » TLS options.

Those custom connection arguments can be defined by navigating to the connection settings’ “Advanced Settings” dialog, choose “Other”, and set "connect_args" in “Engine Parameters”, similarly like described at Workaround for connecting CrateDB and Apache Superset with HTTPS.

With kind regards,

1 Like

Thank you Andreas, this should solve the connection using a self signed cert, after I’ll match the client hostname :smile:

1 Like