-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1143 from yangj1211/stage_datalink
add doc of stage and datalink
- Loading branch information
Showing
15 changed files
with
533 additions
and
479 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
291 changes: 0 additions & 291 deletions
291
docs/MatrixOne/Develop/import-data/bulk-load/1.1-load-s3.md
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# DATALINK 类型 | ||
|
||
`DATALINK` 类型用于存储指向文档 (例如 satge) 或文件链接的特殊数据类型。它的主要目的是在数据库中存储文档的链接地址,而不是存储文档本身。这种类型可以应用于各种场景,特别是在处理大规模文档管理时,提供对文档的快捷访问,而不需要将文档实际存储在数据库中。 | ||
|
||
使用 `DATALINK` 数据类型可以: | ||
|
||
- 节省存储空间:文档实际存储在外部存储中(例如对象存储系统),而数据库只保存链接。 | ||
- 方便的文档访问:通过存储链接,系统可以快速访问文档,无需额外的存储和处理。 | ||
- 提高数据操作效率:避免了直接在数据库中处理大文件,提高了数据操作的速度和效率。 | ||
|
||
## 插入 DATALINK 类型数据 | ||
|
||
**语法结构** | ||
|
||
``` | ||
INSERT INTO TABLE_NAME VALUES ('<file://<path>/<filename>>|<stage://<stage_name>/<path>/<file_name>>?<offset=xx>&<size=xxx>') | ||
``` | ||
|
||
**参数释义** | ||
|
||
| 参数 | 说明 | | ||
| ---- | ---- | | ||
| file | 指向本地文件系统文件位置。| | ||
| stage | 指向 stage 指向文件位置。| | ||
| offset | 非必填。偏移量,表明读的内容的起点。| | ||
| size | 非必填。指定读取内容的大小,单位为子节。| | ||
|
||
## 读取 DATALINK 类型数据 | ||
|
||
如果要读 `DATALINK` 指向文件链接的数据,可以使用 [load_file](../../Reference/Functions-and-Operators/Other/load_file.md) 函数。 | ||
|
||
## 示例 | ||
|
||
`/Users/admin/case` 下有文件 `t1.csv` | ||
|
||
```bash | ||
(base) admin@192 case % cat t1.csv | ||
this is a test message | ||
``` | ||
```sql | ||
drop table test01; | ||
create table test01 (col1 int, col2 datalink); | ||
create stage stage01 url='file:///Users/admin/case/'; | ||
insert into test01 values (1, 'file:///Users/admin/case/t1.csv'); | ||
insert into test01 values (2, 'file:///Users/admin/case/t1.csv?size=2'); | ||
insert into test01 values (3, 'file:///Users/admin/case/t1.csv?offset=4'); | ||
insert into test01 values (4, 'file:///Users/admin/case/t1.csv?offset=4&size=2'); | ||
insert into test01 values (5, 'stage://stage01/t1.csv'); | ||
insert into test01 values (6, 'stage://stage01/t1.csv?size=2'); | ||
insert into test01 values (7, 'stage://stage01/t1.csv?offset=4'); | ||
insert into test01 values (8, 'stage://stage01/t1.csv?offset=4&size=2'); | ||
|
||
mysql> select * from test01; | ||
+------+-------------------------------------------------+ | ||
| col1 | col2 | | ||
+------+-------------------------------------------------+ | ||
| 1 | file:///Users/admin/case/t1.csv | | ||
| 2 | file:///Users/admin/case/t1.csv?size=2 | | ||
| 3 | file:///Users/admin/case/t1.csv?offset=4 | | ||
| 4 | file:///Users/admin/case/t1.csv?offset=4&size=2 | | ||
| 5 | stage://stage01/t1.csv | | ||
| 6 | stage://stage01/t1.csv?size=2 | | ||
| 7 | stage://stage01/t1.csv?offset=4 | | ||
| 8 | stage://stage01/t1.csv?offset=4&size=2 | | ||
+------+-------------------------------------------------+ | ||
8 rows in set (0.01 sec) | ||
|
||
mysql> select col1, load_file(col2) from test01; | ||
+------+-------------------------+ | ||
| col1 | load_file(col2) | | ||
+------+-------------------------+ | ||
| 1 | this is a test message | ||
| | ||
| 2 | th | | ||
| 3 | is a test message | ||
| | ||
| 4 | i | | ||
| 5 | this is a test message | ||
| | ||
| 6 | th | | ||
| 7 | is a test message | ||
| | ||
| 8 | i | | ||
+------+-------------------------+ | ||
8 rows in set (0.01 sec) | ||
``` |
72 changes: 72 additions & 0 deletions
72
docs/MatrixOne/Reference/Functions-and-Operators/Other/load_file.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# **LOAD_FILE()** | ||
|
||
## **函数说明** | ||
|
||
`LOAD_FILE()` 函数用于读取 datalink 类型指向文件的内容。 | ||
|
||
## **函数语法** | ||
|
||
``` | ||
>LOAD_FILE(datalink_type_data) ; | ||
``` | ||
|
||
## **参数释义** | ||
|
||
| 参数 | 说明 | | ||
| ---- | ---- | | ||
| datalink_type_data | datalink 类型数据,可以使用[cast()](../../../Reference/Operators/operators/cast-functions-and-operators/cast/)函数进行转换| | ||
|
||
## 示例 | ||
|
||
`/Users/admin/case` 下有文件 `t1.csv` | ||
|
||
```bash | ||
(base) admin@192 case % cat t1.csv | ||
this is a test message | ||
``` | ||
```sql | ||
create table t1 (col1 int, col2 datalink); | ||
create stage stage1 url='file:///Users/admin/case/'; | ||
insert into t1 values (1, 'file:///Users/admin/case/t1.csv'); | ||
insert into t1 values (2, 'stage://stage1//t1.csv'); | ||
|
||
mysql> select * from t1; | ||
+------+---------------------------------+ | ||
| col1 | col2 | | ||
+------+---------------------------------+ | ||
| 1 | file:///Users/admin/case/t1.csv | | ||
| 2 | stage://stage1//t1.csv | | ||
+------+---------------------------------+ | ||
2 rows in set (0.00 sec) | ||
|
||
mysql> select col1, load_file(col2) from t1; | ||
+------+-------------------------+ | ||
| col1 | load_file(col2) | | ||
+------+-------------------------+ | ||
| 1 | this is a test message | ||
| | ||
| 2 | this is a test message | ||
| | ||
+------+-------------------------+ | ||
2 rows in set (0.01 sec) | ||
|
||
|
||
mysql> select load_file(cast('file:///Users/admin/case/t1.csv' as datalink)); | ||
+--------------------------------------------------------------+ | ||
| load_file(cast(file:///Users/admin/case/t1.csv as datalink)) | | ||
+--------------------------------------------------------------+ | ||
| this is a test message | ||
| | ||
+--------------------------------------------------------------+ | ||
1 row in set (0.00 sec) | ||
|
||
mysql> select load_file(cast('stage://stage1//t1.csv' as datalink)); | ||
+-----------------------------------------------------+ | ||
| load_file(cast(stage://stage1//t1.csv as datalink)) | | ||
+-----------------------------------------------------+ | ||
| this is a test message | ||
| | ||
+-----------------------------------------------------+ | ||
1 row in set (0.00 sec) | ||
``` |
49 changes: 49 additions & 0 deletions
49
docs/MatrixOne/Reference/Functions-and-Operators/Other/save_file.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# **SAVE_FILE()** | ||
|
||
## **函数说明** | ||
|
||
`SAVE_FILE()` 函数用于向 datalink 指向文件中写入内容,指行返回写入内容字节长度。 | ||
|
||
## **函数语法** | ||
|
||
``` | ||
>SAVE_FILE(datalink_type_data,content) ; | ||
``` | ||
|
||
## **参数释义** | ||
|
||
| 参数 | 说明 | | ||
| ---- | ---- | | ||
| datalink_type_data | datalink 类型数据,可以使用[cast()](../../../Reference/Operators/operators/cast-functions-and-operators/cast/)函数进行转换| | ||
| content | 需要写入 datalink 指向文件的内容| | ||
|
||
## 示例 | ||
|
||
``` | ||
drop stage if exists tab1; | ||
create stage stage01 url='file:///Users/admin/case/'; | ||
mysql> select save_file(cast('stage://stage01/test.csv' as datalink), 'this is a test message'); | ||
+-------------------------------------------------------------------------------+ | ||
| save_file(cast(stage://stage01/test.csv as datalink), this is a test message) | | ||
+-------------------------------------------------------------------------------+ | ||
| 22 | | ||
+-------------------------------------------------------------------------------+ | ||
1 row in set (0.00 sec) | ||
mysql> select save_file(cast('file:///Users/admin/case/test1.csv' as datalink), 'this is another test message'); | ||
+-----------------------------------------------------------------------------------------------+ | ||
| save_file(cast(file:///Users/admin/case/test1.csv as datalink), this is another test message) | | ||
+-----------------------------------------------------------------------------------------------+ | ||
| 28 | | ||
+-----------------------------------------------------------------------------------------------+ | ||
1 row in set (0.01 sec) | ||
``` | ||
|
||
```bash | ||
(base) admin@192 case % cat test.csv | ||
this is a test message | ||
|
||
(base) admin@192 case % cat test1.csv | ||
this is another test message | ||
``` |
Oops, something went wrong.