aws / amazon-redshift-python-driver

Redshift Python Connector. It supports Python Database API Specification v2.0.
Apache License 2.0
202 stars 72 forks source link

column "table_schema" does not exist in svv_all_table #198

Closed yearnfar closed 6 months ago

yearnfar commented 7 months ago

pg_catalog.svv_all_tables does not have a table_schema field, but has a schema_name field.

def __is_valid_table(self: "Cursor", table: str) -> bool:
        split_table_name: typing.List[str] = table.split(".")

        if len(split_table_name) > 2:
            return False

        q: str = "select 1 from pg_catalog.svv_all_tables where table_name = ?"

        temp = self.paramstyle
        self.paramstyle = DbApiParamstyle.QMARK.value

        try:
            if len(split_table_name) == 2:
                q += " and table_schema = ?"
                self.execute(q, (split_table_name[1], split_table_name[0]))
            else:
                self.execute(q, (split_table_name[0],))
        except:
            raise
        finally:
            # reset paramstyle to it's original value
            self.paramstyle = temp

        result = self.fetchone()

        return result[0] == 1 if result is not None else False
Brooke-white commented 7 months ago

Hi @yearnfar , thank you for reporting this issue. The fix you propose is indeed the correct way to address the issue. As you've identified a correct fix, you're more than welcome to open a PR to adjust __is_valid_table(). If you're not interested in doing that I am more than happy to make the adjustment on my end. Just let me know how you'd like to proceed.

Brooke-white commented 7 months ago

Also, for tracking purposes this issue is with regards to v2.0.917 of redshift-connector

ujas-dubal commented 7 months ago

HI @Brooke-white , I have identified the issue and want to fix it. Please guide me the process of contribution.

mckadethomas commented 7 months ago

I am still seeing this issue as well. Is there a fix in progress?

Brooke-white commented 7 months ago

Hi folks, we have just merged @rmaxu's fix #199 for this issue. It will be included in our early December release of redshift-connector.

Brooke-white commented 6 months ago

Hi all, a fix is present in 2.0.918