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

Aliases 即 AS 存在兼容性问题:不支持单双引号;无法与 count 函数共同使用 #28766

Open
ipaddicting opened this issue Nov 14, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@ipaddicting
Copy link

ipaddicting commented Nov 14, 2024

Bug Description
Aliases 即 AS 存在兼容性问题:

首先,AS 不支持单双引号,即 "'

taos> SELECT TIMETRUNCATE(ts, 1d, 0) AS ts, max(engine_load) AS "max(engine_load)" FROM abacus.log_combikat GR
OUP BY TIMETRUNCATE(ts, 1d, 0) ORDER BY engine_load DESC;
DB error: syntax error near ""max(engine_load)" from abacus.log_combikat group by timetruncate(ts, 1d, 0) order by engine_load desc;" (0.000060s)

去除 '" 后仅支持简单字符,但存在歧义:

taos> SELECT TIMETRUNCATE(ts, 1d, 0) AS ts, max(engine_load) AS engine_load FROM abacus.log_combikat GROUP BY
TIMETRUNCATE(ts, 1d, 0) ORDER BY engine_load DESC;
           ts            |     engine_load      |
=================================================
 2016-02-08 00:00:00.000 |          -24.3999996 |
 2016-02-04 00:00:00.000 |          -24.3999996 |
 2016-02-17 00:00:00.000 |          -24.3999996 |
 2016-02-18 00:00:00.000 |          -24.3999996 |
 2016-02-13 00:00:00.000 |          -24.3999996 |
 2016-02-02 00:00:00.000 |          -24.3999996 |
 2016-02-07 00:00:00.000 |          -24.3999996 |
 2016-02-14 00:00:00.000 |          -24.3999996 |
 2016-02-19 00:00:00.000 |          -24.3999996 |
 2016-02-06 00:00:00.000 |          -24.3999996 |
 2016-02-12 00:00:00.000 |          -24.3999996 |
 2016-02-03 00:00:00.000 |          -24.3999996 |
 2016-02-15 00:00:00.000 |          -24.3999996 |
 2016-02-16 00:00:00.000 |          -24.3999996 |
 2016-02-29 00:00:00.000 |          -24.5000000 |
 2016-02-01 00:00:00.000 |          -24.5000000 |
 2016-02-24 00:00:00.000 |          -24.5000000 |
 2016-02-27 00:00:00.000 |          -24.5000000 |
 2016-02-22 00:00:00.000 |          -24.5000000 |
 2016-02-11 00:00:00.000 |          -24.5000000 |
 2016-02-10 00:00:00.000 |          -24.5000000 |
 2016-02-21 00:00:00.000 |          -24.5000000 |
 2016-02-20 00:00:00.000 |          -24.5000000 |
 2016-02-28 00:00:00.000 |          -24.5000000 |
 2016-02-25 00:00:00.000 |          -24.5000000 |
 2016-02-09 00:00:00.000 |          -24.5000000 |
 2016-02-05 00:00:00.000 |          -24.5000000 |
 2016-02-26 00:00:00.000 |          -24.5000000 |
 2016-02-23 00:00:00.000 |          -24.5000000 |
Query OK, 29 row(s) in set (0.011580s)

不支持单双引号导致与其他软件如 Superset 存在兼容问题:

Error: [0x2600]: syntax error near ""MAX(engine_load)" 
from abacus.log_combikat group by timetruncate(ts, 1d, 0) order by "MAX(engine_load)" desc
 limit 10000"

其次,COUNT 函数无法使用 AS,报错如下:

taos> SELECT TIMETRUNCATE(ts, 1d, 0) AS ts, count(*) AS count FROM abacus.log_combikat GROUP BY TIMETRUNCATE(t
s, 1d, 0);
DB error: syntax error near "count from abacus.log_combikat group by timetruncate(ts, 1d, 0);" (0.000144s)

移除 AS 可正常查询:

taos> SELECT TIMETRUNCATE(ts, 1d, 0) AS ts, count(*) FROM abacus.log_combikat GROUP BY TIMETRUNCATE(ts, 1d, 0)
           ts            |       count(*)        |
==================================================
 2016-02-05 00:00:00.000 |                   286 |
 2016-02-11 00:00:00.000 |                   282 |
 2016-02-16 00:00:00.000 |                   286 |
 2016-02-06 00:00:00.000 |                   286 |
 2016-02-15 00:00:00.000 |                   286 |
 2016-02-10 00:00:00.000 |                   284 |
 2016-02-21 00:00:00.000 |                   288 |
 2016-02-20 00:00:00.000 |                   288 |
 2016-02-28 00:00:00.000 |                   288 |
 2016-02-14 00:00:00.000 |                   286 |
 2016-02-25 00:00:00.000 |                   288 |
 2016-02-17 00:00:00.000 |                   286 |
 2016-02-18 00:00:00.000 |                   286 |
 2016-02-09 00:00:00.000 |                   286 |
 2016-02-23 00:00:00.000 |                   287 |
 2016-02-02 00:00:00.000 |                   286 |
 2016-02-26 00:00:00.000 |                   288 |
 2016-02-22 00:00:00.000 |                   287 |
 2016-02-27 00:00:00.000 |                   287 |
 2016-02-07 00:00:00.000 |                   286 |
 2016-02-29 00:00:00.000 |                   288 |
 2016-02-13 00:00:00.000 |                   286 |
 2016-02-04 00:00:00.000 |                   286 |
 2016-02-19 00:00:00.000 |                   288 |
 2016-02-01 00:00:00.000 |                   286 |
 2016-02-24 00:00:00.000 |                   288 |
 2016-02-03 00:00:00.000 |                   286 |
 2016-02-12 00:00:00.000 |                   285 |
 2016-02-08 00:00:00.000 |                   286 |
Query OK, 29 row(s) in set (0.009566s)

To Reproduce
参考以上 SQL 语句。

Expected Behavior

  1. AS 需支持单双引号;
  2. AS 可以与 COUNT 函数共同使用。

Environment (please complete the following information):

  • OS: 官方镜像
  • TDengine Version 3.3.0.0

Additional Context
目前我正在尝试将 taospy 集成进 Superset 的过程中,相关代码会在集成验证完成后提交 taospy 以及 Superset 合并,谢谢。

@ipaddicting ipaddicting added the bug Something isn't working label Nov 14, 2024
@ipaddicting ipaddicting changed the title Aliases 即 AS 兼容性问题:不支持单双引号;无法与count函数共同使用 Aliases 即 AS 兼容性问题:不支持单双引号;无法与 count 函数共同使用 Nov 14, 2024
@ipaddicting ipaddicting changed the title Aliases 即 AS 兼容性问题:不支持单双引号;无法与 count 函数共同使用 Aliases 即 AS 存在兼容性问题:不支持单双引号;无法与 count 函数共同使用 Nov 14, 2024
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

1 participant