Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
santosh-1987 opened this issue Aug 19, 2020 · 0 comments

Comments

@santosh-1987
Copy link

santosh-1987 commented Aug 19, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant