Target table modeling and field mapping
For target modeling, first determine supertables and child tables, map business times, values, and device attributes to data columns and tags, then check times and types. Incorrect table names or times may still allow writes but produce results with the wrong business meaning. A model preview does not replace verification of actual target data.
Where to operate: taosExplorer → Data Ingestion → Payload parsing → target supertable and mapping. Run preparation and verification SQL in the taosExplorer Data Browser or taos CLI.
Mapping determines the child table and time for each record and which fields become data columns or tags. Check both model previews and target data. This page does not replace dedicated modeling instructions for industrial point connectors.
1. Define the target schema
Have an authorized TDengine TSDB administrator create dedicated test objects in the taosExplorer Data Browser or taos CLI. If the database name exists, use a new name and update all queries. Do not overwrite existing business tables.
CREATE DATABASE taosx_model_demo PRECISION 'ms';
CREATE STABLE taosx_model_demo.temperatures
(ts TIMESTAMP, temperature DOUBLE) TAGS (device VARCHAR(32));
This example describes similar devices with one supertable and uses one child table per device. temperature is a time-varying value column; device is a tag distinguishing devices. Do not put values that differ in every message into child table names, or the child table count will grow continuously.
Before ingesting into existing tables, run DESCRIBE <库名>.<超级表名>; and record actual columns, types, and tags. Automatic table creation, column addition, or length extension are schema changes requiring management authorization first. Do not modify production tables merely to bypass write errors.
1.1 Create the target database and supertable in the task form
With database and table creation permissions, the taosExplorer graphical interface is another option. The following still uses taosx_model_demo; the Kafka exercise uses taosx_quickstart. Choose one name for the current exercise and do not create it twice:
- In Data Ingestion → Create New Task, click Create Database beside Target Database. Enter a dedicated database name and select millisecond (
ms) precision. Retention must cover the test messages' times; set other parameters to approved deployment requirements. Click Create, then select the database in the target database list. - Complete the source connection, enter the temperature sample in the next section, and run a JSON parsing preview. Configure the supertable only after parsing succeeds; related options may be disabled before then.
- Expand the Create Supertable menu to the right of Target Supertable and select Create Supertable. Use this interface for ordinary table schemas. Create Template is for Dynamic column names and wide-table mapping below.
- Enter name
temperatures. Under Columns, retain primary timestampts TIMESTAMPand addtemperature DOUBLE; under Tags, adddevice VARCHAR(32). If the dialog includes other initial columns, remove those outside this example. Do not add a composite primary key here. Check names, types, lengths, and whether each field is a column or tag, then click Create. - Select
temperaturesin the target supertable list and continue mapping in the next section. If a table with that name exists, first check its schema withDESCRIBE. Do not delete or overwrite existing objects.
Use either SQL or graphical preparation. If graphical creation fails, preserve the error and check permissions and object conflicts first.
2. Configure minimal mapping
Enter this sample and complete JSON parsing:
{"device":"d001","ts":1795132800000,"temperature":23.5}
Select target database taosx_model_demo and supertable temperatures, then configure and preview the following:
| Target | Configuration in this example | Expected result |
|---|---|---|
| Child table name | t_{device} | t_d001; later messages for the same device still enter this table. |
Primary timestamp ts | Input ts, interpreted in milliseconds | The instant corresponding to 2026-11-20T00:00:00Z. |
Data column temperature | Input temperature, type DOUBLE | Numeric 23.5. |
Tag device | Input device | String d001. |
Device names may contain whitespace or punctuation, be too long, or be empty. Test naming rules with real samples. Replacements may turn different original names into the same name. Rule out these conflicts before production use; automatic replacement does not guarantee one-to-one object mapping.
View table selection and mapping result examples
The image below uses a separate model from the temperature table above: target supertable test_kafka_001, inputs id=2 and message_0="hello". The child table is generated from id, data column message selects source message_0, and tag id selects source id. It illustrates table selection, column rules, and preview buttons. The temperature exercise does not require creating this extra table.

The time column in this image uses generator with now, representing processing time rather than source business time. Do not use it unchanged for historical ingestion. Expect child table t_2, message=hello, and id=2 in the preview. The date in the image below is from a historical sample; check the current sample's time during actual operation.
Back in the actual task, restore the device, ts, and temperature sample and mapping above, and confirm that time selects source ts. A correct preview proves only this sample's mapping result. After submission and sending source data, still query the target.
2.1 Choose mapping rules
After selecting a target supertable, check the rule for each column and tag. Automatic matching of identically named fields is only initial configuration, not a substitute for checking types, units, time sources, and nulls.
| Rule | When to use | Input and expectation |
|---|---|---|
mapping | Direct selection of a parsed source field | Maps temperature to the target column of the same name; check the target type separately. |
value | A business-approved fixed string or number | Fixed tag site=lab, or agreed numeric constants 5 and 5.5. Check preview types: numeric 5 is not string "5". Do not hide missing device IDs with constants. |
generator | Processing time is explicitly required instead of source business time | Select now for current time, not to repair missing times in historical messages. |
join | Join several source fields with a specified separator | Joining zoneA and line1 with - produces zoneA-line1. |
format | Reference fields or processing results in a string template | With year="2026", month="11", and day="20", ${year}-${month}-${day} produces 2026-11-20. The target time zone must still be explicit. |
sum | Add numeric fields with confirmed types | a=1 and b=2 produce 3. Handle string concatenation and numeric addition separately. |
expr | Value calculations or more complex expressions | temperature * 1.8 + 32 converts Celsius 23.5 to approximately Fahrenheit 74.3. Floating-point results may differ in final digits; check within the business tolerance and update the target column's unit as well. |
format inputs use ${字段}. Kafka child table name templates accept both t_{device} and t_${device}; with device=d001, both generate t_d001. This example uses the first. This compatibility applies only to this name-template interface, not all format inputs, mathematical expressions, or complete expressions with backticks. Follow other connectors' interface instructions. Child table names are string results; do not use generator=now to produce a different table name per message.
2.2 Set mapping defaults
Default Value beside mapping fills business-approved missing values, unlike value, which always writes a constant. For example, if source string site may be missing and the business uses unknown for an unknown site, select mapping, source field site, and default unknown, with a sufficiently long target string type. Preview each case first:
| Source input | Expected mapping result |
|---|---|
site="zoneA" | Keeps zoneA, not overwritten by the default. |
site="" or null in this string column | Uses unknown. |
No site column in parsing results | Uses unknown; first rule out misspelled field names or parsing paths. |
Defaults must still meet target type and length requirements. They are not a general fault-tolerance switch that replaces all conversion errors. Nulls in existing integer, Boolean, and binary columns do not all use this default. Do not generalize the string example to every type. Test normal values, nulls, empty strings, and invalid values using actual field types. If default behavior does not meet business requirements, adjust reviewed conversion rules first, then confirm failure handling under Write errors and abnormal data.
For missing device identifiers or business times, check source samples and models first. Do not bulk-fill them with one device constant, zero, or the current time. After setting defaults, still verify target child tables, primary keys, and values to avoid merging devices or hiding source data issues.
2.3 String formatting
Strings can be processed inside ${...} in format, for example ${device.sub_string(0, 4)}. Common forms follow. Preview them in separate samples first instead of combining many changes. pad and trim modify the string itself and do not directly return the modified string. Explicitly return the result at the end of the expression block. ${device.trim()} alone does not produce the trimmed value.
| Method | Example | Expected result |
|---|---|---|
pad | ${let formatted = "1.2"; formatted.pad(5, '0'); formatted} | 1.200; right-padding, not numeric precision configuration. |
trim | ${let formatted = " abc ee "; formatted.trim(); formatted} | abc ee; removes leading and trailing whitespace. |
sub_string | "012345678".sub_string(5) | 5678; adding second argument 2 gives 56. |
sub_string length boundary | "012345678".sub_string(5, 0) | Empty string; a negative second argument is also empty, rather than taking through the end as when omitted. |
sub_string negative index | "012345678".sub_string(-2) | 78; the start counts from the end. |
replace | "012345678".replace("012", "abc") | abc345678. |
Trimming, substring extraction, or replacement may give different devices identical names. Check uniqueness against the actual identifier set before production use. Formatting child table names does not automatically move data already written to old tables.
2.4 Format time text and device identifiers
If source time text and device identifiers do not meet target conventions, verify expressions with separate samples before production mapping. For example, source time 2025/06/10 10:00:00 is confirmed by the business as UTC+8. Enter the following in a time mapping interface providing format expressions:
${ts.replace("/", "-")}+08:00
This produces 2025-06-10 10:00:00+08:00, then parsed using a target-supported time-zone-qualified format. +08:00 adds the source time zone, not merely display formatting. Do not append it if the source already contains Z or another offset. If the date is outside target retention, update both sample and verification window.
To normalize device field device="Pump_A" to lowercase, enter ${device.to_lower()} in the corresponding string expression interface and expect pump_a. To lowercase original table names in a child table template, use the supported tablename variable, for example prefix_${tablename.to_lower()}_suffix. Original table name METERS produces prefix_meters_suffix. These forms belong to template interfaces; do not copy them directly into filters or SQL.
Preview normal values, nulls, mixed-case values, and differently formatted times separately, then query target child tables and times. Case conversion and character replacement can cause name collisions. Do not compensate for conversion failures with the current time or a fixed device name.
2.5 Mathematical expressions
expr supports +, -, *, /, and parentheses. Calculation fields must be numeric. Convert strings first as described in Extraction, splitting, filtering, and transformation. Distinguish integer and floating-point division in particular: 5 / 2 gives integer 2, while 5.0 / 2.0 gives 2.5. This is not merely changing displayed decimal places. Check positive, negative, zero, and null samples.
| Category | Common methods | Example |
|---|---|---|
| Trigonometric/hyperbolic | sin, cos, tan, sinh, cosh | Numeric field angle uses angle.sin() with input in radians. |
| Inverse trigonometric/hyperbolic | asin, acos, atan, asinh, acosh | Check domains first; do not treat empty output as normal. |
| Square root and exponential | sqrt, exp | Float field reading=4.0 with reading.sqrt() gives 2.0. |
| Logarithms | ln, log | With reading=10.0, reading.log() gives 1.0; ln() is the natural logarithm. |
| Rounding and decomposition | floor, ceiling, round, int, fraction | With reading=4.2, floor() gives 4.0, ceiling() gives 5.0, int() gives 4.0, and fraction() gives approximately 0.2. |
Message expressions and TDengine SQL are separate interfaces. Do not copy SQL function names directly into rules. Check invalid values, out-of-range results, and precision changes from calculations in both previews and target queries. In particular, do not hide timestamp primary key collisions through rounding.
2.6 Dynamic column names and wide-table mapping
With Create Template, supertable names, column names, and types can use the corresponding template variables. A column name using ${字段} expands that field's value into a target column name, then maps the selected value field to it. Turning field names and values into actual columns is called pivoting into a wide table. It differs from splitting a message array into multiple rows.
View the dynamic column template creation interface
Select Create Template in the creation menu beside Target Supertable, then enter the supertable name, primary timestamp column, data columns, and tags. The separate example below uses supertable site, time column ts, dynamic column name ${message}, and data column type INT. Variables in name fields come from parsed samples; confirm that the fields exist before continuing mapping.

The expanded type list also offers sample fields as type candidates. For dynamic types, field values must generate target-supported data types, and each column's type must remain consistent across messages. If uncertain, start with an explicit fixed type. Then return to mapping, select the dynamic column's value source, and preview. Saving a template does not mean source messages have been ingested.
For input id=1, message="temperature", and value=23.5, set dynamic column name ${message}, type DOUBLE, and map source value to it. Generate the child table name from device field id. Expect a numeric column named temperature with value 23.5, not a text column still named ${message}. These fields differ from the earlier device temperature example. Use a separate sample and template first instead of changing a verified table directly.
To check multiple metrics and devices together, use this separate sample:
[
{"id":1,"message":"temperature","value":23.5,"ts":1795132800000},
{"id":1,"message":"humidity","value":60.5,"ts":1795132800000},
{"id":2,"message":"temperature","value":24.5,"ts":1795132800000}
]
Fix the supertable template name as site, primary timestamp as ts TIMESTAMP, dynamic data column ${message} as DOUBLE, and tag id as INT. In mapping, convert source ts from milliseconds to a timestamp, select source value for the dynamic column and source id for the tag, and use t_{id} for child table names. Then inspect template and mapping previews separately:
- The template must contain data columns
ts,temperature, andhumidityand tagid. Do not check only columns appearing in the first message. t_1must have temperature23.5and humidity60.5at the same time;t_2must have temperature24.5, without mixing intot_1. The sample provides no humidity fort_2; do not fill it with zero.- This example verifies expansion within one batch only. After actual writing, still check target values using verification below. This preview alone cannot verify cross-batch metrics or metrics added later.

The image above illustrates relationships between id, message, and value, using dynamic column type INT and time generator=now. It is not the complete configuration for the historical temperature exercise. To preserve business time, map actual source time. Choose a suitable numeric type for floating-point values instead of copying INT or collection time.

Before submission, check in order:
- Confirm that all possible column-name field values are within the approved range, without invalid characters, nulls, excessive length, or collisions after replacement. Do not let unbounded business text continually generate columns.
- Check that actual value types are consistent for each expanded column. For example,
temperaturemust not be numeric in some messages and unconvertible text in others. Defaults must not hide type conflicts. - Check that metrics for the same device and business time form the expected wide table and another device still enters a separate child table. Verify results across messages and batches by actual sending and querying. Do not infer automatic aggregation of all history from one preview.
- If a template-generated supertable or column is absent, check whether the error policy permits creation and the execution identity has the required permissions. If an existing schema conflicts with a new type, stop expanding ingestion before confirming model changes.
If the supertable name itself also uses variables, check the complete columns, tags, and types for each actual supertable. In particular, test a message order where one metric appears for the first table, other metrics appear for a second table, then messages return to the first. If template previews omit columns or tags, stop submission, preserve redacted samples and the expected schema list, and confirm the software version and handling with the delivery provider. Do not treat a different sample batch that happens to be complete as a fix or assume automatic column addition covers every case.
Dynamic templates define schemas and mapping for new writes; they do not automatically convert old table data into new wide tables. To split three-phase metrics into multiple rows, use Split three-phase voltage into rows. Do not mix the two models.
3. Check time and types
1795132800000 is a millisecond Unix timestamp. Convert source seconds, microseconds, nanoseconds, or time-zone-qualified text according to the actual format, not merely display formatting. If database precision differs between source and target, confirm allowed precision changes and whether adjacent records may fall on the same timestamp.
Tags describe child table attributes; they are not ordinary columns stored separately for each row. For tag changes on the same child table, confirm update behavior under target table and connector rules. Do not treat tags as per-row historical device attributes.
String lengths, numeric ranges, nulls, and composite primary key requirements follow the actual target table. On first configuration, reject values outside the contract, define whether truncation, defaults, or automatic expansion are allowed, then configure Write errors and abnormal data.
Type conversion failures do not always raise errors. For example, mapping strings "23.5" and "bad" to DOUBLE gives numeric 23.5 for the former, but the latter may become null while its row remains in the preview. Check original fields before conversion and values afterward, not just row counts. If nulls are not allowed, correct source values or mapping before submission. Do not replace this check with zero-filling, defaults, or “archiving is configured.” For actual archive boundaries, see Write errors.
4. Verify tables and real data
4.1 Minimal temperature example
These queries apply only to the temperatures and device example in Section 2, not dynamic wide tables. Submit the corresponding configuration, start the task, and send the example message to the actual test topic. Run in the taosExplorer Data Browser or taos CLI:
DESCRIBE taosx_model_demo.temperatures;
SHOW taosx_model_demo.TABLES;
SELECT ts, temperature, device
FROM taosx_model_demo.t_d001
WHERE ts = 1795132800000;
Child table t_d001 must exist. Expect one row with temperature 23.5 and tag d001. Send another message for device d002 with time 1000 milliseconds later, and confirm it enters t_d002, not t_d001. Finally, send a new time for the same device and confirm that a new table is not created per message.
4.2 Dynamic wide-table example
These queries apply only to the three-row dynamic sample with fixed supertable site above. Keep target database taosx_model_demo and use a separate test task and template. If site or the child tables already exist, use an isolated database and update queries; do not overwrite existing objects. Check template and mapping previews before saving, then start the task, send the complete three-row sample, and run in the taosExplorer Data Browser or taos CLI:
DESCRIBE taosx_model_demo.site;
SELECT ts, temperature, humidity, id
FROM taosx_model_demo.t_1
WHERE ts = 1795132800000;
SELECT ts, temperature, humidity, id
FROM taosx_model_demo.t_2
WHERE ts = 1795132800000;
DESCRIBE must include ts TIMESTAMP, temperature DOUBLE, humidity DOUBLE, and tag id INT. Querying t_1 must return one row at that instant with temperature=23.5, humidity=60.5, and id=1; t_2 must return one row with temperature=24.5, null humidity, and id=2. Both times correspond to 2026-11-20T00:00:00Z; client display may vary by time zone.
For missing columns or rows or incorrect values or tags, preserve inputs and logs from the same run. First check schema, dynamic mapping, within-batch expansion, and write causes. Do not query old data in temperatures as evidence that this example passed. These are verification requirements after actual sending, not execution results replaceable by model previews. Cross-batch sending and later-added metrics still require separate verification.
With repeated writes to the same child table and primary key, do not infer final unique row counts from sent message counts. Verification must check time, values, tags, and actual primary keys together, especially when target records already exist.
5. Troubleshooting
| Symptom | Check order |
|---|---|
| Target supertable not found | Confirm target cluster, database, and permissions, then check whether the administrator created it. |
| Empty or invalid table name | Check required template inputs first, then model previews and the error policy. |
| Time offset or far from expectations | Compare original integer, units, text time zone, and client display time zone. Do not change server time first. |
| Two devices enter the same child table | Check missing identifiers, fixed defaults, or replacement collisions. Stop expanding ingestion. |
| Type or length error on writing | Compare DESCRIBE and failed samples, then decide whether to correct source data or adjust the model under approval. |
For obtaining actual logs and error samples, see Logs and performance.
6. Mapping changes and recovery
Save the original configuration and affected object list first, stopping the task if needed. After changing a child table template or supertable, new data may enter new objects; old objects are not moved or deleted automatically. Even after restoring the original configuration, check the time range during the change and plan separate reingestion or cleanup if needed.
7. Limitations
Message mapping on this page differs from object renaming during TDengine query migration. The latter must also maintain source table, supertable, and metadata relationships. See Object selection and renaming. Configuration previews do not establish automatic historical data reconstruction, permission synchronization, or lossless migration across precisions.