duckdb_engine icon indicating copy to clipboard operation
duckdb_engine copied to clipboard

fix bug of get_view_names

Open alitrack opened this issue 3 years ago • 1 comments

  • fix bug
AttributeError: 'Connection' object has no attribute 'exec_driver_sql'
  • add schema support.

alitrack avatar Aug 26 '22 14:08 alitrack

🤖 I detect that the PR title and the commit message differ and there's only one commit. To use the PR title for the commit history, you can use Github's automerge feature with squashing, or use automerge label. Good luck human!

-- conventional-commit-lint bot https://conventionalcommits.org/

Codecov Report

Merging #393 (10b8153) into master (53c3961) will decrease coverage by 0.34%. The diff coverage is 75.00%.

@@            Coverage Diff             @@
##           master     #393      +/-   ##
==========================================
- Coverage   93.46%   93.11%   -0.35%     
==========================================
  Files           8        8              
  Lines         459      465       +6     
==========================================
+ Hits          429      433       +4     
- Misses         30       32       +2     
Impacted Files Coverage Δ
duckdb_engine/__init__.py 90.57% <75.00%> (-1.09%) :arrow_down:

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov[bot] avatar Sep 07 '22 06:09 codecov[bot]

just notice, Superset does not support sqlalchemy 1.4 and newer, so does not support exec_driver_sql

so for new version sqlalchemy,

s = f"SELECT table_name FROM information_schema.tables WHERE table_type='VIEW' and table_schema=%s "
schema = schema if schema is not None else "main"
rs = connection.exec_driver_sql(s % schema)

and for old version, should

s = f"SELECT table_name FROM information_schema.tables WHERE table_type='VIEW' and table_schema=? "
schema = schema if schema is not None else "main"
rs = connection.execute(s ,schema)
``

or view will not show.

alitrack avatar Sep 07 '22 08:09 alitrack

Which old versions of sqlalchemy are you trying to support?

Mause avatar Sep 07 '22 10:09 Mause

It looks like the current superset version only supports >=1.4

https://github.com/apache/superset/blob/master/setup.py#L118

Mause avatar Sep 07 '22 10:09 Mause

the last release version apache superset 2.0 still needs <1.4 and need another parameter: schema image

alitrack avatar Sep 07 '22 12:09 alitrack

I've merged most of these changes in another pr, #404 so thanks for those. The remaining changes don't seem to be required and in fact introduce a potential security issue

The fixes will be released shortly

Mause avatar Sep 08 '22 04:09 Mause