Version:

/execute/sql

URL: http://GPUDB_IP_ADDRESS:GPUDB_PORT/execute/sql

SQL Request

Input Parameter Description

Name Type Description
statement string SQL statement (query, DML, or DDL) to be executed
offset long A positive integer indicating the number of initial results to skip (this can be useful for paging through the results). The default value is 0.The minimum allowed value is 0. The maximum allowed value is MAX_INT.
limit long A positive integer indicating the maximum number of results to be returned, or END_OF_SET (-9999) to indicate that the maximum number of results allowed by the server should be returned. The number of records returned will never exceed the server's own limit, defined by the max_get_records_size parameter in the server configuration. Use output parameter has_more_records to see if more records exist in the result to be fetched, and input parameter offset & input parameter limit to request subsequent pages of results. The default value is -9999.
encoding string

Specifies the encoding for returned records; either 'binary' or 'json'. The default value is binary. The supported values are:

  • binary
  • json
request_schema_str string Avro schema of input parameter data. The default value is ''.
data array of bytes An array of binary-encoded data for the records to be binded to the SQL query. The default value is an empty array ( [] ).
options map of string to strings

Optional parameters. The default value is an empty map ( {} ).

Supported Parameters (keys) Parameter Description
parallel_execution

If false, disables the parallel step execution of the given query. The default value is true. The supported values are:

  • true
  • false
cost_based_optimization

If false, disables the cost-based optimization of the given query. The default value is false. The supported values are:

  • true
  • false
plan_cache

If false, disables plan caching for the given query. The default value is true. The supported values are:

  • true
  • false
rule_based_optimization

If false, disables rule-based rewrite optimizations for the given query The default value is true. The supported values are:

  • true
  • false
results_caching

If false, disables caching of the results of the given query The default value is true. The supported values are:

  • true
  • false
paging_table When empty or the specified paging table not exists, the system will create a paging table and return when query output has more records than the user asked. If the paging table exists in the system, the records from the paging table are returned without evaluating the query.
paging_table_ttl Sets the TTL of the paging table.
distributed_joins

If true, enables the use of distributed joins in servicing the given query. Any query requiring a distributed join will succeed, though hints can be used in the query to change the distribution of the source data to allow the query to succeed. The default value is false. The supported values are:

  • true
  • false
distributed_operations

If true, enables the use of distributed operations in servicing the given query. Any query requiring a distributed join will succeed, though hints can be used in the query to change the distribution of the source data to allow the query to succeed. The default value is false. The supported values are:

  • true
  • false
ssq_optimization

If false, scalar subqueries will be translated into joins The default value is true. The supported values are:

  • true
  • false
late_materialization

If true, Joins/Filters results will always be materialized ( saved to result tables format) The default value is false. The supported values are:

  • true
  • false
ttl Sets the TTL of the intermediate result tables used in query execution.
update_on_existing_pk

Can be used to customize behavior when the updated primary key value already exists as described in /insert/records. The default value is false. The supported values are:

  • true
  • false
preserve_dict_encoding

If true, then columns that were dict encoded in the source table will be dict encoded in the projection table. The default value is true. The supported values are:

  • true
  • false
validate_change_column

When changing a column using alter table, validate the change before applying it. If true, then validate all values. A value too large (or too long) for the new type will prevent any change. If false, then when a value is too large or long, it will be truncated. The default value is true.

Supported Values Description
true true
false false
prepare_mode

If true, compiles a query into an execution plan and saves it in query cache. Query execution is not performed and an empty response will be returned to user The default value is false. The supported values are:

  • true
  • false
view_id <DEVELOPER> The default value is ''.
no_count <DEVELOPER> The default value is 'false'.

Output Parameter Description

The GPUdb server embeds the endpoint response inside a standard response structure which contains status information and the actual response to the query. Here is a description of the various fields of the wrapper:

Name Type Description
status String 'OK' or 'ERROR'
message String Empty if success or an error message
data_type String 'execute_sql_request' or 'none' in case of an error
data String Empty string
data_str JSON or String

This embedded JSON represents the result of the /execute/sql endpoint:

Name Type Description
count_affected long The number of objects/records affected.
response_schema_str string Avro schema of output parameter binary_encoded_response or output parameter json_encoded_response.
binary_encoded_response bytes Avro binary encoded response.
json_encoded_response string Avro JSON encoded response.
total_number_of_records long Total/Filtered number of records.
has_more_records boolean

Too many records. Returned a partial set. Possible values are:

  • true
  • false
paging_table string Name of the table that has the result records of the query. Valid, when output parameter has_more_records is true (Subject to config.paging_tables_enabled)
info map of string to strings

Additional information. The default value is an empty map ( {} ).

Possible Parameters (keys) Parameter Description
count Number of records in the final table

Empty string in case of an error.