taosdata / TDengine

High-performance, scalable time-series database designed for Industrial IoT (IIoT) scenarios
https://tdengine.com
GNU Affero General Public License v3.0
23.24k stars 4.84k forks source link

Rest read from TDengine with wrong result issue #25427

Closed masterchengsheng closed 4 months ago

masterchengsheng commented 5 months ago

在执行超级查询数据时,发现采用数据源查询数据,数据字段长的那个字段会出现有的时候查询出来,有的时候查询不出来,数据出现是随机的,

数据超级表结构: CREATE STABLEmeasure_vibrate_original(tsTIMESTAMP,valueVARCHAR(65500),frequencyINT) TAGS (measure_codeVARCHAR(64),equipment_codeVARCHAR(64),measure_type_codeVARCHAR(64),company_codeVARCHAR(64),order_numINT)

image

查询语句: select ts,value,order_num,frequency from dqms.measure_vibrate_original where ts>= 1713518404000 and ts <= 1713518406000 and equipment_code='Y1CRF001PO' and measure_code='MBND_1_P_800L_1K' order by ts image

直接在taos命令行中已经确认有七条数据,每条数据的value都有数据。但是采用数据源执行查询时,返回的数据在value这个字段中随机的出现

驱动版本3.2.4; td的版本3.2.0 springboot 版本2.5.14 这是采用数据源直接测试的代码


            dataSource.setPassword("taosdata");
            dataSource.setUsername("root");
            dataSource.setJdbcUrl("jdbc:TAOS-RS://192.168.135.52:6041/dqms?user=root&password=taosdata");
            dataSource.setMaximumPoolSize(10);
            dataSource.setDriverClassName("com.taosdata.jdbc.rs.RestfulDriver");
            try (Connection connection = dataSource.getConnection()) {
                ResultSet resultSet = connection.createStatement().executeQuery(sql);
                while (resultSet.next()) {
                    String string = resultSet.getString("value");
                    System.out.println(string);
                }
            }```
打印出来的是7条数据中只有一个有值,
采用springboot的数据源去测试跟上面的效果是一样的
```            DataSource dataSource = tdengineDb.use(null);//获取数据源 druid
            try (Connection connection = dataSource.getConnection()) {
                ResultSet resultSet = connection.createStatement().executeQuery(sql);
                while (resultSet.next()){
                    String string = resultSet.getString("value");
                    System.out.println(string);
                }
            } catch (Exception e) {
                log.error(e.getMessage(), e);
            }```
采用如下代码进行测试是发现数据都能取得到
```            String jdbcUrl = "jdbc:TAOS-RS://192.168.135.52:6041/dqms?user=root&password=taosdata";
            Properties connProps = new Properties();
            connProps.setProperty(TSDBDriver.PROPERTY_KEY_BATCH_LOAD, "true");
            Connection conn = DriverManager.getConnection(jdbcUrl, connProps);
            ResultSet resultSet = conn.createStatement().executeQuery("select ts,`value`,order_num,frequency from dqms.measure_vibrate_original where ts>= 1713518404000 and ts <= 1713518406000 and equipment_code='Y1CRF001PO' and measure_code='MBND_1_P_800L_1K' order by ts");
            while (resultSet.next()){
                String string = resultSet.getString("value");
                System.out.println(string);
            }
            System.out.println("Connected");
            conn.close();```
masterchengsheng commented 5 months ago
String sql = "select ts,`value`,order_num,frequency from dqms.measure_vibrate_original where ts>= 1713518404000 and ts <= 1713518406000 and equipment_code='Y1CRF001PO' and measure_code='MBND_1_P_800L_1K' order by ts";
        HikariDataSource dataSource = new HikariDataSource();
        dataSource.setPassword("taosdata");
        dataSource.setUsername("root");
        dataSource.setJdbcUrl("jdbc:TAOS-RS://192.168.135.52:6041/dqms?user=root&password=taosdata");
        dataSource.setMaximumPoolSize(10);
        dataSource.setDriverClassName("com.taosdata.jdbc.rs.RestfulDriver");
        try (Connection connection = dataSource.getConnection()) {
            ResultSet resultSet = connection.createStatement().executeQuery(sql);
            while (resultSet.next()) {
                String string = resultSet.getString("value");
                System.out.println(StringUtils.isBlank(string) ? "----" : string);
            }
        }

返回来的数据

image

yu285 commented 4 months ago

可以加微信具体沟通一下a15652223354

masterchengsheng commented 4 months ago

升级jdbc 版本->3.2.9 td版本3.2.3 之后不会出现上述问题