Learn the SQL scripting rules and limitations for query-type (Get/List) and operation-type (Create/Update/Delete) APIs.
Get/List (query type)
-
Supported query features:
-
Single-table queries, multi-table joins (JOIN), and nested queries (subqueries) are supported within the same data source.
-
Advanced SQL mode (MyBatis style) is supported.
-
Parameters are supported in
SELECTstatements. For example:SELECT id_card, SUM(CASE WHEN id_card LIKE ${id_card} THEN 1 ELSE 0 END) AS proj_score FROM table WHERE c LIKE ${id_card} GROUP BY id_card.
-
-
Unsupported syntax and usage:
-
Multiple SQL query statements: Multiple SQL statements in a single API are not supported, such as
SELECT ...; SELECT ...;. -
Non-DQL statements:
ListandGetAPIs do not support non-DQL statements such asINSERT,UPDATE,CREATE, andDELETE. -
SELECT *:
SELECT *queries are not allowed. Explicitly specify the columns to query. -
Column name prefixes: If a column name includes a table prefix (for example,
t.name), you must use an alias as the response parameter name. For example:SELECT t.name AS name FROM table. -
Aggregate functions: Aggregate functions such as
SUM(),COUNT(),MAX(), andMIN()require an alias as the response parameter name. For example:SELECT SUM(num) AS total_num FROM table. -
Do not include pagination statements in the SQL script. Use pagination parameters instead.
Note-
If the data source is SAP HANA, use pagination statements in SQL and define pagination parameters to implement pagination.
-
For TDengine data sources, you must use a pagination statement in the SQL script. If pagination parameters such as
PageStartandPageSizeare not provided, all data is returned. If they are provided, data is paginated according to the specified values.
-
-
-
In advanced SQL mode, dynamic field queries let you dynamically specify response fields by using parameters.
-
Parameter format: The parameter name must start with
var_cols_and follow the formatvar_cols_xxx, such asvar_cols_args. For example:SELECT id, ${var_cols_args} FROM table1. -
Response parameters: All supported dynamic query fields must be declared as response parameters.
-
Calling an API: Pass the fields to query in the dynamic parameters. Fields that are not passed return null in the response. For example:
var_cols_args=name,age,dept. -
Actual execution: The resulting SQL statement is:
SELECT id, name, age, dept FROM table1.
-
-
In advanced SQL mode, comparison operators in MyBatis SQL must be escaped.
Original operator
Escaped operator
<<>><=<=>=>= -
Data source-specific limitations:
Data source
Limitations
TDengine
-
You must use
LIMIT/OFFSETin SQL to implement pagination. -
Optional parameters are not supported.
SAP HANA
-
Pagination is not supported. The
PageStartandPageSizeparameters have no effect. -
Optional parameters are not supported.
Elasticsearch
-
Elasticsearch uses
ScrollIdfor deep pagination. Without aScrollId, only the first 10,000 records can be retrieved using thePageStartandPageSizeparameters. Retrieving records beyond this limit causes the API call to fail.For example, if
PageStartis set to9998, the maximum value forPageSizeis2. -
To query data beyond the first 10,000 records, specify a
scrollIdin theWHEREclause. Define ascrollIdrequest parameter when developing the API and pass the correspondingscrollIdvalue in your request.NoteWhen querying with a
scrollId, standard pagination is not available. Do not pass values forPageStartandPageSize, or the call will fail. -
The
WHEREclause only supportsscrollIdas a condition. Other fields in the clause are ignored.For example:
select a from table where scrollId=${scrollId}. -
Subqueries are not supported.
HBase
-
Only single
rowkeyqueries are supported, where rowkey is a required request parameter. The query syntax is:select info1.id as name from table where rowkey = ${rowkey} -
The
ORDER BYclause is not supported. -
Pagination is not supported. The
PageStartandPageSizeparameters have no effect. -
The
JOINstatement is not supported.
PostgreSQL
Cross-schema queries are not supported. Only data within the current connection's schema can be queried.
Impala
Advanced SQL mode (MyBatis style) is not supported.
Lindorm
JOINstatements are not supported.DolphinDB
Native DolphinDB mode is not supported. To use DolphinDB, create a data source and set its SQL compatibility mode to either Oracle or MySQL.
ImportantModifying the compatibility mode of a data source may cause unpredictable errors in existing APIs. Adjust this setting based on your business requirements.
GBase 8a
The
QUALIFYclause is not supported in basic SQL mode.OpenSearch
-
Simple subqueries are supported, but multi-level nested
INsubqueries may not execute correctly.For example:
SELECT ... WHERE age IN (SELECT age FROM ... WHERE age IN (18,39));. -
Running a JDBC query with a subquery that contains
JOINmay return an empty result set.For example:
SELECT ... FROM (SELECT ... FROM t1 LEFT JOIN t2 ON ...) e1 WHERE ...;. -
The
WITHsyntax for common table expressions is not supported.For example:
WITH test_with AS (...) SELECT ...;. -
UNIONandUNION ALLstatements are not supported, even if they are included in a subquery.For example:
SELECT id FROM (SELECT id FROM t1 UNION SELECT id FROM t2) t;. -
The
COALESCEsyntax has compatibility issues with the current JDBC driver. Use theCASE WHENsyntax as an alternative.Replace
SELECT COALESCE(id, 0) FROM ...;withSELECT CASE WHEN id IS NULL THEN 0 ELSE id END FROM ...;. -
Using a
CASE WHENexpression with aJOINclause may cause field parsing failures or missing columns. Verify syntax compatibility before building complex queries.For example:
SELECT CASE WHEN a.id= ... END FROM t1 a JOIN t2 b ON ...;.
Hive
The query engine for Hive tables depends on the table format: the Spark engine queries data lake tables (such as Iceberg or Hudi), while the Hive engine queries regular tables (such as ORC, Parquet, or TextFile).
-
Create/Update/Delete (operation type)
-
Supported SQL modes:
-
Basic SQL mode: Supports standard
INSERT,UPDATE, andDELETEstatements. Uses the${param}placeholder to pass parameters. Suitable for simple scenarios. -
Advanced SQL mode (MyBatis style): Use this mode for complex logic such as conditional statements, dynamic fields, and batch operations. The following tags are supported:
<if>, <choose>, <when>, <otherwise>, <trim>, <foreach>
-
-
Batch operations in advanced SQL mode process records individually, which can degrade performance. Avoid using this mode for batch create, update, or delete APIs whenever possible.
-
If an SQL statement contains an
incondition parameter, each record is executed separately, which degrades performance. Avoid using theincondition parameter. -
Only PostgreSQL supports the
RETURNINGclause.