Skip to content

Vertica returns empty result set when there is no data and row_handler_block is present #73

@santosh-1987

Description

@santosh-1987

Hey Team,

We are facing an issue with the Vertica library when a row_handler is passed to query execution.

Scenario :
Query1: select * from persons limit 0;

This is expected to return the column metadata info w.r.t person table but returns an empty string and as there is no result it doesn't execute the code block.

result_rows = []
column_names = []
query_result =
        connection.query(execution.query) do |result|
           result_rows.push(result)
           column_names = result.row_description.as_json if column_names.empty?
        end

As a workaround we are overriding the Vertica::Query#handle command complete method to return the metadata info.

To make an Unbuffered Query

class Vertica::Query
  private

  def handle_command_complete(message)
    if buffer_rows?
      @result = Vertica::Result.new(row_description: @row_description, rows: @buffer, tag: message.tag)
      @row_description = nil
      @buffer = nil
    else
      @result = Vertica::Result.new(row_description: @row_description, rows: [], tag: message.tag)
    end
  end
end

Refer Issues with Previous Version: #69

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions