Skip to content

Commit

Permalink
Merge pull request #61 from treasure-data/implement_query_id
Browse files Browse the repository at this point in the history
Implement `StatementClient#query_id`
  • Loading branch information
yui-knk authored Jan 22, 2020
2 parents 01fa867 + 2b692ca commit 6f3f236
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/presto/client/statement_client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ def current_results_headers
@results_headers
end

def query_id
@results.id
end

def has_next?
!!@results.next_uri
end
Expand Down
16 changes: 16 additions & 0 deletions spec/statement_client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
q.current_results_headers["X-Test-Header"].should == "123"
end

describe "#query_id" do
it "returns query_id" do
stub_request(:post, "localhost/v1/statement").
with(body: query).to_return(body: response_json2.to_json, headers: {"X-Test-Header" => "123"})

stub_request(:get, "localhost/v1/next_uri").
to_return(body: response_json.to_json, headers: {"X-Test-Header" => "123"})

sc = StatementClient.new(faraday, query, options.merge(http_open_timeout: 1))
sc.query_id.should == "queryid"
sc.has_next?.should be_true
sc.advance.should be_true
sc.query_id.should == "queryid"
end
end

describe '#query_info' do
let :headers do
{
Expand Down

0 comments on commit 6f3f236

Please sign in to comment.