Hi,

Thanks, Dawei and Jialin.

>  Is last an aggregation function or is the result format of last the same
with aggregation queries?

Ok... let me agree with you temporarily. Now we have some syntax like
`select last s1, s2`...

There are two concerns:

(1) Do we support select last *? I think it is needed in some applications.

(2) I do not think it is good to let the result data type of `select last
s1 from root ` as  "| path     |      max_time    |.      last_value.    |"

As we are designing something like SQL, we are not designing API. We need
to let the semantic clear enough.

So, my suggestion, if user write `select last s1 from root`, then return a
wide-column table; if user write `select last s1 s2 from root disable
align`, then return narrow table.

Best,
-----------------------------------
Xiangdong Huang
School of Software, Tsinghua University

 黄向东
清华大学 软件学院


Dawei Liu <[email protected]> 于2020年2月21日周五 下午8:37写道:

> Hi,
>
> I would like to introduce the current requirements first. Imagine when the
> user executes an SQL:
>
> Select last_value(*),max_time(*) from root.sg1.*
>
> The result is:
>
>
> +-------------+-------------+------------+---------------+-----------+-------------+
> |last_value(s1)   |        max_time(s1)|    last_time(s2)   |
> max_value(s2)     |   last_time(N)   | max_value(N)     |
>
> +-------------+-------------+------------+---------------+-----------+-------------+
>
>
> We all know that in the Internet of things, a device typically contains
> multiple sensors, and a set of requirements contains multiple devices.
> The result set above will have N * M columns, sometimes up to 50,000
> columns, which is a very unfriendly way to return data.
>
> So the way we expect to return the data is:
>
> +-------+-------------+-------------+
> | path     |      max_time    |.      last_value.    |
> +-------+-------------+-------------+
>  | s1.        |.       1                 |        1              |
> +-------+-------------+-------------+
> |. s2        |         2              |         2               |
> +-------+-------------+-------------+
> …….
>
> Business processes max_time and last_value in many cases come in pairs, so
> we would like to see a simplified query function named last, so we have
> listed several candidates for SQL to support the new return format
> conversion. Which one do you prefer?
>
> 1. select last(s1), last(s2) from root.sg.d
> 2. select last(s1), last(s2) from root.sg.d align by sensor
> 3. select last(s1, s2) from root.sg.d
> 4. select last s1, s2 from root.sg.d
> 5. last s1, s2 from root.sg.d
> 6. select s1, s2 from root.sg.d last
> 7. select s1, s2 from root.sg.d onlylast
>
>
>
> Thanks
> ---
> Dawei Liu
>
>
>
> > 2020年2月21日 下午8:09,Jialin Qiao <[email protected]> 写道:
> >
> > Hi,
> >
> > Actually we do not have "last" syntax now. There are two ways to treat
> last:
> >
> > (1) Treat it as a special case of raw data query
> > (2)Treat it as a aggregation query
> >
> > Before deciding, let's consider two questions:
> >
> > (1) Is last an aggregation function or is the result format of last the
> same with aggregation queries?
> >
> > I thinks it's not. One aggregation function should return one column.
> For example, the result of "select count(s1) from xx" has one column:
> count(s1).
> > However, the last should return three columns: path, time, value
> >
> > (2) Could "last" be used with other aggregations at the same time?
> >
> > NO, if users issue a last query, he should query the last of all
> selected series. "select last(s1), count(s2)" is not allowed.
> > i.e., it could only be this form: select last(s1), last(s2), last(s3),
> last(s4) from root.sg.d1.    And if so, why we duplicate last so many
> times...
> >
> > Therefor, I prefer treat last as a special case of raw data query.
> i.e.,  4. select last s1, s2 from root.sg.d1
> >
> > Thanks,
> > --
> > Jialin Qiao
> > School of Software, Tsinghua University
> >
> > 乔嘉林
> > 清华大学 软件学院
> >
> >> -----原始邮件-----
> >> 发件人: "Xiangdong Huang" <[email protected]>
> >> 发送时间: 2020-02-21 19:44:46 (星期五)
> >> 收件人: [email protected]
> >> 抄送:
> >> 主题: Re: Last Query syntax vote
> >>
> >> Hi,
> >>
> >> +1 for  select last(s1), last(s2) from root.sg.d
> >>
> >> I think this vote description does not show why we need a new syntax and
> >> the data result format we will get...
> >>
> >> For example, the first SQL is a common query statement, but why it is
> not
> >> suitable and you want a new syntax?
> >>
> >> It is hard to let other guys joining the vote.
> >>
> >> Best,
> >> -----------------------------------
> >> Xiangdong Huang
> >> School of Software, Tsinghua University
> >>
> >> 黄向东
> >> 清华大学 软件学院
> >>
> >>
> >> Dawei Liu <[email protected]> 于2020年2月21日周五 下午5:35写道:
> >>
> >>> Hi,
> >>>
> >>> I’d vote for
> >>>
> >>> [2] select last(s1), last(s2) from root.sg.d align by sensor
> >>>
> >>> It looks simple, it's easy to use, it's human logic
> >>>
> >>>
> >>> Thanks
> >>> ---
> >>> Dawei Liu
> >>>
> >>>
> >>>
> >>>> 2020年2月21日 下午5:26,Wei Shao <[email protected]> 写道:
> >>>>
> >>>> Hi,
> >>>>
> >>>>
> >>>> I'd vote for
> >>>> [4]. select last s1, s2 from root.sg.d
> >>>>
> >>>>
> >>>> Thanks,
> >>>> Wei
> >>>>
> >>>>
> >>>>
> >>>> At 2020-02-21 17:08:14, "Wei Shao" <[email protected]> wrote:
> >>>>> Hi,
> >>>>>
> >>>>>
> >>>>> We are to determine the exact syntax of Last Query for IoTDB. Last
> >>> query is to select the latest time-value pair result for a given
> timeseries.
> >>>>> You can choose from the following syntax options.
> >>>>> 1. select last(s1), last(s2) from root.sg.d
> >>>>> 2. select last(s1), last(s2) from root.sg.d align by sensor
> >>>>> 3. select last(s1, s2) from root.sg.d
> >>>>> 4. select last s1, s2 from root.sg.d
> >>>>> 5. last s1, s2 from root.sg.d
> >>>>> 6. select s1, s2 from root.sg.d last
> >>>>> 7. select s1, s2 from root.sg.d onlylast
> >>>>>
> >>>>>
> >>>>> Please vote for the option you are comfortable with.
> >>>>>
> >>>>>
> >>>>> Thanks,
> >>>>> Wei
> >>>
> >>>
>
>

Reply via email to