apache / iotdb-client-go

Apache IoTDB Client for Go
https://iotdb.apache.org/
Apache License 2.0
55 stars 33 forks source link

cannot get data when using some features implemented in iotdb session #73

Closed yooniversal closed 1 year ago

yooniversal commented 1 year ago

I have implemented that change default DB of edgeX project as IoTDB working on docker, but there are some issues when use GET method when I call it on edgeX. IoTDB session is connected successfully with DB client of the project.

Description

I'm following printDataSet0() and insertRecord() implemented in session_example.go.

Although Session.InsertRecord() works successfully that returns no error and I can check input data in IoTDB (referenced here for testing it work as typing SQL in IoTDB), cannot retrieve the data in edgeX when use Session.ExecuteQueryStatement(sql) perfectly. More details, ExecuteQueryStatement() returns SessionDataSet without error but when use SessionDataSet.GetText(), it returns "" always but not input data saved in IoTDB.

Use InsertRecord() in AddEvent(): code here and GetText() in ChangeTypeToEvent(): code here

execute SQL in IoTDB: image

empty string returned from IoTDB in edgeX API response: (deviceId: root.sg27, measurement: deviceName, value: root) image

While I use getText(), make isNull() in the function not working because returns false:

// client/rpcdataset.go
func (s *IoTDBRpcDataSet) getText(columnName string) string {
    if s.closed {
        return ""
    }
    if columnName == TimestampColumnName {
        return time.Unix(0, bytesToInt64(s.time)*1000000).Format(time.RFC3339)
    }

    columnIndex := s.getColumnIndex(columnName)
    if columnIndex < 0 || int(columnIndex) >= len(s.values) || { //s.isNull(int(columnIndex), s.rowsIndex-1) {
        s.lastReadWasNull = true
        return ""
    }
    s.lastReadWasNull = false
    return s.getString(int(columnIndex), s.columnTypeDeduplicatedList[columnIndex])
}

Question

If you think reason is different, please share.

Environment

yooniversal commented 1 year ago

I omitted some codes that must be called SessionDataSet.Next() before calling SessionDataSet.GetText() (or SessionDataSet.GetValue(), ...). After adding some codes in session_example.go, GetText() and GetValue() return expected value.