[import] IMPORT INTO can replace declared temporal defaults with the import time
- Dominant language
- Go
- Stars
- 40.5k
- Forks
- 6.2k
- PR merge metrics
- PR metrics pending
Description
## Bug Report
### 1. Minimal reproduce step (Required)
**Environment**
TiDB 13282a8bd0; TiKV 730be34f; PD f7db4252; default strict mode and MDL ON; one TiDB and real TiKV; no injection
**Steps**
Create an empty table with id INT PRIMARY KEY and v DATE NOT NULL DEFAULT '2000-01-01'. Create a CSV containing lines 1 and 2 with no second field. Run IMPORT INTO from that file under default settings, then query id,v. Repeat with DATETIME and TIMESTAMP fixed defaults and with DATE NOT NULL without a default.
### 2. What did you expect to see? (Required)
A missing mapped field remains absent until schema admission. The fixed default is stored; a NOT NULL column without a default raises 1364 and leaves the table empty; a nullable column stores NULL.
### 3. What did you see instead? (Required)
All temporal imports report finished with two imported rows. Fixed defaults are replaced by the import date or timestamp. Even the no-default tables succeed. The corresponding NOT NULL INT control fails with 1364. ADMIN CHECK remains green because the invented temporal values are physically valid.
### 4. What is your TiDB version? (Required)
TiDB 13282a8bd0; TiKV 730be34f; PD f7db4252; default strict mode and MDL ON; one TiDB and real TiKV; no injection
Likely root cause and fix direction
**Likely root cause**
parserData2TableData treats time type plus NOT NULL as proof that a missing input field means current time. It appends types.CurrentTime and continues before clearing hasValue for the column, so getRow cannot apply the declared default, preserve NULL, or reject a missing required value.
**Fix direction**
Remove the temporal current-time special case from IMPORT INTO row mapping and carry field absence with hasValue=false to the existing schema-default and nullability owner. Add a DATE/DATETIME/TIMESTAMP matrix covering fixed default, current-time default, no default, and nullable columns.
Contributor guide
Research direction
Start at parserData2TableData and trace how missing fields and hasValue flow into getRow. Add the DATE, DATETIME, and TIMESTAMP matrix covering fixed defaults, current-time defaults, no defaults, and nullable columns, then verify missing values use schema defaults, NULL, or the expected 1364 error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, sql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 72/100