File import
This chapter describes importing file data into TDengine: CSV supports upload and directory monitoring, while ORC and Parquet use command-line import. The host that holds the files is the most common source of confusion: directory monitoring and command-line reads use paths on the taosX host, not the browser host.
| File | Entry point | Host that holds the files |
|---|---|---|
| CSV | Upload or directory monitoring in taosExplorer. | Upload selects files in the browser and transfers them to the server; the monitored directory belongs to the actual taosX host. |
| ORC command-line import | taosx run. | The host running taosx run; the process needs read permission. |
| Parquet command-line import | taosx run. | The host running taosx run, not the browser host. |
Keep copies of the source files before importing. Record the file inventory, sizes, row counts, and model. After importing, check target objects, times, values, and tags. Batch size controls read/processing batches, not the maximum number of rows imported. Multiple files may be read in parallel; do not treat their list order as a global time order across files.
Error archives may need to be extracted into standard Parquet before general-purpose tools can read them. Viewing and extracting archives is not the database import or recovery procedure in this section. See Logs and performance. Backup files also cannot be imported as CSV/ORC/Parquet simply by changing their extensions.
1. Shared preparation for ORC and Parquet
On the host where taosX is installed and taosx run will execute, prepare a small file that has finished writing and mapping.json. The runtime identity must be able to read both and access the target taosAdapter. Do not modify input during import or read .part files that are still being generated. Use a reader for the corresponding format to record the schema, row count, time range, representative values, and nulls.
The temperature examples on both pages use millisecond time ts, device string device, and numeric temperature, with temperatures as the target supertable. First create an independent target database as described on the selected format page. Then save the following configuration as mapping.json in the working directory where taosx run will execute, alongside sample.orc or sample.parquet. If source columns or units differ, change the mapping first. Do not overwrite business objects with the same names.
{
"parse": {
"ts": {"as": "timestamp(ms)"},
"device": {"as": "varchar(32)"},
"temperature": {"as": "double"}
},
"model": {
"name": "t_{device}",
"using": "temperatures",
"tags": ["device"],
"columns": ["ts", "temperature"]
}
}
In the command, -f specifies the source DSN, -p '@./mapping.json' reads the parsing and mapping configuration, and -t specifies the target DSN. +ws connects to the target taosAdapter; the default port is 6041, which must be replaced according to the actual deployment. Run taosx run --help first to check the program. Encode special characters in credentials correctly. Protect actual commands and terminal history as sensitive information; do not put real passwords in tickets or shared scripts.
2. Query verification and reruns
Use the queries on the selected format page to check the actual child table, then calculate COUNT(*), MIN(ts), and MAX(ts) for the supertable. Use the same device and time window as the source file to compare unique record counts, times, values, types, nulls, and tags. If the target already contains data, restrict checks to this run's scope rather than comparing the entire table count with this run's input. If multiple files contain the same primary keys, do not simply add their row counts to determine the expected target count.
Neither a completed read nor exit code 0 replaces target queries. To interrupt a run, press Ctrl+C in the terminal running taosx run, and retain the original files, mapping, logs, and verified windows. A service task does not automatically take over a standalone command. Rerunning may reread files and does not guarantee row-level resume. First verify the primary-key overwrite behavior of reruns in an isolated target. Multiple files do not guarantee global order; perform separate representative trial imports for nested and special types.