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

feat: Implement list_columns for datasources. #1720

Merged
merged 1 commit into from
Sep 7, 2023
Merged

Conversation

vrongmeal
Copy link
Contributor

Lists the columns information for datasources:

> CREATE EXTERNAL DATABASE "PgDb"
::: FROM postgres OPTIONS (
:::   host = 'pg.demo.glaredb.com',
:::   port = '5432',
:::   user = 'demo',
:::   password = 'demo',
:::   database = 'postgres',
::: );
Database created
>
> select * from list_columns("PgDb", public, nation);
┌─────────────┬───────────┬──────────┐
│ column_name │ data_type │ nullable │
│ ──          │ ──        │ ──       │
│ Utf8        │ Utf8      │ Boolean  │
╞═════════════╪═══════════╪══════════╡
│ n_nationkey │ Int32     │ true     │
│ n_name      │ Utf8      │ true     │
│ n_regionkey │ Int64     │ true     │
│ n_comment   │ Utf8      │ true     │
└─────────────┴───────────┴──────────┘

Syntax:

-- All the three arguments are identifiers so they can either be double
-- quoted or quoteless.
--
-- Prefer adding `"` (double quotation marks) on cloud.
--
select * from list_columns("<database>", "<schema>", "<table>");

Fixes #1540

@vrongmeal
Copy link
Contributor Author

I have opened a draft PR. Seems easy to implement, will do it for all other data sources and get it merged.

Copy link
Member

@scsmithr scsmithr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship!

Copy link
Contributor

@greyscaled greyscaled left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exciting times

Lists the columns information for datasources:

```
> CREATE EXTERNAL DATABASE "PgDb"
::: FROM postgres OPTIONS (
:::   host = 'pg.demo.glaredb.com',
:::   port = '5432',
:::   user = 'demo',
:::   password = 'demo',
:::   database = 'postgres',
::: );
Database created
>
> select * from list_columns("PgDb", public, nation);
┌─────────────┬───────────┬──────────┐
│ column_name │ data_type │ nullable │
│ ──          │ ──        │ ──       │
│ Utf8        │ Utf8      │ Boolean  │
╞═════════════╪═══════════╪══════════╡
│ n_nationkey │ Int32     │ true     │
│ n_name      │ Utf8      │ true     │
│ n_regionkey │ Int64     │ true     │
│ n_comment   │ Utf8      │ true     │
└─────────────┴───────────┴──────────┘
```

Syntax:

```sql
-- All the three arguments are identifiers so they can either be double
-- quoted or quoteless.
--
-- Prefer adding `"` (double quotation marks) on cloud.
--
select * from list_columns("<database>", "<schema>", "<table>");
```

Fixes #1540

Signed-off-by: Vaibhav <[email protected]>
@vrongmeal vrongmeal marked this pull request as ready for review September 7, 2023 06:00
@vrongmeal vrongmeal merged commit bb02791 into main Sep 7, 2023
2 checks passed
@vrongmeal vrongmeal deleted the vrongmeal/list-cols branch September 7, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

list_columns("<database>", "<schema>", "<table>")
3 participants