Class: DruidClient::Api::Sql
- Defined in:
- lib/druid_client/api/sql.rb
Constant Summary collapse
- SQL_PATH =
'/druid/v2/sql'- QUERY_RESULT_FORMATS =
%i[object array objectLines arrayLines csv].freeze
- QUERY_RESULT_FORMAT =
QUERY_RESULT_FORMATS.first
- QUERY_HEADER =
true- QUERY_TYPES_HEADER =
true- QUERY_SQL_TYPES_HEADER =
true- QUERY_PARAMETERS =
[].freeze
- QUERY_CONTEXT =
{}.freeze
Instance Method Summary collapse
- #cancel_query(query_id:) ⇒ Object
- #query(query:, result_format: QUERY_RESULT_FORMAT, header: QUERY_HEADER, types_header: QUERY_TYPES_HEADER, sql_types_header: QUERY_SQL_TYPES_HEADER, parameters: QUERY_PARAMETERS, context: QUERY_CONTEXT) ⇒ Object
Methods inherited from Resource
Constructor Details
This class inherits a constructor from DruidClient::Api::Resource
Instance Method Details
#cancel_query(query_id:) ⇒ Object
41 42 43 |
# File 'lib/druid_client/api/sql.rb', line 41 def cancel_query(query_id:) delete("#{SQL_PATH}/#{query_id}") end |
#query(query:, result_format: QUERY_RESULT_FORMAT, header: QUERY_HEADER, types_header: QUERY_TYPES_HEADER, sql_types_header: QUERY_SQL_TYPES_HEADER, parameters: QUERY_PARAMETERS, context: QUERY_CONTEXT) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/druid_client/api/sql.rb', line 22 def query(query:, result_format: QUERY_RESULT_FORMAT, header: QUERY_HEADER, types_header: QUERY_TYPES_HEADER, sql_types_header: QUERY_SQL_TYPES_HEADER, parameters: QUERY_PARAMETERS, context: QUERY_CONTEXT) query_body = { query: query.to_s, parameters: parameters.to_a, resultFormat: result_format.to_s, header: header, typesHeader: header && types_header, sqlTypesHeader: header && sql_types_header, context: context.to_h } post(SQL_PATH, body: query_body) end |