Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convenience function to stand in for .inspect? #393

Open
pskrbasu opened this issue Dec 13, 2023 · 0 comments
Open

convenience function to stand in for .inspect? #393

pskrbasu opened this issue Dec 13, 2023 · 0 comments
Labels
standalone Issues related to steampipe anywhere standalone FDW

Comments

@pskrbasu
Copy link
Contributor

Could do this in steampipe_postgres_fdw_github--1.0.sql

drop function if exists steampipe_fdw_schema
create function steampipe_fdw_schema(schema text, table_name text) returns table (
  column_name_and_type text
  ) as $$
  select distinct
    column_name || ': ' || data_type as column_name_and_type
  from 
    information_schema.columns 
  where 
    table_name = table_name and
    table_schema = schema
  order by
    column_name_and_type
$$ language sql;

then:

select steampipe_fdw_schema('github', 'github_issue');

                  steampipe_fdw_schema
----------------------------------------------------------
 _ctx: jsonb
 action: text
 active_lock_reason: text
 actor: jsonb
 actor: text
 actor_location: jsonb
 actor_login: text
 additions: bigint
 affiliation: text
 alert_number: bigint
 allow_update_branch: boolean

Much nicer than looking up and using some version of the underlying query.

@pskrbasu pskrbasu added the standalone Issues related to steampipe anywhere standalone FDW label Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
standalone Issues related to steampipe anywhere standalone FDW
Projects
None yet
Development

No branches or pull requests

1 participant