You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@iotdb.apache.org by "Julian Feinauer (Jira)" <ji...@apache.org> on 2020/03/02 17:32:00 UTC

[jira] [Commented] (IOTDB-535) Do we need a more accurate data type in the ResultSet for aggregation functions

    [ https://issues.apache.org/jira/browse/IOTDB-535?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17049464#comment-17049464 ] 

Julian Feinauer commented on IOTDB-535:
---------------------------------------

I would like that.

A straightforwad solution would be to give all functions an return type inferrer which acts dependent on the input type.

Examples would be

AVG -> Always Double

SUM -> Take Input Type

For one-adic functions this would be a Function<Type, Type> but could get more complex for other cases.

> Do we need a more accurate data type in the ResultSet for aggregation functions
> -------------------------------------------------------------------------------
>
>                 Key: IOTDB-535
>                 URL: https://issues.apache.org/jira/browse/IOTDB-535
>             Project: Apache IoTDB
>          Issue Type: Improvement
>          Components: Core/Engine
>            Reporter: Xiangdong Huang
>            Priority: Major
>
> Hi, when I am trying to add a UT for GroupBy Time Interval clause, I find that all data in the resultSet are Strings... like:
> {code:java}
> // code placeholder
> try (Connection connection = DriverManager.
>         getConnection("jdbc:iotdb://127.0.0.1:6667/", "root", "root");
>         Statement statement = connection.createStatement()) {
>       statement.execute("INSERT INTO root.ln.wf01.wt01(timestamp,temperature,status, hardware) "
>           + "values(now(), 35.5, false, 650)");
>       ResultSet resultSet = statement.executeQuery(
>           "select count(temperature), sum(temperature), avg(temperature) from "
>               + "root.ln.wf01.wt01 "
>               + "GROUP BY ([now() - 1h, now()), 1h)");
>       assertTrue(resultSet.next());
>       //resultSet.getLong(1) is the timestamp
>       assertEquals(1, Integer.valueOf(resultSet.getString(2)).intValue());
>       assertEquals(35.5, Float.valueOf(resultSet.getString(3)).floatValue(), 0.01);
>       assertEquals(35.5, Double.valueOf(resultSet.getString(4)).doubleValue(), 0.01);
>     }{code}
> I think we can get more accurate data types of the data in the resultSet.
> E.g., count() returns INT, sum returns double or long for float/double or int/long measurement, avg() returns float or double..
> How do you think?
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)