Skip to main content

Parquet command-line import

note

Import standard Parquet files through the command line: the host running the command reads the source files and mapping.json, and the DSN specifies the target. Misspelled column names are ignored, and exit code 0 does not mean that all data was written.

Entry point: run taosx run on the host holding the Parquet files. Execute SQL in the taosExplorer Data Browser or taos CLI.

This page reads standard Parquet data files. Error archive extraction, Parquet query export, and database backup and recovery are different operations. They are not interchangeable merely because they use the same file extension.

1. Prerequisites​

Follow Shared preparation and mapping to prepare sample.parquet and mapping.json. Check the ts, device, and temperature columns, millisecond time units, and source file records.

An authorized TDengine TSDB administrator must create independent objects in the taosExplorer Data Browser or taos CLI:

CREATE DATABASE parquet_demo PRECISION 'ms';
CREATE STABLE parquet_demo.temperatures (ts TIMESTAMP, temperature DOUBLE)
TAGS (device VARCHAR(32));

2. Run the import​

Run taosx run --help first to confirm the program. Replace target placeholders with an authorized identity and actual address. Use the actual port of the target taosAdapter:

Run in Linux Bash:

taosx run -f 'parquet:./sample.parquet?batch_size=1000&projection=ts,device,temperature' -p '@./mapping.json' -t 'taos+ws://<用户>:<密码>@<目标主机>:6041/parquet_demo'

For command argument direction and credential requirements, see Shared preparation.

2.1 Convert numeric strings to integers before writing​

Some Parquet files store electric meter current as strings, while the target requires integers. The independent practice file meters-string.parquet contains ts, tbname, current, voltage, phase, groupid, and location, with current="12". Prepare the other fields according to their target types. First have an administrator create an independent target:

CREATE DATABASE parquet_cast_demo PRECISION 'ms';
CREATE STABLE parquet_cast_demo.meters
(ts TIMESTAMP, current INT, voltage INT, phase FLOAT)
TAGS (groupid INT, location VARCHAR(24));

Save the complete configuration as meters.json:

{
"parse": {
"ts": { "as": "TIMESTAMP(ms)" },
"voltage": { "as": "INT" },
"phase": { "as": "FLOAT" },
"groupid": { "as": "INT" },
"location": { "as": "VARCHAR(24)" }
},
"mutate": [
{ "map": { "current_str": {"cast": "current", "as": "varchar(100)"} } },
{ "map": { "current": {"cast": "current_str", "as": "INT"} } }
],
"model": {
"name": "${tbname}",
"using": "meters",
"tags": ["groupid", "location"],
"columns": ["ts", "current", "voltage", "phase"]
}
}

Run the following command in the directory holding the files. Leave the source file unchanged and replace the target address and identity as appropriate:

taosx run \
-f 'parquet:./meters-string.parquet' \
-t 'taos+ws://USER:PASSWORD@target-host:6041/parquet_cast_demo' \
-p '@./meters.json'
warning

The first mutate step preserves source current as the string current_str; the second generates the integer current required by the target. This applies to integer strings such as 12. Verify 12.3, values containing units, and empty strings separately. Do not hide decimals or errors through integer conversion. tbname in the child table expression must have a source. If the source file lacks that field, first modify the model to use the actual business identifier.

In the target cluster's taosExplorer Data Browser or taos CLI, query the actual child tables of the target supertable and check the type and values of current:

DESCRIBE parquet_cast_demo.meters;
SELECT ts, current, voltage, phase, groupid, location
FROM parquet_cast_demo.meters ORDER BY ts LIMIT 20;

The results should retain the source times, devices, and numeric values, with current=12 as an integer. Displaying one row or command exit 0 does not replace this check. Also check rows with failed conversions against logs and the error handling policy.

3. Read options​

batch_size specifies rows read per batch, default 1000. It is not a total volume limit or the export-side Row Group size. projection can select root fields by case-sensitive column names. Numeric projection starts at 0 and indicates root field positions, not ORC type IDs or nested leaf column IDs. Use column names for the first run to avoid selecting incorrect columns after a schema change. Retain all columns needed for time, tags, and the model.

Misspelled names are ignored. Do not assume that columns were selected correctly merely because the command accepts the arguments. The column list only selects columns; it does not reorder them into the specified order. device.id is not automatically interpreted as a nested path either. Do not mix column names and numeric indices. First check the source schema and final model references.

For multiple files, list explicit paths separated by commas, for example parquet:./part-001.parquet,./part-002.parquet?batch_size=1000. Do not assume that quoted *.parquet expands automatically. If paths contain commas, first use unambiguous isolated paths. unprocessed_batches controls pending batch counts in the processing pipeline; when unset, the runtime pipeline uses 64. It is not a maximum file count or resumable progress. Retain the default for the first run and obtain a load baseline before tuning. For complete definitions, see Parquet read parameters, not the export parameter table.

4. Verification​

Run the following in the taosExplorer Data Browser or taos CLI, then follow the Shared verification method to check this run's device and window:

SELECT ts, temperature, device FROM parquet_demo.t_d001 ORDER BY ts LIMIT 20;
SELECT COUNT(*), MIN(ts), MAX(ts) FROM parquet_demo.temperatures;

5. Troubleshooting​

SymptomChecks
open parquet file errorCheck the host running taosx run, the current directory, every full path, and runtime identity permissions, not the browser download directory.
build parquet reader error or read parquet batchUse a standard reader to confirm the file is complete and has not been modified by another program. For archive containers, first follow Viewing and extracting error archives. Do not simply change the extension.
Missing column or incorrect target typeCompare the file schema, column name case, column projection, and mapping. Confirm the actual selected columns first, rather than checking only the extension.

For example, if the projection omits ts, the same run may report selected column ts not found in stream message, receive failed ack, and a completed read, while taosx run may also return 0. First restore the time column required by the mapping, then check actual target data. Do not let the final success log or exit code hide earlier errors. To view logs for that run in the terminal, add --no-log-to-files after the executable and before run, keeping the original source, mapping, and target arguments. This changes only this taosx run log output, not service task log settings. For limitations of other logging switches, see the CLI reference.

For other task, write, and runtime issues, see Troubleshooting by symptom.

6. Stopping, recovery, and limitations​

For interruptions and reruns, follow Rerun boundaries. Perform representative trial imports for complex or nested types; one simple file import does not establish compatibility for all types.