Connect With Arrow Flight SQL
Arrow Flight SQL takes a SQL statement and streams back its result as Arrow. It suits Python data tools, SQL clients such as DBeaver, and Tableau Desktop. You send one read-only statement over the project’s tables, and PlaidCloud filters every table it reads to the rows the client’s owner may see before it runs. Before you connect, create a BI feed client and add it to the project, or create a personal access token to read as yourself; see Connect BI Tools.
Connection Details
Section titled “Connection Details”| Setting | Value |
|---|---|
| Endpoint | grpc+tls://flightsql.<workspace host>:443 |
| JDBC URL | jdbc:arrow-flight-sql://flightsql.<workspace host>:443/?useEncryption=true&project_id=<project id> |
| User name | The client ID, or your email address with a token |
| Password | The client secret, or the token |
| Project | project_id: part of the JDBC URL, or the ADBC option adbc.flight.sql.rpc.call_header.project_id |
The project’s JDBC URL is on the BI feed clients card of its Access & sharing page, ready to copy. The connection is always encrypted, on port 443. With a token, use your email address and the token as the user name and password in the examples below, in place of the client ID and secret.
A connection reads one project. To read another, connect again with that project’s ID.
Python
Section titled “Python”Install the ADBC Flight SQL driver with pip install adbc-driver-flightsql pyarrow, then connect with the client’s ID and secret, here read from environment variables:
import os
import adbc_driver_flightsql.dbapi as flightsql
with flightsql.connect( "grpc+tls://flightsql.<workspace host>:443", db_kwargs={ "username": os.environ["PLAIDCLOUD_CLIENT_ID"], "password": os.environ["PLAIDCLOUD_CLIENT_SECRET"], "adbc.flight.sql.rpc.call_header.project_id": "<project id>", }, autocommit=True,) as connection, connection.cursor() as cursor: cursor.execute( 'SELECT region, SUM(amount) AS total FROM "Sales" WHERE fiscal_year = ? GROUP BY region', parameters=(2024,), ) sales = cursor.fetch_arrow_table()The feed runs no transactions, so connect with autocommit=True. sales is an Arrow table:
- pandas:
sales.to_pandas() - polars:
polars.from_arrow(sales) - DuckDB: query it by its name, as in
duckdb.sql("SELECT * FROM sales")
For a large result, cursor.fetch_record_batch() reads it a batch at a time instead of all at once.
DBeaver
Section titled “DBeaver”DBeaver doesn’t include the Apache Arrow Flight SQL driver, so add it once:
- Choose Database > Driver Manager > New.
- Name the driver, for example
Arrow Flight SQL, and set Class Name toorg.apache.arrow.driver.jdbc.ArrowFlightJdbcDriver. - On Libraries, choose Add Artifact and enter
org.apache.arrow:flight-sql-jdbc-driver, or choose Add File and pick the driver’s.jarfile. Choose OK.
Then connect:
- Choose Database > New Database Connection and pick the driver you added.
- Connect by URL: paste the project’s JDBC URL, then enter the client ID as the user name and the secret as the password.
- Choose Finish. The project’s tables are in the
plaidschema.
In your own Java program, start Java with --add-opens=java.base/java.nio=ALL-UNNAMED. Without it, the driver connects and runs plain statements, but a statement with ? parameters fails with sun.misc.Unsafe or java.nio.DirectByteBuffer.<init>(long, int) not available. DBeaver already starts with that option.
Tableau Desktop and Tableau Server
Section titled “Tableau Desktop and Tableau Server”- Download the Apache Arrow Flight SQL JDBC driver (
flight-sql-jdbc-driver, a.jarfile) and put it in Tableau’s drivers folder:C:\Program Files\Tableau\Driverson Windows, or~/Library/Tableau/Driverson a Mac. Then restart Tableau. - Under Connect, choose To a Server > Other Databases (JDBC).
- Enter the project’s JDBC URL as the URL, choose PostgreSQL as the Dialect, enter the client ID and secret as Username and Password, and choose Sign In.
- The project’s tables are in the
plaidschema.
To refresh a published workbook or data source, Tableau Server needs the same driver installed in its own drivers folder.
The SQL You Can Send
Section titled “The SQL You Can Send”The feed reads PostgreSQL-style SQL and accepts one read-only statement at a time:
- One statement: a
SELECT, aWITH … SELECT, or aUNION,INTERSECTorEXCEPTof them. A recursiveWITHis refused. - The project’s tables, by name: write a table’s name on its own, or in the
plaidschema, as inplaid."Sales". Any other schema or catalog is refused. - Quoting: a name without quotes matches whatever its case, as
salesmatchesSales. A quoted name must match exactly; quote a name with spaces or punctuation, as in"Sales 2024"or"Cost Center Name". - The usual clauses: joins, subqueries,
GROUP BY,HAVING,ORDER BY,LIMIT,OFFSET,FETCH,DISTINCT,CASE,CASTand window functions. - Functions: the common text, number, date, aggregate and window functions, including
UPPER,LOWER,TRIM,SUBSTRING,REPLACE,CONCAT,ROUND,ABS,COALESCE,NULLIF,EXTRACT,DATE_TRUNC,CURRENT_DATE,COUNT,SUM,AVG,MIN,MAX,ROW_NUMBER,RANK,LAGandLEAD. - Parameters:
?markers, each given a number, text, true or false, a date, a timestamp, or NULL. - Length: up to 65,536 characters, with its parameters written in.
Empty values sort the way the project’s warehouse sorts them. Write NULLS FIRST or NULLS LAST when the order matters.
Quote a column named like a word a warehouse knows about the session or the clock, as in "user" or "current_date". Without quotes, the word may not read your column: the feed may refuse it, or the warehouse may read the session’s own value, as current_date reads today’s date. user, system_user, current_role, current_database, sysdate and systimestamp are always refused without quotes, with a message asking you to quote them.
The feed refuses anything that writes or locks (INSERT, UPDATE, DELETE, MERGE, SELECT … INTO), VALUES, UNNEST, LATERAL, reading files, time travel, TABLESAMPLE, PIVOT, and any function outside its list. A refusal starts with “Nothing was run:” and names what it refused, so you can rewrite that part.
What Clients See
Section titled “What Clients See”- Schema: one schema,
plaid, with no catalog. - Tables: the project’s tables shown to the client’s role, by their names in the project. Two names that differ only in case each get an underscore and a short code made from their table. Views aren’t included.
- Columns: by their names in the project, spaces included, as in
"FULL YEAR"or"Cost Center Name". This differs from OData, which showsFULL_YEAR. - Keys: a table’s update keys are its primary key, and a table with none has no primary key. Tables have no foreign keys.
Timestamps arrive in UTC.
Limits and Messages
Section titled “Limits and Messages”There’s no row cap: a result streams until it ends. Sign-in messages are listed in Connect BI Tools. These are particular to Flight SQL:
| Message | What to do |
|---|---|
| Name the project to read with the project_id connection property … | Add project_id to the JDBC URL, or set the ADBC option adbc.flight.sql.rpc.call_header.project_id. |
| This session reads another project. Connect again to read this one. | A connection reads one project. Open another connection for the other project. |
| This session has ended. Connect again. | A connection’s session ends after 8 hours unused, and 24 hours after it began. Connect again. |
| This client was disabled or its secret has changed since this session began. Connect again. | Connect again with the current secret. If the client was disabled, enable it first. A deleted client, or one whose owner’s account is disabled, can’t connect. |
| The statement ran past the gateway’s 3,600-second limit and was stopped. | One statement can run for an hour at most. Filter or aggregate it to return less. |
| Nothing was run: … | The statement holds something the feed doesn’t accept; see The SQL You Can Send. |
| The warehouse could not run the statement: … | The project’s warehouse refused the statement, for the reason given. |