TDengine icon indicating copy to clipboard operation
TDengine copied to clipboard

limit subclause does NOT truncate extra raw-block-payload for non-fixed-length select-list

Open freemine opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. taos_fetch_raw_block returns whole column-payload no matter whether limit sub-clause exists or not. NOTE: nr_rows field of raw-block is correct eg.: for a table: create table t (ts timestamp, i32 int, name varchar(20)) and 4096 rows in the table. comparing: sql1: select name from t sql2: select name from t limit 1 all 4096 rows of col name are in the payload returned by taos_fetch_raw_block but comparing: sql1: select i32 from t sql2: select i32 from t limit 1 the first raw-block contains 4096 rows of i32, while the second contains only 1 row of i32 as what limit 1 requires

Describe your desired behavior this does not matter too much, except when the raw-block returned by taos_fetch_raw_block is to be sent over the network. better modify the internal implementation of taos_fetch_raw_block, or give another taos-API for the sake of what-so-called API-compatibility.

Describe your solutions/suggestions if you've any for whom interested in this issues, you might think of such workarounds as follows:

  1. select * from (select ts, name from t limit 1) x order by ts

Additional context

$ node tools/node/mytaosws_node.js --sql 'select name from bg.t limit 1'
cols_payloads:
<Buffer 00 00 00 00 09 00 32 36 33 32 34 30 35 31 31 09 00 31 37 31 32 30 30 32 37 37 08 00 38 30 33 33 32 30 32 33 0a 00 31 35 32 30 32 30 35 34 30 35 0a 00 ... 47013 more bytes>
$ node tools/node/mytaosws_node.js --sql 'select name from bg.t limit 4096'
cols_payloads:
<Buffer 00 00 00 00 0b 00 00 00 16 00 00 00 20 00 00 00 2c 00 00 00 38 00 00 00 44 00 00 00 4f 00 00 00 5b 00 00 00 66 00 00 00 71 00 00 00 7c 00 00 00 88 00 ... 63393 more bytes>
$ echo '(63393 - 47013) / 4' | bc
4095
#comment: 4096 - 1 = 4095. denotes payloads for column offsets

$ node tools/node/mytaosws_node.js --sql 'select i32 from bg.t limit 1'
cols_payloads:
<Buffer 00 32 43 74 67>
$ node tools/node/mytaosws_node.js --sql 'select i32 from bg.t limit 4096'
cols_payloads:
<Buffer 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 16846 more bytes>

freemine avatar Jan 31 '24 03:01 freemine