Skip to content

Commit

Permalink
docs: add docs of create table like parquet (#3065)
Browse files Browse the repository at this point in the history
* Add docs of create table like parquet

* Fix syntax of create table like

* Refine create table like syntax
  • Loading branch information
tobegit3hub authored Feb 17, 2023
1 parent 36ea791 commit bf7e6ab
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
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名。

### 列索引ColumnIndex(可选)

```sql
Expand Down

0 comments on commit bf7e6ab

Please sign in to comment.