class TrinoRestClient
Trino REST client (POST /v1/statement + poll of nextUri). Returns a compact metrics hash for execution_histories.metrics. Commit conflicts raised by the engine are surfaced as TrinoRuntime::CommitConflict so the retry machine can act on them.
Constants
- COMMIT_CONFLICT_PATTERN
- MAX_POLL_SECONDS
- POLL_INTERVAL
Public Class Methods
# File app/services/trino_rest_client.rb, line 18 def initialize(endpoint:, transport: HttpTransport.new) @endpoint = endpoint @transport = transport end
Creates the client with an endpoint and injectable transport.
@param endpoint [String] the Trino coordinator URL @param transport [HttpTransport] the HTTP transport
Public Instance Methods
# File app/services/trino_rest_client.rb, line 30 def execute(sql, execution_id:, execution: nil, step: nil) first = statement(sql, execution_id: execution_id) capture_query_id(step, first) poll(first, execution_id: execution_id, execution: execution, step: step) .merge("execution_history_id" => execution_id, "query_id" => first["id"]) end
Executes SQL against Trino and polls until it finishes.
@param sql [String] the query @param execution_id [Integer] the execution id for tracking @param execution [ExecutionHistory, nil] the execution for heartbeats @param step [ExecutionStep, nil] the step being run, for query id/progress @return [Hash] the metrics payload
# File app/services/trino_rest_client.rb, line 44 def query_rows(sql, execution_id:) first = statement(sql, execution_id: execution_id) poll_rows(first, execution_id: execution_id) end
Executes SQL and returns the actual data rows, for helper queries where the values matter (e.g. reading distinct partition values before batching an OPTIMIZE). Unlike execute it does not strip the rows into a count.
@param sql [String] the query @param execution_id [Integer] the execution id for headers @return [Array<Array>] the data rows