Class: ADBCArrow::Statement

Inherits:
Object
  • Object
show all
Extended by:
ADBC::StatementOpenable
Includes:
ADBC::StatementOperations
Defined in:
lib/adbc/arrow-statement.rb

Instance Method Summary collapse

Methods included from ADBC::StatementOpenable

open

Methods included from ADBC::StatementOperations

#ingest, #query

Instance Method Details

#bind(*args) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/adbc/arrow-statement.rb', line 44

def bind(*args)
  n_args = args.size
  if block_given?
    message = "wrong number of arguments (given #{n_args}, expected 1 with block)"
    raise ArgumentError, message unless n_args == 1
    values = args[0]
    if values.is_a?(Arrow::Table)
      values = Arrow::TableBatchReader.new(values)
    end
    if values.is_a?(Arrow::RecordBatchReader)
      bind_stream(values)
      yield
    else
      bind_raw(values)
      yield
    end
  else
    bind_raw(*args)
  end
end

#bind_rawObject



43
# File 'lib/adbc/arrow-statement.rb', line 43

alias_method :bind_raw, :bind

#execute(need_result: true) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/adbc/arrow-statement.rb', line 24

def execute(need_result: true)
  _, reader, n_rows_affected = execute_raw(need_result)
  if need_result
    begin
      if block_given?
        yield(reader, n_rows_affected)
      else
        [reader.read_all, n_rows_affected]
      end
    end
  else
    if block_given?
      yield(n_rows_affected)
    else
      n_rows_affected
    end
  end
end

#execute_rawObject



23
# File 'lib/adbc/arrow-statement.rb', line 23

alias_method :execute_raw, :execute