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

Allow to use arbitrary queries (e.g. DESCRIBE) in a subquery #8854

Open
ramazanpolat opened this issue Jan 27, 2020 · 3 comments
Open

Allow to use arbitrary queries (e.g. DESCRIBE) in a subquery #8854

ramazanpolat opened this issue Jan 27, 2020 · 3 comments
Labels
feature st-accepted The issue is in our backlog, ready to take

Comments

@ramazanpolat
Copy link
Contributor

Use case
DESCRIBE output is something like this:

DESCRIBE TABLE ABC

┌─name────────┬─type──┬─default_type─┬─default_expression─┬─comment─┬─codec_expression─┬─ttl_expression─┐
│ ID          │ Int32 │              │                    │         │                  │                │
│ BORYIL      │ Int32 │              │                    │         │                  │                │
│ BORDONEM    │ Int32 │              │                    │         │                  │                │
│ BORYILDONEM │ Int32 │              │                    │         │                  │                │
└─────────────┴───────┴──────────────┴────────────────────┴─────────┴──────────────────┴────────────────┘

Unfortunately we cannot use this result in SQL since the output is not a table, althought it looks exactly like a table.

Therefore something like SELECT name FROM (DESCRIBE TABLE ABC) where type='Int32' is not possible.

Proposed solution
Make a table function called describe that can return DESCRIBE output as table. So users will be able to use this functions to get information about the a table and use it in SQL statements.

Somthing like these will be possible:

SELECT name FROM describe(ABC) where type='Int32

SELECT count() FROM describe(jdbc('datasource://abc', 'schema', 'table'))

@filimonov
Copy link
Contributor

filimonov commented Jan 27, 2020

SELECT name FROM (DESCRIBE TABLE ABC) where type='Int32'

didn't check that, but most probably allowing that will be simpler/more logical (comparing to introducing table function which is able to accept another tables / table functions).

@alexey-milovidov
Copy link
Member

We should allow to select from anything returning a table like DESCRIBE, SHOW TABLES, ...

@alexey-milovidov alexey-milovidov added the st-accepted The issue is in our backlog, ready to take label Jan 27, 2020
@amosbird
Copy link
Collaborator

An SQL table funtion then, though the result schema needs to be inferred.

@alexey-milovidov alexey-milovidov changed the title Make DESCRIBE a table function Allow to use arbitrary queries (e.g. DESCRIBE) in a subquery Mar 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature st-accepted The issue is in our backlog, ready to take
Projects
None yet
Development

No branches or pull requests

5 participants