Skip to content

Improved schema and catalog support from SQL #1877

Description

@matthewmturner

Is your feature request related to a problem or challenge? Please describe what you are trying to do.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
(This section helps Arrow developers understand the context and why for this feature, in addition to the what)

Right now there is limited schema and catalog support in sql. You have to be using language bindings and register the catalog / schema to the ExecutionContext before being able to select. I would like to be able to create schemas and catalogs from sql, without language bindings, so that its easier to manage ddl and do data analysis just using datafusion-cli.

DataFusion CLI v7.0.0
❯ CREATE TABLE sch.tbl AS VALUES (1,2,3);
0 rows in set. Query took 0.032 seconds.
❯ show tables;
+---------------+--------------------+------------+------------+
| table_catalog | table_schema       | table_name | table_type |
+---------------+--------------------+------------+------------+
| datafusion    | public             | sch.tbl    | BASE TABLE |
| datafusion    | information_schema | tables     | VIEW       |
| datafusion    | information_schema | columns    | VIEW       |
+---------------+--------------------+------------+------------+
3 rows in set. Query took 0.015 seconds.
❯ CREATE TABLE cat.sch.tbl AS VALUES (1,2,3);
0 rows in set. Query took 0.003 seconds.
❯ show tables;
+---------------+--------------------+-------------+------------+
| table_catalog | table_schema       | table_name  | table_type |
+---------------+--------------------+-------------+------------+
| datafusion    | public             | cat.sch.tbl | BASE TABLE |
| datafusion    | public             | sch.tbl     | BASE TABLE |
| datafusion    | information_schema | tables      | VIEW       |
| datafusion    | information_schema | columns     | VIEW       |
+---------------+--------------------+-------------+------------+
4 rows in set. Query took 0.006 seconds.
❯ CREATE SCHEMA abc;
NotImplemented("Unsupported SQL statement: CreateSchema { schema_name: ObjectName([Ident { value: \"abc\", quote_style: None }]), if_not_exists: false }")
CREATE CATALOG xyz;  🤔 Invalid statement: sql parser error: Expected an object type after CREATE, found: CATALOG

Describe the solution you'd like
A clear and concise description of what you want to happen.
Support the following sql statements:

  • CREATE CATALOG abc

  • CREATE SCHEMA xyz

  • Parse catalog and schema from CREATE TABLE abc.xyz.tbl instead of creating table `

  • Create Schema support

  • Create Catalog / Database support

  • /c command on datafusion cli to set active db / catalog

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.
Postgres reference here
https://www.postgresql.org/docs/9.3/sql-createschema.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions