TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

Internal error: `Primary key column should not be none`

Open Link-Tian opened this issue 3 weeks ago • 6 comments

Bug Description

I am encountering an internal error of Primary key column should not be none while executing this sql below

INSERT INTO us.ohlcv_1d(tbname, symbol, ts, open, high, low, close, volume) SELECT tbname, symbol, '2025-12-01T00:00:00.000-05:00', first(open), max(high), min(low), last(close), sum(volume) FROM us.ohlcv_1m WHERE symbol = 'AAPL' AND ts >= '2025-12-01T00:00:00.000-05:00' AND ts < '2025-12-02T00:00:00.000-05:00' PARTITION BY tbname, symbol

If I just execute the subquery alone, I get the correct result

SELECT tbname, symbol, '2025-12-01T00:00:00.000-05:00', first(open), max(high), min(low), last(close), sum(volume) FROM us.ohlcv_1m WHERE symbol = 'AAPL' AND ts >= '2025-12-01T00:00:00.000-05:00' AND ts < '2025-12-02T00:00:00.000-05:00' PARTITION BY tbname, symbol
Image

I'm wondering if there is something wrong with my SQL statement, or if the feature is not supported, or if it's a bug?

To Reproduce Steps to reproduce the behavior:

Execute the following SQL statement

INSERT INTO us.ohlcv_1d(tbname, symbol, ts, open, high, low, close, volume) SELECT tbname, symbol, '2025-12-01T00:00:00.000-05:00', first(open), max(high), min(low), last(close), sum(volume) FROM us.ohlcv_1m WHERE symbol = 'AAPL' AND ts >= '2025-12-01T00:00:00.000-05:00' AND ts < '2025-12-02T00:00:00.000-05:00' PARTITION BY tbname, symbol

Expected Behavior

A piece of data is inserted into the us.ohlcv_1d Stable.

Screenshots

Image

Environment (please complete the following information):

  • OS: [e.g. CentOS 7.0] Docker image tdengine/tsdb
  • Memory, CPU, current Disk Space 6G 6U 100G
  • TDengine Version [e.g. 1.6.1.7] 3.3.8.8

Additional Context No

Link-Tian avatar Dec 08 '25 02:12 Link-Tian

https://docs.taosdata.com/reference/taos-sql/table/ TDengine requires that the first column of a table must be of timestamp type.

ZeLv01 avatar Dec 08 '25 05:12 ZeLv01

https://docs.taosdata.com/reference/taos-sql/table/ TDengine requires that the first column of a table must be of timestamp type.

Thanks for the answer, you're talking about the requirement to create a table, whereas in my case it's a data write.

https://docs.taosdata.com/reference/taos-sql/insert/#超级表语法说明 I found in the doc that when using INSERT ... subquery, the first column must be tbname.

The problem I am encountering now is that executing the subquery (SELECT...) alone can return the expected data. The returned data can also be written successfully using the normal insert statement (INSERT...VALUES), but an error will be reported when using INSERT...subquery

Link-Tian avatar Dec 09 '25 01:12 Link-Tian

https://docs.taosdata.com/reference/taos-sql/table/ TDengine requires that the first column of a table must be of timestamp type.

I also tried putting the timestamp in the first column and it still returns the Primary key column should not be none error

Link-Tian avatar Dec 09 '25 01:12 Link-Tian

please run ,send the results here: describe us.ohlcv_1m describe us.ohlcv_1d

ZeLv01 avatar Dec 09 '25 03:12 ZeLv01

please run ,send the results here: describe us.ohlcv_1m describe us.ohlcv_1d

Image Image

Link-Tian avatar Dec 09 '25 04:12 Link-Tian

Thank you for your feedback. Please wait for the release of our updated version.

ZeLv01 avatar Dec 09 '25 07:12 ZeLv01