Skip to content

3.3.5.0版本UNION ALL查询时字段长度不同执行SQL异常 #30632

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

Open
river1017 opened this issue Apr 3, 2025 · 3 comments
Open

3.3.5.0版本UNION ALL查询时字段长度不同执行SQL异常 #30632

river1017 opened this issue Apr 3, 2025 · 3 comments
Labels
bug Something isn't working

Comments

@river1017
Copy link

Bug Description
3.3.5.0版本执行以下SQL语句异常:
(select 1741708800000 startTime,

        '37KAP1_DL' deviceId,

        1215373850266001408 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '37KAP1_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

     UNION ALL 

        (select 1741708800000 startTime,

        '37KAP2_DL' deviceId,

        1215373850266001408 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '37KAP2_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

     UNION ALL 

        (select 1741708800000 startTime,

        '8FPDX_WYGL_3_DL' deviceId,

        1215373861133443072 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '8FPDX_WYGL_3_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

当把第三段中的8FPDX_WYGL_3_DL长度减少到9位的时候正常,以下SQL能够正常执行:
(select 1741708800000 startTime,

        '37KAP1_DL' deviceId,

        1215373850266001408 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '37KAP1_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

     UNION ALL 

        (select 1741708800000 startTime,

        '37KAP2_DL' deviceId,

        1215373850266001408 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '37KAP2_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

     UNION ALL 

        (select 1741708800000 startTime,

        'WYGL_3_DL' deviceId,

        1215373861133443072 companyId,

        last(collect_date_time) endTime,

        last(temp.collect_value) - first(temp.collect_value) usage from (

        select

        collect_date_time, collect_value

        from aiot_dasmeasure.measure_data_t1743084587277402113

        where project_id = 1192410229407772672

        and device_id = '8FPDX_WYGL_3_DL'

        and collect_date_time >= 1741708800000

        and collect_date_time <= 1745510400000

        and is_delete is null

        order by collect_date_time

        ) temp)

Expected Behavior
在UNION ALL中长度不一样也能够正常执行

Environment (please complete the following information):

  • TDengine Version [3.3.5.0]
@river1017 river1017 added the bug Something isn't working label Apr 3, 2025
@yu285
Copy link
Contributor

yu285 commented Apr 7, 2025

是从哪个版本升级上来的呢

@river1017
Copy link
Author

是从哪个版本升级上来的呢

从3.3.3.0升级的

@yu285
Copy link
Contributor

yu285 commented May 8, 2025

可以远程看下 a15652223354

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants