aws-sdk-ruby: Not receiving ion_text and can't parse ion_binary in QLDB session

Not receiving ion_text and can’t parse ion_binary in QLDB session while executing query

I am fairly new in QLDB. This might not be a issue as I don’t have much knowledge in QLDB. I have a ledger named hk-ledger-test and a table named testing. I am trying to execute a query in that table.

gem name: aws-sdk-qldbsession

Version of Ruby: 2.4.1, OS environment : MacOs

Code snippets

I have the following method to execute query

def test
      cred = Aws::Credentials.new(ENV['AWS_ACCESS_KEY'], ENV['AWS_SECRET_ACCESS_KEY'])

      qldb_session_client = Aws::QLDBSession::Client.new(region: 'ap-southeast-1', credentials: cred)

      start_session_req = Aws::QLDBSession::Types::StartSessionRequest.new
      start_session_req.ledger_name = 'hk-ledger-test'

      command_request = Aws::QLDBSession::Types::SendCommandRequest.new

      command_request.start_session = start_session_req

      resp = qldb_session_client.send_command(command_request)
      session_token = resp.start_session.session_token

      command_request = Aws::QLDBSession::Types::SendCommandRequest.new
      command_request.session_token = session_token
      command_request.start_transaction = Aws::QLDBSession::Types::StartTransactionRequest.new
      resp = qldb_session_client.send_command(command_request)
      transaction_id = resp.start_transaction.transaction_id

      command_request = Aws::QLDBSession::Types::SendCommandRequest.new
      command_request.session_token = session_token
      command_request.execute_statement = Aws::QLDBSession::Types::ExecuteStatementRequest.new
      command_request.execute_statement.transaction_id = transaction_id
      command_request.execute_statement.statement = 'select * from testing'
      resp = qldb_session_client.send_command(command_request)
      resp
    end

And it’s returning the following Struct, ion_text was supposed to be in there but it’s showing nil

#<struct Aws::QLDBSession::Types::SendCommandResult start_session=nil, start_transaction=nil, end_session=nil, commit_transaction=nil, abort_transaction=nil, execute_statement=#<struct Aws::QLDBSession::Types::ExecuteStatementResult first_page=#<struct Aws::QLDBSession::Types::Page values=[#<struct Aws::QLDBSession::Types::ValueHolder ion_binary="\xE0\x01\x00\xEA\xEE\x9A\x81\x83\xDE\x96\x87\xBE\x93\x89firstname\x88lastname\xDE\x9D\x8A\x8Dtesting first\x8B\x8Ctesting last", ion_text=nil>, #<struct Aws::QLDBSession::Types::ValueHolder
ion_binary="\xE0\x01\x00\xEA\xEE\x9A\x81\x83\xDE\x96\x87\xBE\x93\x89firstname\x88lastname\xDE\x9D\x8A\x8Dtesting first\x8B\x8Ctesting last", ion_text=nil>, #<structAws::QLDBSession::Types::ValueHolder ion_binary="\xE0\x01\x00\xEA\xEE\x9A\x81\x83\xDE\x96\x87\xBE\x93\x89firstname\x88lastname\xDB\x8A\x83ami\x8B\x84boka", ion_text=nil>], next_page_token=nil>>, fetch_page=nil>

I don’t know if I am doing something wrong or if this is the right way. I was then trying to decode the binary -

string_io = StringIO.new(resp.execute_statement.first_page.values[0].ion_binary).binmode
decoded_string= Aws::EventStream::Decoder.new.decode(string_io)

it shows #<Enumerator: #<Enumerator::Generator:0x007fc9598a2350>:each>

where do I go from here? How do I get the data?

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

I’ve engaged relevant teams to start a feature request for Ion support in Ruby. There may be a quick and dirty way to do this using the C extension with a Ruby wrapper.