You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@iotdb.apache.org by "Eric Pai (Jira)" <ji...@apache.org> on 2022/01/18 07:59:00 UTC
[jira] [Commented] (IOTDB-2429) Clearify string literal and timeseries path in grammer
[ https://issues.apache.org/jira/browse/IOTDB-2429?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17477635#comment-17477635 ]
Eric Pai commented on IOTDB-2429:
---------------------------------
[~liuminghui] [~suyurong] Please review those cases and check whether we have the same idea :)
> Clearify string literal and timeseries path in grammer
> ------------------------------------------------------
>
> Key: IOTDB-2429
> URL: https://issues.apache.org/jira/browse/IOTDB-2429
> Project: Apache IoTDB
> Issue Type: Bug
> Components: Planner/SQLParser
> Reporter: Eric Pai
> Assignee: Eric Pai
> Priority: Major
> Fix For: master branch
>
>
> After this work is finished, the constant of string type (quoted with '' or "") in the expression is not worked now.
> The root cause is that in this commit [https://github.com/apache/iotdb/commit/289d23f8dcf27e55cf286df07975086c3d93b33d] , the definitions of {_}nodename{_}, {_}nodeNameWithoutWildcard{_}, _nodeNameCanInExpr_ contain STRING_LITERAL, which is also included in _constant_ definition{_}.{_} So there's a confliction in antlr resolution, the quoted string literal will be always treated as timeseries node path, not a constant.
> So we need to clarify the representation of string literal and timeseries path.
> IMO, the following SQLs are valid:
> [1] CREATE TIMESERIES root.vehicle.`'d0'`.s0 WITH DATATYPE=INT32, ENCODING=RLE – The real timeseries is {color:#de350b}root.vehicle.'d0'.s0{color}{color:#de350b}{color:#172b4d}.{color}{color}
> [2] CREATE TIMESERIES root.vehicle.`"d0"`.s0 WITH DATATYPE=INT32, ENCODING=RLE – The real timeseries is {color:#de350b}root.vehicle."d0".s0{color}{color:#de350b}{color:#172b4d}.{color}{color}
> [3] CREATE TIMESERIES root.vehicle.`a+b+c`.s0 WITH DATATYPE=INT32, ENCODING=RLE – The real timeseries is {color:#de350b}root.vehicle.a+b+c.s0{color:#172b4d}.{color}{color}
> [4] INSERT INTO root.vehicle.`a*1.0`(time, s0) values (1, 'a') – string {color:#de350b}'a'{color} will be inserted into timeseries {color:#de350b}root.vehicle.`a*1.0`.s0{color:#172b4d}. (Backward compatible with v0.12){color}{color}
> [5] INSERT INTO root.vehicle.`a*1.0`(time, `s0*2.0`) values (1, "a") – string {color:#de350b}'a'{color} will be inserted into timeseries {color:#de350b}root.vehicle.a*1.0.s0*2.0{color:#172b4d}. {color:#de350b}{color:#172b4d}(Backward compatible with v0.12){color}{color}{color}{color}
> [6] SELECT my_udf(`a1+a2`, 'b', 'k'='v') FROM root.sg.`d1+d2` – the UDF my_udf is called, and the 1st parameter is the timeseries {color:#de350b}root.sg.d1+d2.a1+a2{color}, the 2nd parameter is a constant string {color:#de350b}'b'{color}, and the 3rd is an attribute whose key is {color:#de350b}'k'{color} and value is {color:#de350b}'v'{color}.
> [7] SELECT my_udf(`a1+a2`, "b", 'k'='v') FROM root.sg.`d1+d2` – the UDF my_udf is called, and the 1st parameter is the timeseries {color:#de350b}root.sg.d1+d2.a1+a2{color}, the 2nd parameter is a constant string {color:#de350b}'b'{color}, and the 3rd is an attribute whose key is {color:#de350b}'k'{color} and value is {color:#de350b}'v'{color:#172b4d}.{color}{color}
>
> But the following ones are not allowed:
> [8]CREATE TIMESERIES root.vehicle."a".s0 WITH DATATYPE=INT32, ENCODING=RLE – "a" is interpreted as a constant string.
> [9]CREATE TIMESERIES root.vehicle.'a'.s0 WITH DATATYPE=INT32, ENCODING=RLE – 'a' is interpreted as a constant string.
> [10]INSERT INTO root.vehicle.'a*1.0'(time, s0) values (1, 'a') – 'a*1.0' is not a valid timeseries node path{color:#de350b}{color:#172b4d}.{color}{color}
>
--
This message was sent by Atlassian Jira
(v8.20.1#820001)