{"title":"Arrow Flight SQL","description":"High-performance streaming analytics with Arrow Flight SQL. Built on Apache Arrow, ideal for dbt, Airbyte, and large datasets.","order":820,"askSuggestions":["Why can't my Flight SQL client connect?","How do I run prepared statements from Python?","How do I list catalogs and tables from the Python client?"],"navigation":true,"routeId":"queryDataArrowFlightSql","body":{"code":"var Component=(()=>{var m=Object.create;var c=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var S=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),A=(t,e)=>{for(var i in e)c(t,i,{get:e[i],enumerable:!0})},h=(t,e,i,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let r of b(e))!w.call(t,r)&&r!==i&&c(t,r,{get:()=>e[r],enumerable:!(a=f(e,r))||a.enumerable});return t};var x=(t,e,i)=>(i=t!=null?m(y(t)):{},h(e||!t||!t.__esModule?c(i,\"default\",{value:t,enumerable:!0}):i,t)),q=t=>h(c({},\"__esModule\",{value:!0}),t);var u=S((E,d)=>{d.exports=_jsx_runtime});var L={};A(L,{default:()=>g,frontmatter:()=>_});var n=x(u()),_={title:\"Arrow Flight SQL\",routeId:\"queryDataArrowFlightSql\",description:\"High-performance streaming analytics with Arrow Flight SQL. Built on Apache Arrow, ideal for dbt, Airbyte, and large datasets.\",order:820,askSuggestions:[\"Why can't my Flight SQL client connect?\",\"How do I run prepared statements from Python?\",\"How do I list catalogs and tables from the Python client?\"]};function p(t){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",h4:\"h4\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...t.components},{CodeSnippet:i,DocsPreviewDocument:a,DocsPreviewSection:r,DocsSdkCodeTabs:s,DocsTable:l}=e;return i||o(\"CodeSnippet\",!0),a||o(\"DocsPreviewDocument\",!0),r||o(\"DocsPreviewSection\",!0),s||o(\"DocsSdkCodeTabs\",!0),l||o(\"DocsTable\",!0),(0,n.jsxs)(a,{anchors:\"arrow-flight-sql goal prerequisites steps 1-configure-the-endpoint 2-configure-authentication 3-run-your-first-query 4-use-the-python-client prepared-statements transactions metadata-queries 5-connect-another-client verification troubleshooting next-steps\",children:[(0,n.jsxs)(r,{sectionId:\"arrow-flight-sql\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,n.jsx)(e.h1,{id:\"arrow-flight-sql\",children:\"Arrow Flight SQL\"}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"goal\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,n.jsx)(e.h2,{id:\"goal\",children:\"Goal\"}),`\n`,(0,n.jsx)(e.p,{children:\"Connect an Arrow Flight SQL client to Altertable over TLS, run a query, and confirm that the client can stream Arrow record batches.\"}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"prerequisites\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,n.jsx)(e.h2,{id:\"prerequisites\",children:\"Prerequisites\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[\"Your \",(0,n.jsx)(e.a,{href:\"/docs/administration/lakehouse-credentials\",children:\"lakehouse username and password\"}),\".\"]}),`\n`,(0,n.jsx)(e.li,{children:\"An Arrow Flight SQL-compatible client.\"}),`\n`,(0,n.jsx)(e.li,{children:\"Access to at least one table you can query.\"}),`\n`]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"steps\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,n.jsx)(e.h2,{id:\"steps\",children:\"Steps\"}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"1-configure-the-endpoint\",anchors:\"\",ancestors:\"steps\",index:\"4\",children:[(0,n.jsx)(e.h3,{id:\"1-configure-the-endpoint\",children:\"1. Configure the endpoint\"}),`\n`,(0,n.jsx)(l,{columns:[\"Hostname\",\"Port\"],data:[{Hostname:\"`flight.altertable.ai`\",Port:\"443 (TLS/SSL)\"}]}),`\n`,(0,n.jsxs)(e.p,{children:[(0,n.jsx)(e.a,{href:\"https://arrow.apache.org/docs/format/FlightSql.html\",children:\"Arrow Flight SQL\"}),\" provides the highest-performance interface for streaming large analytical datasets between Altertable and your tools. Built on Apache Arrow's columnar format, it's ideal for:\"]}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Analytics tools\"}),\" like dbt, Airbyte, and custom data pipelines\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Large result sets\"}),\" that benefit from efficient columnar data transfer\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"High-throughput workloads\"}),\" requiring minimal serialization overhead\"]}),`\n`]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"2-configure-authentication\",anchors:\"\",ancestors:\"steps\",index:\"5\",children:[(0,n.jsx)(e.h3,{id:\"2-configure-authentication\",children:\"2. Configure authentication\"}),`\n`,(0,n.jsx)(e.p,{children:\"Use your Altertable credentials with any Arrow Flight SQL client:\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Username\"}),\": Your lakehouse username\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Password\"}),\": Your lakehouse password\"]}),`\n`]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"3-run-your-first-query\",anchors:\"\",ancestors:\"steps\",index:\"6\",children:[(0,n.jsx)(e.h3,{id:\"3-run-your-first-query\",children:\"3. Run your first query\"}),`\n`,(0,n.jsx)(s,{category:\"sql\",languageIds:[\"arrow-flight\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"4-use-the-python-client\",anchors:\"\",ancestors:\"steps\",index:\"7\",children:[(0,n.jsx)(e.h3,{id:\"4-use-the-python-client\",children:\"4. Use the Python client\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Altertable provides an official Python client library (\",(0,n.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:(0,n.jsx)(e.code,{children:\"altertable-flightsql\"})}),\") that handles authentication, connection management, queries, prepared statements, transactions, and metadata operations.\"]}),`\n`,(0,n.jsx)(e.p,{children:\"Install the package:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-bash\",children:`pip install altertable-flightsql\n`})}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"prepared-statements\",anchors:\"\",ancestors:\"steps 4-use-the-python-client\",index:\"8\",children:[(0,n.jsx)(e.h4,{id:\"prepared-statements\",children:\"Prepared statements\"}),`\n`,(0,n.jsx)(e.p,{children:\"Prepare a statement once and execute it multiple times with different parameters:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-python\",children:`with client.prepare(\"SELECT * FROM users WHERE id = $id\") as stmt:\n    result = stmt.query(parameters={\"id\": 1})\n    for batch in result:\n        print(batch.data.to_pandas())\n`})}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"transactions\",anchors:\"\",ancestors:\"steps 4-use-the-python-client\",index:\"9\",children:[(0,n.jsx)(e.h4,{id:\"transactions\",children:\"Transactions\"}),`\n`,(0,n.jsx)(e.p,{children:\"Execute multiple statements atomically:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-python\",children:`with client.begin_transaction():\n    client.execute(\"INSERT INTO users ...\")\n    client.execute(\"UPDATE accounts ...\")\n`})}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"metadata-queries\",anchors:\"\",ancestors:\"steps 4-use-the-python-client\",index:\"10\",children:[(0,n.jsx)(e.h4,{id:\"metadata-queries\",children:\"Metadata queries\"}),`\n`,(0,n.jsx)(e.p,{children:\"Discover catalogs, schemas, and tables:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-python\",children:`catalogs = client.get_catalogs()\nschemas = client.get_schemas(catalog=\"my_db\")\ntables = client.get_tables(catalog=\"my_db\", schema_pattern=\"main\")\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"For more details, examples, and advanced usage, see the \",(0,n.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:\"GitHub repository\"}),\".\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"5-connect-another-client\",anchors:\"\",ancestors:\"steps\",index:\"11\",children:[(0,n.jsx)(e.h3,{id:\"5-connect-another-client\",children:\"5. Connect another client\"}),`\n`,(0,n.jsxs)(e.p,{children:[\"Any Arrow Flight SQL-compatible client can connect to \",(0,n.jsx)(e.code,{children:\"flight.altertable.ai:443\"}),\" with TLS.\"]}),`\n`,(0,n.jsx)(e.p,{children:(0,n.jsx)(e.strong,{children:\"Python ADBC\"})}),`\n`,(0,n.jsx)(i,{language:\"python\",children:`import adbc_driver_flightsql.dbapi as flight_sql\n\nconn = flight_sql.connect(\nuri=\"grpc+tls://flight.altertable.ai:443\",\ndb_kwargs={\n\"username\": \"{{LAKEHOUSE_USERNAME}}\",\n\"password\": \"{{LAKEHOUSE_PASSWORD}}\"\n}\n)\n\ncursor = conn.cursor()\ncursor.execute(\"SELECT * FROM your_database.your_schema.your_table LIMIT 10\")\nresults = cursor.fetchall()`}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"verification\",anchors:\"\",ancestors:\"\",index:\"12\",children:[(0,n.jsx)(e.h2,{id:\"verification\",children:\"Verification\"}),`\n`,(0,n.jsx)(e.p,{children:\"Run a query that does not depend on an existing table:\"}),`\n`,(0,n.jsx)(e.pre,{children:(0,n.jsx)(e.code,{className:\"language-python\",children:`from altertable_flightsql import Client\n\nwith Client(\n    username=\"{{LAKEHOUSE_USERNAME}}\",\n    password=\"{{LAKEHOUSE_PASSWORD}}\",\n) as client:\n    for batch in client.query(\"SELECT 1 AS connected\"):\n        print(batch.data.to_pandas())\n`})}),`\n`,(0,n.jsxs)(e.p,{children:[\"The result should contain one \",(0,n.jsx)(e.code,{children:\"connected\"}),\" column with the value \",(0,n.jsx)(e.code,{children:\"1\"}),\".\"]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"troubleshooting\",anchors:\"\",ancestors:\"\",index:\"13\",children:[(0,n.jsx)(e.h2,{id:\"troubleshooting\",children:\"Troubleshooting\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"Authentication fails:\"}),\" copy the lakehouse username and password from the same environment again.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"The TLS connection fails:\"}),\" connect to \",(0,n.jsx)(e.code,{children:\"flight.altertable.ai:443\"}),\" and keep TLS enabled.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"A table cannot be found:\"}),\" use \",(0,n.jsx)(e.code,{children:\"get_catalogs()\"}),\", \",(0,n.jsx)(e.code,{children:\"get_schemas()\"}),\", and \",(0,n.jsx)(e.code,{children:\"get_tables()\"}),\" to confirm its fully qualified name.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.strong,{children:\"A generic client cannot connect:\"}),\" confirm that it supports Arrow Flight SQL rather than only the Arrow in-memory format.\"]}),`\n`]}),`\n`]}),(0,n.jsxs)(r,{sectionId:\"next-steps\",anchors:\"\",ancestors:\"\",index:\"14\",children:[(0,n.jsx)(e.h2,{id:\"next-steps\",children:\"Next steps\"}),`\n`,(0,n.jsxs)(e.ul,{children:[`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.a,{href:\"/docs/lakehouse/query/http-api\",children:\"Query with the HTTP API\"}),\" when HTTPS and JSONL fit the integration better.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[(0,n.jsx)(e.a,{href:\"/docs/lakehouse/clients\",children:\"Connect a BI tool\"}),\" through Arrow Flight SQL or the Postgres adapter.\"]}),`\n`,(0,n.jsxs)(e.li,{children:[\"See the \",(0,n.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:\"Python client repository\"}),\" for advanced examples.\"]}),`\n`]})]})]})}function g(t={}){let{wrapper:e}=t.components||{};return e?(0,n.jsx)(e,{...t,children:(0,n.jsx)(p,{...t})}):p(t)}function o(t,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+t+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return q(L);})();\n;return Component;"},"_id":"docs/lakehouse/clients/arrow-flight-sql.mdx","_raw":{"sourceFilePath":"docs/lakehouse/clients/arrow-flight-sql.mdx","sourceFileName":"arrow-flight-sql.mdx","sourceFileDir":"docs/lakehouse/clients","contentType":"mdx","flattenedPath":"docs/lakehouse/clients/arrow-flight-sql"},"type":"Docs","path":"/lakehouse/clients/arrow-flight-sql","level":3,"parent":"lakehouse/clients"}