未验证 提交 a0b6bc00 编写于 作者: M Minglei Jin 提交者: GitHub

Merge pull request #13522 from taosdata/fix/TS-1586-V26

fix: inserting data from multi files is not supported
...@@ -111,13 +111,6 @@ INSERT INTO d1001 FILE '/tmp/csvfile.csv'; ...@@ -111,13 +111,6 @@ INSERT INTO d1001 FILE '/tmp/csvfile.csv';
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv';
``` ```
也可以在一条语句中向多个表以自动建表的方式插入记录。例如:
```
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv'
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
```
## 历史记录写入 ## 历史记录写入
可使用 IMPORT 或者 INSERT 命令,IMPORT 的语法,功能与 INSERT 完全一样。 可使用 IMPORT 或者 INSERT 命令,IMPORT 的语法,功能与 INSERT 完全一样。
......
...@@ -113,13 +113,6 @@ From version 2.1.5.0, tables can be automatically created using a super table as ...@@ -113,13 +113,6 @@ From version 2.1.5.0, tables can be automatically created using a super table as
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv'; INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile.csv';
``` ```
Multiple tables can be automatically created and inserted in a single SQL statement, like below:
```sql
INSERT INTO d21001 USING meters TAGS ('California.SanFrancisco', 2) FILE '/tmp/csvfile_21001.csv'
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
```
## More About Insert ## More About Insert
For SQL statement like `insert`, a stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior. For SQL statement like `insert`, a stream parsing strategy is applied. That means before an error is found and the execution is aborted, the part prior to the error point has already been executed. Below is an experiment to help understand the behavior.
......
...@@ -456,11 +456,6 @@ INSERT INTO ...@@ -456,11 +456,6 @@ INSERT INTO
```mysql ```mysql
INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile.csv'; INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile.csv';
``` ```
也可以在一条语句中向多个表以自动建表的方式插入记录。例如:
```mysql
INSERT INTO d21001 USING meters TAGS ('Beijing.Chaoyang', 2) FILE '/tmp/csvfile_21001.csv'
d21002 USING meters (groupId) TAGS (2) FILE '/tmp/csvfile_21002.csv';
```
**历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。 **历史记录写入**:可使用IMPORT或者INSERT命令,IMPORT的语法,功能与INSERT完全一样。
......
...@@ -257,6 +257,8 @@ typedef struct SInsertStatementParam { ...@@ -257,6 +257,8 @@ typedef struct SInsertStatementParam {
int32_t batchSize; // for parameter ('?') binding and batch processing int32_t batchSize; // for parameter ('?') binding and batch processing
int32_t numOfParams; int32_t numOfParams;
int32_t numOfFiles;
char msg[512]; // error message char msg[512]; // error message
uint32_t insertType; // insert data from [file|sql statement| bound statement] uint32_t insertType; // insert data from [file|sql statement| bound statement]
uint64_t objectId; // sql object id uint64_t objectId; // sql object id
......
...@@ -1501,6 +1501,11 @@ int tsParseInsertSql(SSqlObj *pSql) { ...@@ -1501,6 +1501,11 @@ int tsParseInsertSql(SSqlObj *pSql) {
tscInvalidOperationMsg(pInsertParam->msg, "invalid filename", sToken.z); tscInvalidOperationMsg(pInsertParam->msg, "invalid filename", sToken.z);
goto _clean; goto _clean;
} }
if (++pInsertParam->numOfFiles > 1) {
code = tscInvalidOperationMsg(pInsertParam->msg, "data from multi files is not supported", NULL);
goto _clean;
}
} else { } else {
if (bindedColumns == NULL) { if (bindedColumns == NULL) {
STableMeta *pTableMeta = pTableMetaInfo->pTableMeta; STableMeta *pTableMeta = pTableMetaInfo->pTableMeta;
......
...@@ -30,7 +30,7 @@ class TDTestCase: ...@@ -30,7 +30,7 @@ class TDTestCase:
self.ts = 1500074556514 self.ts = 1500074556514
self.csvfile = "/tmp/csvfile.csv" self.csvfile = "/tmp/csvfile.csv"
self.rows = 100000 self.rows = 10000
def writeCSV(self): def writeCSV(self):
with open(self.csvfile, 'w', encoding='utf-8', newline='') as csvFile: with open(self.csvfile, 'w', encoding='utf-8', newline='') as csvFile:
...@@ -64,6 +64,8 @@ class TDTestCase: ...@@ -64,6 +64,8 @@ class TDTestCase:
tdSql.query("select * from stb") tdSql.query("select * from stb")
tdSql.checkRows(self.rows * 2) tdSql.checkRows(self.rows * 2)
tdSql.error("insert into t4 using stb tags(2, 'test2') file '%s' t5 using stb(t1) tags(5) file '%s'" % (self.csvfile, self.csvfile))
def stop(self): def stop(self):
tdSql.close() tdSql.close()
tdLog.success("%s successfully executed" % __file__) tdLog.success("%s successfully executed" % __file__)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册