@@ -56,13 +56,34 @@ X-Databend-SQL: insert into demo.people(name,age,city) values (?, ?, 'BJ') from
5656### Column mapping rules
5757
5858- ** 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+ ```
5964- **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+ ```
6070- **With column list and `VALUES`**:
6171 - Each target column gets the corresponding expression in `VALUES`.
6272 - 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+ ```
6378- **Columns not provided**:
6479 - Use column `DEFAULT` value if defined.
6580 - 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+ ```
6687
6788**cURL template:**
6889
@@ -102,6 +123,7 @@ Common CSV options:
102123- ` field_delimiter=',' ` : Use a custom delimiter (default is ` , ` ).
103124- ` quote='\"' ` : Quote character.
104125- ` record_delimiter='\n' ` : Line delimiter.
126+ - ` error_on_column_count_mismatch=false ` : Allow column count mismatch and ignore extra fields.
105127
106128Examples:
107129
0 commit comments