* fix(scalar): prevent crash when IN expression has invalid type from unhandled node
Root cause: sclGetNodeType() silently set *type = -1 and returned
TSDB_CODE_SUCCESS for unhandled node types. This propagated -1 as
ctx->type.selfType, which was then cast to (uint32_t)-1 = 4294967295
and used as an index into tDataTypes[], causing an out-of-bounds
crash in scalarGenerateSetFromList().
The bug was triggered by semantically odd SQL such as:
ifnull(b not between vb and a, n in (...)) in (today(), today(), now())
where a boolean result is compared against a timestamp list.
Fixes:
1. sclGetNodeType(): return TSDB_CODE_QRY_INVALID_INPUT for unhandled
node types instead of silently setting type = -1.
2. sclInitParam(): validate selfType before using it as list element
type to prevent OOB access in vectorGetConvertType(-1, ...).
3. scalarGenerateSetFromList(): add IS_INVALID_TYPE() guard at entry
as a defensive check against any future invalid-type paths.
Add regression test: test_scalar_invalid_type.py
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* fix: case when and decimal query crash issues
* fix: sclGetNodeType missing cases cause invalid input in query/subquery
Add missing node type cases to sclGetNodeType() that were hit after
ed9de01 changed the fallthrough from silent type=-1 to hard error:
1. QUERY_NODE_LEFT_VALUE (27): return ctx->type.opResType, used when
the planner rewrites constants into ASSIGN(LEFT_VALUE, VALUE)
operators for scalarSup pre-processing (e.g. mavg(2.0, 3))
2. QUERY_NODE_REMOTE_VALUE_LIST (61): read resType from SExprNode,
used when IN subquery RHS is a remote value list node
3. QUERY_NODE_REMOTE_VALUE / QUERY_NODE_REMOTE_ZERO_ROWS /
QUERY_NODE_REMOTE_ROW: read resType from embedded SValueNode,
defensive coverage for other remote node types
Also extend doSetInputDataBlock() dummy-column creation to cover
the first constant argument of indefinite-rows functions (mavg, csum,
diff) so pInput->pData[0] is not NULL at function execution time.
Fixes: select distinct t1,'abc',tbname from st1 -> invalid input
Fixes: 1 in (select 1 from st1) -> invalid input
Fixes: mavg(cast(2 as float), 3) -> invalid input
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
---------
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Implement week/month/year units for stream PERIOD trigger with natural
boundary alignment and offset support.
Key changes:
- Parser: Add validation for natural time units (w/n/y) and offset parameter
- Time utilities: Add getDuration() support for week/month/year units
- TriggerTask: Implement window calculation with natural boundary alignment
- Week: align to Monday 00:00:00
- Month: align to 1st of month 00:00:00
- Year: align to Jan 1st 00:00:00
- Add offset support: PERIOD(1w, 1d) shifts window by 1 day
- Unit tests: Parser validation, time utilities, TriggerTask window calculation
- System tests: End-to-end tests for week/month/year units with offset
- Documentation: Update user manual with natural time unit examples
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>