{"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,S=Object.prototype.hasOwnProperty;var w=(n,e)=>()=>(e||n((e={exports:{}}).exports,e),e.exports),T=(n,e)=>{for(var i in e)c(n,i,{get:e[i],enumerable:!0})},h=(n,e,i,a)=>{if(e&&typeof e==\"object\"||typeof e==\"function\")for(let r of b(e))!S.call(n,r)&&r!==i&&c(n,r,{get:()=>e[r],enumerable:!(a=f(e,r))||a.enumerable});return n};var q=(n,e,i)=>(i=n!=null?m(y(n)):{},h(e||!n||!n.__esModule?c(i,\"default\",{value:n,enumerable:!0}):i,n)),x=n=>h(c({},\"__esModule\",{value:!0}),n);var u=w((E,d)=>{d.exports=_jsx_runtime});var _={};T(_,{default:()=>g,frontmatter:()=>A});var t=q(u()),A={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(n){let e={a:\"a\",code:\"code\",h1:\"h1\",h2:\"h2\",h3:\"h3\",li:\"li\",p:\"p\",pre:\"pre\",strong:\"strong\",ul:\"ul\",...n.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,t.jsxs)(a,{anchors:\"arrow-flight-sql prerequisites connect run-your-first-query use-the-python-client prepared-statements transactions metadata-queries connect-another-client troubleshooting next-steps\",children:[(0,t.jsxs)(r,{sectionId:\"arrow-flight-sql\",sectionTitle:\"Arrow Flight SQL\",anchors:\"\",ancestors:\"\",index:\"0\",children:[(0,t.jsx)(e.h1,{id:\"arrow-flight-sql\",children:\"Arrow Flight SQL\"}),`\n`,(0,t.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,t.jsxs)(r,{sectionId:\"prerequisites\",sectionTitle:\"Prerequisites\",anchors:\"\",ancestors:\"\",index:\"1\",children:[(0,t.jsx)(e.h2,{id:\"prerequisites\",children:\"Prerequisites\"}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsxs)(e.li,{children:[\"Your \",(0,t.jsx)(e.a,{href:\"/docs/administration/lakehouse-credentials\",children:\"lakehouse username and password\"}),\".\"]}),`\n`,(0,t.jsx)(e.li,{children:\"An Arrow Flight SQL-compatible client.\"}),`\n`]}),`\n`,(0,t.jsx)(e.p,{children:\"For the Python examples, install the Flight SQL client:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.jsx)(e.code,{className:\"language-bash\",children:`pip install altertable-flightsql\n`})}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"connect\",sectionTitle:\"Connect\",anchors:\"\",ancestors:\"\",index:\"2\",children:[(0,t.jsx)(e.h2,{id:\"connect\",children:\"Connect\"}),`\n`,(0,t.jsx)(l,{columns:[\"Hostname\",\"Port\"],data:[{Hostname:\"`flight.altertable.ai`\",Port:\"443 (TLS/SSL)\"}]}),`\n`,(0,t.jsxs)(e.p,{children:[\"Enable TLS and authenticate with your lakehouse username and password. For Metabase driver configuration, see \",(0,t.jsx)(e.a,{href:\"/docs/integrations/metabase\",children:\"Connect Metabase\"}),\".\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"run-your-first-query\",sectionTitle:\"Run your first query\",anchors:\"\",ancestors:\"\",index:\"3\",children:[(0,t.jsx)(e.h2,{id:\"run-your-first-query\",children:\"Run your first query\"}),`\n`,(0,t.jsx)(e.p,{children:\"Run a query that does not depend on an existing table:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.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 ok\"):\n        print(batch.data.to_pandas())\n`})}),`\n`,(0,t.jsxs)(e.p,{children:[\"The result should contain one \",(0,t.jsx)(e.code,{children:\"ok\"}),\" column with the value \",(0,t.jsx)(e.code,{children:\"1\"}),\".\"]}),`\n`,(0,t.jsx)(s,{category:\"sql\",languageIds:[\"arrow-flight\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"use-the-python-client\",sectionTitle:\"Use the Python client\",anchors:\"\",ancestors:\"\",index:\"4\",children:[(0,t.jsx)(e.h2,{id:\"use-the-python-client\",children:\"Use the Python client\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Altertable provides an official Python client library (\",(0,t.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:(0,t.jsx)(e.code,{children:\"altertable-flightsql\"})}),\") that handles authentication, connection management, queries, prepared statements, transactions, and metadata operations.\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"prepared-statements\",sectionTitle:\"Prepared statements\",anchors:\"\",ancestors:\"use-the-python-client\",index:\"5\",children:[(0,t.jsx)(e.h3,{id:\"prepared-statements\",children:\"Prepared statements\"}),`\n`,(0,t.jsx)(e.p,{children:\"Prepare a statement once and execute it multiple times with different parameters:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.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,t.jsxs)(r,{sectionId:\"transactions\",sectionTitle:\"Transactions\",anchors:\"\",ancestors:\"use-the-python-client\",index:\"6\",children:[(0,t.jsx)(e.h3,{id:\"transactions\",children:\"Transactions\"}),`\n`,(0,t.jsx)(e.p,{children:\"Execute multiple statements atomically:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.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,t.jsxs)(r,{sectionId:\"metadata-queries\",sectionTitle:\"Metadata queries\",anchors:\"\",ancestors:\"use-the-python-client\",index:\"7\",children:[(0,t.jsx)(e.h3,{id:\"metadata-queries\",children:\"Metadata queries\"}),`\n`,(0,t.jsx)(e.p,{children:\"Discover catalogs, schemas, and tables:\"}),`\n`,(0,t.jsx)(e.pre,{children:(0,t.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,t.jsxs)(e.p,{children:[\"For more details, examples, and advanced usage, see the \",(0,t.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:\"GitHub repository\"}),\".\"]}),`\n`]}),(0,t.jsxs)(r,{sectionId:\"connect-another-client\",sectionTitle:\"Connect another client\",anchors:\"\",ancestors:\"\",index:\"8\",children:[(0,t.jsx)(e.h2,{id:\"connect-another-client\",children:\"Connect another client\"}),`\n`,(0,t.jsxs)(e.p,{children:[\"Any Arrow Flight SQL-compatible client can connect to \",(0,t.jsx)(e.code,{children:\"flight.altertable.ai:443\"}),\" with TLS.\"]}),`\n`,(0,t.jsx)(e.p,{children:(0,t.jsx)(e.strong,{children:\"Python ADBC\"})}),`\n`,(0,t.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,t.jsxs)(r,{sectionId:\"troubleshooting\",sectionTitle:\"Troubleshooting\",anchors:\"\",ancestors:\"\",index:\"9\",children:[(0,t.jsx)(e.h2,{id:\"troubleshooting\",children:\"Troubleshooting\"}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:\"Authentication fails:\"}),\" copy the lakehouse username and password from the same environment again.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:\"The TLS connection fails:\"}),\" connect to \",(0,t.jsx)(e.code,{children:\"flight.altertable.ai:443\"}),\" and keep TLS enabled.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[(0,t.jsx)(e.strong,{children:\"A table cannot be found:\"}),\" use \",(0,t.jsx)(e.code,{children:\"get_catalogs()\"}),\", \",(0,t.jsx)(e.code,{children:\"get_schemas()\"}),\", and \",(0,t.jsx)(e.code,{children:\"get_tables()\"}),\" to confirm its fully qualified name.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[(0,t.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,t.jsxs)(r,{sectionId:\"next-steps\",sectionTitle:\"Next steps\",anchors:\"\",ancestors:\"\",index:\"10\",children:[(0,t.jsx)(e.h2,{id:\"next-steps\",children:\"Next steps\"}),`\n`,(0,t.jsxs)(e.ul,{children:[`\n`,(0,t.jsxs)(e.li,{children:[(0,t.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,t.jsxs)(e.li,{children:[(0,t.jsx)(e.a,{href:\"/docs/integrations/metabase\",children:\"Connect Metabase\"}),\" through Arrow Flight SQL or the Postgres adapter.\"]}),`\n`,(0,t.jsxs)(e.li,{children:[\"See the \",(0,t.jsx)(e.a,{href:\"https://github.com/altertable-ai/altertable-flightsql-python\",children:\"Python client repository\"}),\" for advanced examples.\"]}),`\n`]})]})]})}function g(n={}){let{wrapper:e}=n.components||{};return e?(0,t.jsx)(e,{...n,children:(0,t.jsx)(p,{...n})}):p(n)}function o(n,e){throw new Error(\"Expected \"+(e?\"component\":\"object\")+\" `\"+n+\"` to be defined: you likely forgot to import, pass, or provide it.\")}return x(_);})();\n;return Component;"},"_id":"docs/lakehouse/query/arrow-flight-sql.mdx","_raw":{"sourceFilePath":"docs/lakehouse/query/arrow-flight-sql.mdx","sourceFileName":"arrow-flight-sql.mdx","sourceFileDir":"docs/lakehouse/query","contentType":"mdx","flattenedPath":"docs/lakehouse/query/arrow-flight-sql"},"type":"Docs","path":"/lakehouse/query/arrow-flight-sql","level":3,"parent":"lakehouse/query"}