Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to create a stream to load data into super table with tags #25806

Closed
enix223 opened this issue May 16, 2024 · 2 comments
Closed
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@enix223
Copy link

enix223 commented May 16, 2024

Question

I have a summary table (with two tags: location and device_id), the source table device_history also have these two tags, I need to summarized the power value for each location + device_id combination, and load it into the dest table.

CREATE STABLE device_total_power (ts TIMESTAMP, total_power BIGINT) TAGS (location INT, device_id INT);

create stream

CREATE STREAM stream_device_total_power
TRIGGER WINDOW_CLOSE
INTO device_total_power SUBTABLE(CONCAT('device_, CAST(device_id AS VARCHAR(12)), '_total_power'))
AS SELECT _wend AS ts, SUM(power) AS total_power
FROM device_history PARTITION BY location, device_id INTERVAL(1d);

When I run the sql above, I got error:

DB error: Illegal number of columns (0.012870s)

Environment

TDEngine version: 3.1.0.3
Server: Ubuntu 22.04

@enix223 enix223 added help wanted Extra attention is needed question Further information is requested labels May 16, 2024
@yu285
Copy link
Contributor

yu285 commented May 23, 2024

image

CREATE STABLE device_history (ts TIMESTAMP, power BIGINT) TAGS (location INT, device_id INT);

CREATE STREAM stream_device_total_power TRIGGER WINDOW_CLOSE INTO device_total_power SUBTABLE(CONCAT('device_', CAST(device_id AS VARCHAR(12)), '_total_power')) AS SELECT _wen
d AS ts, SUM(power) AS total_power FROM device_history PARTITION BY location, device_id INTERVAL(1d);

it seems fine ,can you try new version? 3.3.0.3

@yu285 yu285 closed this as completed May 23, 2024
@yu285
Copy link
Contributor

yu285 commented May 23, 2024

if any error happened , feel free to contact me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants