You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/en/guides/20-self-hosted/04-references/http-streaming-load.md
+70-1Lines changed: 70 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -53,6 +53,40 @@ Example (load two columns from a CSV file and set a constant):
53
53
X-Databend-SQL: insert into demo.people(name,age,city) values (?, ?, 'BJ') from @_databend_load file_format=(type=csv skip_header=1)
54
54
```
55
55
56
+
### Column mapping rules
57
+
58
+
-**No column list, no `VALUES`**: file fields map to table columns by table definition order.
59
+
- CSV header: `id,name,age`
60
+
- SQL:
61
+
```text
62
+
X-Databend-SQL: insert into demo.people from @_databend_load file_format=(type=csv skip_header=1)
63
+
```
64
+
- **With column list, no `VALUES`**: file fields map to the listed columns in order.
65
+
- CSV header: `id,name`
66
+
- SQL:
67
+
```text
68
+
X-Databend-SQL: insert into demo.people(id,name) from @_databend_load file_format=(type=csv skip_header=1)
69
+
```
70
+
- **With column list and `VALUES`**:
71
+
- Each target column gets the corresponding expression in `VALUES`.
72
+
- Each `?` consumes one field from the uploaded file, in order.
73
+
- CSV header: `name,age`
74
+
- SQL:
75
+
```text
76
+
X-Databend-SQL: insert into demo.people(name,age,city) values (?, ?, 'BJ') from @_databend_load file_format=(type=csv skip_header=1)
77
+
```
78
+
- **Columns not provided**:
79
+
- Use column `DEFAULT` value if defined.
80
+
- Otherwise insert `NULL` (and fail if the column is `NOT NULL`).
81
+
- **Read only part of a CSV (ignore extra fields)**:
82
+
- By default, Databend errors if the file has more fields than the target column list.
83
+
- To ignore extra fields, set `error_on_column_count_mismatch=false`:
84
+
```text
85
+
X-Databend-SQL: insert into demo.people(id,name) from @_databend_load file_format=(type=csv skip_header=1 error_on_column_count_mismatch=false)
86
+
```
87
+
- This only helps when you want the **first N fields**. Streaming load maps CSV fields by position and does not support selecting non-adjacent fields (for example, `id,name,age` → insert only `id` and `age`).
88
+
- Workaround: preprocess the CSV to keep only the needed columns, or load via stage and project columns (for example, `SELECT $1, $3 FROM @stage/file.csv`).
89
+
56
90
**cURL template:**
57
91
58
92
```shell
@@ -91,6 +125,7 @@ Common CSV options:
91
125
-`field_delimiter=','`: Use a custom delimiter (default is `,`).
92
126
-`quote='\"'`: Quote character.
93
127
-`record_delimiter='\n'`: Line delimiter.
128
+
-`error_on_column_count_mismatch=false`: Allow column count mismatch and ignore extra fields.
0 commit comments