Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions client/rpcdataset.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ func (s *IoTDBRpcDataSet) getBooleanByTsBlockColumnIndex(tsBlockColumnIndex int3
if err := s.checkRecord(); err != nil {
return false, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return false, nil
}
if !s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = false
return s.curTsBlock.GetColumn(tsBlockColumnIndex).GetBoolean(s.tsBlockIndex)
Expand Down Expand Up @@ -348,6 +352,10 @@ func (s *IoTDBRpcDataSet) getDoubleByTsBlockColumnIndex(tsBlockColumnIndex int32
if err := s.checkRecord(); err != nil {
return 0, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return 0, nil
}
if !s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = false
return s.curTsBlock.GetColumn(tsBlockColumnIndex).GetDouble(s.tsBlockIndex)
Expand Down Expand Up @@ -377,6 +385,10 @@ func (s *IoTDBRpcDataSet) getFloatByTsBlockColumnIndex(tsBlockColumnIndex int32)
if err := s.checkRecord(); err != nil {
return 0, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return 0, nil
}
if !s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = false
return s.curTsBlock.GetColumn(tsBlockColumnIndex).GetFloat(s.tsBlockIndex)
Expand Down Expand Up @@ -406,6 +418,10 @@ func (s *IoTDBRpcDataSet) getIntByTsBlockColumnIndex(tsBlockColumnIndex int32) (
if err := s.checkRecord(); err != nil {
return 0, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return 0, nil
}
if !s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = false
dataType := s.curTsBlock.GetColumn(tsBlockColumnIndex).GetDataType()
Expand Down Expand Up @@ -484,6 +500,10 @@ func (s *IoTDBRpcDataSet) getBinaryByTsBlockColumnIndex(tsBlockColumnIndex int32
if err := s.checkRecord(); err != nil {
return nil, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return nil, nil
}
if !s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = false
return s.curTsBlock.GetColumn(tsBlockColumnIndex).GetBinary(s.tsBlockIndex)
Expand Down Expand Up @@ -513,6 +533,10 @@ func (s *IoTDBRpcDataSet) getObjectByTsBlockIndex(tsBlockColumnIndex int32) (int
if err := s.checkRecord(); err != nil {
return nil, err
}
if tsBlockColumnIndex < 0 {
s.lastReadWasNull = false
return nil, nil
}
if s.isNull(tsBlockColumnIndex, s.tsBlockIndex) {
s.lastReadWasNull = true
return nil, nil
Expand Down
11 changes: 11 additions & 0 deletions client/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ func (s *Session) ExecuteStatement(sql string) (*SessionDataSet, error) {
return s.ExecuteStatementWithContext(context.Background(), sql)
}

func (s *Session) Ping(ctx context.Context) error {
status, err := s.client.TestConnectionEmptyRPC(ctx)
if err != nil {
return err
}
if status.GetCode() == SuccessStatus {
return nil
}
return errors.New("Ping failed: " + status.GetMessage())
}

func (s *Session) ExecuteNonQueryStatement(sql string) error {
request := rpc.TSExecuteStatementReq{
SessionId: s.sessionId,
Expand Down
50 changes: 50 additions & 0 deletions database/batch.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

package iotdb_go

import (
"context"
"database/sql/driver"

"github.com/pkg/errors"
)

type stdBatch struct {
debugf func(format string, v ...any)
}

func (s *stdBatch) NumInput() int { return -1 }

func (s *stdBatch) Exec(args []driver.Value) (driver.Result, error) {
return nil, errors.New("not implemented")
}

func (s *stdBatch) ExecContext(ctx context.Context, args []driver.NamedValue) (driver.Result, error) {
return nil, driver.ErrSkip
}

func (s *stdBatch) Query(args []driver.Value) (driver.Rows, error) {
// Note: not implementing driver.StmtQueryContext accordingly
return nil, errors.New("only Exec method supported in batch mode")
}

func (s *stdBatch) Close() error {
return nil
}
Loading
Loading