Giter Club home page Giter Club logo

Comments (10)

dstandish avatar dstandish commented on July 3, 2024 3

Redshift seems to have a view that includes both internal and external tables: SVV_COLUMNS

perhaps this can be used instead?

from sqlalchemy-redshift.

graingert avatar graingert commented on July 3, 2024

wow

from sqlalchemy-redshift.

graingert avatar graingert commented on July 3, 2024

@c-nichols urgh that's probably going to need some changes to https://github.com/sqlalchemy-redshift/bigcrunch

Eg add the appropriate IAM roles to the redshift cluster.

from sqlalchemy-redshift.

briandailey avatar briandailey commented on July 3, 2024

Adding some notes based on digging around...

Both views and tables are normally defined in pg_table_def (a catalog table) and this is what is currently used in _get_all_column_info.

External table information isn't in pg catalog tables. Views that include external tables aren't, either, because they are required to use WITH NO SCHEMA BINDING. In fact, describing these views in the shell (with /d) doesn't even show anything useful.

Metadata about tables can be found in svv_external_tables:

# \d svv_external_tables       
  View "pg_catalog.svv_external_tables"  
      Column       |  Type   | Modifiers 
-------------------+---------+-----------
 schemaname        | text    |           
 tablename         | text    |           
 location          | text    |           
 input_format      | text    |           
 output_format     | text    |           
 serialization_lib | text    |           
 serde_parameters  | text    |           
 compressed        | integer |           
 parameters        | text    |           

Metadata for views that include tables can be found in pg_get_late_binding_view_cols(). One example for querying this from the docs:

select * from pg_get_late_binding_view_cols() cols(view_schema name, view_name name, col_name name, col_type varchar, col_num int);

I'm still digging into this but what I need, ideally, is to be able to use Introspector.get_columns to return column meta data from an external table.

from sqlalchemy-redshift.

everglory99 avatar everglory99 commented on July 3, 2024

Any update on this issue/feature?

from sqlalchemy-redshift.

jklukas avatar jklukas commented on July 3, 2024

The maintainers of this project aren't actively working on any new features. A PR for this would be welcome and I'd be happy to review, but neither I nor @graingert have time to devote to adding this support ourselves.

from sqlalchemy-redshift.

briandailey avatar briandailey commented on July 3, 2024

Support for late binding views was added in #159, hooray!

However, support for external tables looks a bit more difficult. At first I thought we could UNION in information from svv_external_columns much like @e01n0 did for late binding views from pg_get_late_binding_view_cols, but it looks like the internal representation of the data is slightly different.

For example, in pg_get_late_binding_view_cols an integer is represented as integer but in svv_external_columns it's shown as an int. Likewise, external character columns are indicated as varchar(36) instead of character varying(36). I don't know how well that will work with type inference.

from sqlalchemy-redshift.

jklukas avatar jklukas commented on July 3, 2024

For example, in pg_get_late_binding_view_cols an integer is represented as integer but in svv_external_columns it's shown as an int. Likewise, external character columns are indicated as varchar(36) instead of character varying(36). I don't know how well that will work with type inference.

As far as I'm aware, int and integer are just aliases for one another and same for varchar and character varying, so this may not be a problem? I'd encourage you to give UNIONing a try and see what happens.

from sqlalchemy-redshift.

robert-yxin05 avatar robert-yxin05 commented on July 3, 2024

Any updates on this feature? Thanks

from sqlalchemy-redshift.

Brooke-white avatar Brooke-white commented on July 3, 2024

partially supported in #263

from sqlalchemy-redshift.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.