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

docs: add docs of create table like parquet #3065

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions docs/en/reference/sql/ddl/CREATE_TABLE_STATEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,20 @@ TableElement ::=
ColumnDef | ColumnIndex
```


The `TableElementList` needs to be defined in the `CREATE TABLE` statement. `TableElementList` consists of `ColumnDef` (column definition) and `ColumnIndex`. OpenMLDB requires at least one `ColumnDef` in the `TableElementList`.

Or use Hive tables to create new tables.
Or use Hive tables and Parquet files to create new tables.

```sql
CreateTableStmt ::=
'CREATE' 'TABLE' TableName LIKE 'HIVE' PATH
'CREATE' 'TABLE' TableName LIKE LikeType PATH

TableName ::=
Identifier ('.' Identifier)?

LikeType ::=
'HIVE' | 'PARQUET'

PATH ::=
string_literal
```
Expand Down Expand Up @@ -201,6 +203,15 @@ CREATE TABLE db1.t1 LIKE HIVE 'hive://hive_db.t1';

Notice that the table name should include database name at present.

**Example 6: Create a Table from the Parquet files**

```sql
CREATE TABLE db1.t1 LIKE PARQUET 'file://t1.parquet';
-- SUCCEED
```

Notice that the table name should include database name at present.

### ColumnIndex (optional)

```sql
Expand Down
29 changes: 27 additions & 2 deletions docs/zh/openmldb_sql/ddl/CREATE_TABLE_STATEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,23 @@ TableElement ::=

建表语句中需要定义`TableElementList`,即`TableElement`列表。`TableElement`分为列描述`ColumnDef`和列索引`ColumnIndex`。OpenMLDB要求`TableElement`列表中至少包含一个`ColumnDef`。

基于 `LIKE` 语法建表目前仅支持基于 Hive 的表格,详情查看文档 [Hive 数据源支持](../../integration/offline_data_sources/hive.md)。
或者基于 `LIKE` 语法建表,目前支持基于 Hive 和 Parquet 格式。

```sql
CreateTableStmt ::=
'CREATE' 'TABLE' TableName LIKE LikeType PATH

TableName ::=
Identifier ('.' Identifier)?

LikeType ::=
'HIVE' | 'PARQUET'

PATH ::=
string_literal
```

基于 Hive 建表的详情可查看文档 [Hive 数据源支持](../../integration/offline_data_sources/hive.md)。

### 列描述ColumnDef(必要)

Expand Down Expand Up @@ -173,7 +189,7 @@ desc t4;
--------------
```

**示例5:基于Hive表创建新表**
**示例5:基于 Hive 表创建新表**

首先[配置OpenMLDB支持Hive](../../integration/offline_data_sources/hive.md),然后使用以下语句。

Expand All @@ -184,6 +200,15 @@ CREATE TABLE db1.t1 LIKE HIVE 'hive://hive_db.t1';

注意目前创建的表名必须包括DB名。

**示例6:基于 Parquet 文件创建新表**

```sql
CREATE TABLE db1.t1 LIKE PARQUET 'file://t1.parquet';
-- SUCCEED
```

注意目前创建的表名必须包括DB名。
tobegit3hub marked this conversation as resolved.
Show resolved Hide resolved

### 列索引ColumnIndex(可选)

```sql
Expand Down