GetSqlInfo
capability metadata instead of assuming that the server implements every Flight
SQL operation.
Query and metadata commands
GetFlightInfo validates and plans a SQL statement, then returns an opaque
ticket. DoGet executes that ticket and streams Arrow record batches.
Prepared statements
A prepared statement is read-only and has this lifecycle:- The
CreatePreparedStatementaction returns a handle. DoPutonCommandPreparedStatementQuerybinds parameter values. ItsDoPutPreparedStatementResultreturns a new handle that carries them. Send that handle on every later call.- The
ClosePreparedStatementaction ends the statement.
DoPut returns. An older client that keeps the
first handle runs the statement without its values, and the statement fails.
Use prepared statements when query values come from users or another untrusted
source. Transactions, savepoints, and prepared writes are not supported.
Sample a table
TABLESAMPLE reads a sample of a table or a subquery, in the form Postgres,
Snowflake and Databricks share:
- A row is kept when a hash of all its values and the seed, read as a fraction from 0 to 1, is below the percentage. The same seed keeps the same rows of the same data, whatever the query reads around it, so two samples of one table in one query keep the same rows.
BERNOULLI,ROW,SYSTEMandBLOCKall sample rows. A size without a unit is a percentage.(n ROWS)keeps thenrows with the lowest hash.BUCKET k OUT OF nkeeps the rows in thek-th ofnequal ranges, so thenbuckets hold every row once.- Without
REPEATABLEorSEED, the seed is 0, so a query that samples returns the same rows each time. Postgres picks a new seed each time instead. OFFSETandBUCKET ... ONare refused.
LATERAL subqueries
ALATERAL subquery reads columns of the tables before it in FROM. The
engine plans it as a join, so it works when the join is clear:
- Write it as
JOIN LATERAL (...) x ON ...,LEFT JOIN LATERAL (...) x ON ..., or after a comma, as inFROM teams t, LATERAL (...) x. - Use the outer columns only in comparisons in the subquery’s own
WHEREclause. The comparison can be=,>, or another operator, and it can useANDandOR. - The subquery can use
DISTINCT,GROUP BY,HAVINGwithGROUP BY,ORDER BY, and aggregates such ascount(*). A team with no people gets the count 0, as in Postgres.
INVALID_ARGUMENT and error code QL-PL-012 when:
- The subquery reads an outer column in its
SELECTlist, inGROUP BY, in aUNIONbranch, or in a subquery nested inside it. - The subquery has a
LIMIT. LATERALis in aRIGHTorFULLjoin.- The subquery’s own
SELECThas an aggregate and aHAVINGclause but noGROUP BY, and the join is notLEFT. A table that the subquery joins, or a scalar subquery in itsWHEREclause, can still useHAVINGwith noGROUP BY.
WHERE clause, or join the tables
directly. For a HAVING clause, move its condition into the join’s ON
clause, as in JOIN LATERAL (SELECT count(*) AS n ...) x ON x.n > 1, or add
GROUP BY.
Show the plan of a query
EXPLAIN followed by a SELECT returns the plan Parable would use for the
query, and runs nothing:
- The answer has two columns,
plan_typeandplan, and two rows: onelogical_planrow and onephysical_planrow. - The physical plan names each step, its partitions and its keys. It shows no storage path and no filter condition, because a filter can hold a Policy’s condition.
- The plan holds no cost information.
EXPLAIN ANALYZEruns the query, so it fails withINVALID_ARGUMENTand error codeQL-SQ-008.EXPLAIN VERBOSE, aFORMAToption,EXPLAIN QUERY PLANandDESCRIBEof a query fail withINVALID_ARGUMENTand error codeQL-SQ-009.
Unsupported operations
The SQL surface does not support:- Writes, ingestion, or transactions.
DoExchange, orDoPutfor anything but binding prepared statement parameters.ListFlightsorPollFlightInfo.- Transaction, savepoint, or cancellation actions.
UNIMPLEMENTED. ListActions returns an
empty stream because the server does not advertise actions proactively.
Handshake is accepted and does nothing, so JDBC drivers that call it on
connect work; authentication comes from the authorization metadata on every
call.
Primary and foreign-key commands return logical metadata. They do not make the
underlying tables enforce constraints.