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

rfc: Infer Schema #8645

Closed
wants to merge 4 commits into from
Closed

rfc: Infer Schema #8645

wants to merge 4 commits into from

Conversation

Xuanwo
Copy link
Member

@Xuanwo Xuanwo commented Nov 5, 2022

Signed-off-by: Xuanwo github@xuanwo.io

I hereby agree to the terms of the CLA available at: https://databend.rs/dev/policies/cla/

Summary

RFC: Infer Schema

preview of RFC: https://databend-git-fork-xuanwo-inferschema-databend.vercel.app/doc/contributing/rfcs/infer-schema

Signed-off-by: Xuanwo <github@xuanwo.io>
@vercel
Copy link

vercel bot commented Nov 5, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
databend ✅ Ready (Inspect) Visit Preview Nov 5, 2022 at 5:25AM (UTC)

@Xuanwo Xuanwo changed the title RFC: Infer Schema rfc: Infer Schema Nov 5, 2022
@mergify mergify bot added the pr-rfc label Nov 5, 2022
Signed-off-by: Xuanwo <github@xuanwo.io>
Signed-off-by: Xuanwo <github@xuanwo.io>
Signed-off-by: Xuanwo <github@xuanwo.io>
+-------------+---------+----------+
```

`CREATE TABLE` will support `CREATE TABLE <table> BY ( <Query> )` to accept the output from `INFER`, so users can create a table with `INFRE` directly.
Copy link
Member

Choose a reason for hiding this comment

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

we already support create table as


MySQL [(none)]> drop table a;
Query OK, 0 rows affected (0.004 sec)

MySQL [(none)]> create table a as select 3 as a, '3' as b;
Query OK, 0 rows affected (0.006 sec)

MySQL [(none)]> desc a;
+-------+------------------+------+---------+-------+
| Field | Type             | Null | Default | Extra |
+-------+------------------+------+---------+-------+
| a     | TINYINT UNSIGNED | NO   | 0       |       |
| b     | VARCHAR          | NO   |         |       |
+-------+------------------+------+---------+-------+
2 rows in set (0.003 sec)

Copy link
Member Author

Choose a reason for hiding this comment

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

#8645 (comment)

I think create table as is different too.

```sql
CREATE TABLE test BY (
SELECT UPPER(COLUMN_NAME), TYPE, TRUE from (
INFER 's3://mybucket/data.csv' FILE_FORMAT = ( TYPE = CSV )
Copy link
Member

Choose a reason for hiding this comment

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

looks like it's a table function like select * from infer($location, $file_format)

Copy link
Member Author

Choose a reason for hiding this comment

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

infer is much more complex that (location, file_format).

We need to accept stage/location like in COPY, file format options and so so. I feel it's hard to implement as a function with named args.

Copy link
Member

Choose a reason for hiding this comment

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

I think it's more like a table function.

Copy link
Member Author

Choose a reason for hiding this comment

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

Is there an existing example about table function in databend?

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

I will take this a look.

pub struct TableFunctionFactory {
creators: TableFunctionCreators,
}
impl TableFunctionFactory {

@Xuanwo Xuanwo closed this Jan 13, 2023
@Xuanwo Xuanwo deleted the infer_schema branch February 23, 2023 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants