questdb / questdb-connect

SQLAchemy and Apache Superset extensions for QuestDB
Apache License 2.0
14 stars 6 forks source link

Connector to load tables with VARCHAR in Superset, whereas STRING works #20

Closed peterklingelhofer closed 1 month ago

peterklingelhofer commented 1 month ago

After upgrading QuestDB to 8.1.2 from 7.4.2 we're seeing issues with Superset 4.0.0 (with both questdb-connect==1.0.12 and questdb-connect==1.0.11):

2024-10-28T13:28:21.521208472Z ERROR:flask_appbuilder.api:'NoneType' object is not callable2024-10-28T13:28:21.521233355Z Traceback (most recent call last):2024-10-28T13:28:21.521237176Z   File "/usr/local/lib/python3.10/site-packages/flask_appbuilder/api/__init__.py", line 110, in wraps2024-10-28T13:28:21.521240585Z     return f(self, *args, **kwargs)2024-10-28T13:28:21.521242959Z   File "/app/superset/views/base_api.py", line 127, in wraps2024-10-28T13:28:21.521245388Z     raise ex2024-10-28T13:28:21.521248040Z   File "/app/superset/views/base_api.py", line 121, in wraps2024-10-28T13:28:21.521250464Z     duration, response = time_function(f, self, *args, **kwargs)2024-10-28T13:28:21.521253488Z   File "/app/superset/utils/core.py", line 1463, in time_function2024-10-28T13:28:21.521255789Z     response = func(*args, **kwargs)2024-10-28T13:28:21.521258381Z   File "/app/superset/utils/log.py", line 255, in wrapper2024-10-28T13:28:21.521261480Z     value = f(*args, **kwargs)2024-10-28T13:28:21.521263836Z   File "/app/superset/databases/api.py", line 742, in table_metadata2024-10-28T13:28:21.521266910Z     table_info = get_table_metadata(database, table_name, schema_name)2024-10-28T13:28:21.521269293Z   File "/app/superset/databases/utils.py", line 67, in get_table_metadata2024-10-28T13:28:21.521271766Z     columns = database.get_columns(table_name, schema_name)2024-10-28T13:28:21.521274575Z   File "/app/superset/models/core.py", line 839, in get_columns2024-10-28T13:28:21.521277035Z     return self.db_engine_spec.get_columns(2024-10-28T13:28:21.521279705Z   File "/app/superset/db_engine_specs/base.py", line 1340, in get_columns2024-10-28T13:28:21.521282333Z     cast(list[SQLAColumnType], inspector.get_columns(table_name, schema))2024-10-28T13:28:21.521284920Z   File "/usr/local/lib/python3.10/site-packages/questdb_connect/inspector.py", line 79, in get_columns2024-10-28T13:28:21.521287336Z     return self.format_table_columns(table_name, result_set)2024-10-28T13:28:21.521289845Z   File "/usr/local/lib/python3.10/site-packages/questdb_connect/inspector.py", line 87, in format_table_columns2024-10-28T13:28:21.521292427Z     return [2024-10-28T13:28:21.521294748Z   File "/usr/local/lib/python3.10/site-packages/questdb_connect/inspector.py", line 90, in <listcomp>2024-10-28T13:28:21.521297122Z     "type": resolve_type_from_name(row[1])(),2024-10-28T13:28:21.521299536Z TypeError: 'NoneType' object is not callable

I'm not sure the column/type selector SQL still works get_columns in inspector.py, would this SQL be more appropriate?

def get_columns(self, table_name, schema=None, **kw):
    result_set = self.bind.execute(
        sqlalchemy.text("""
            SELECT column_name, data_type
            FROM information_schema.columns
            WHERE table_name = :tn
        """),
        {"tn": table_name},
    )
    return self.format_table_columns(table_name, result_set)
peterklingelhofer commented 1 month ago

Update: Realized there was a discrepancy between schemas, schemas with VARCHAR columns were failing whereas schemas with STRING columns connected just fine. Probably something up with the VARCHAR types going on here.

Was able to fix with:

ALTER TABLE table_name ALTER COLUMN column_name TYPE STRING;
peterklingelhofer commented 1 month ago

Missed this, there's already an issue open for this: https://github.com/questdb/questdb-connect/issues/14

Closing this.