@qualithm/arrow-flight-client - v0.1.4
    Preparing search index...

    Class FlightSqlClient

    Arrow Flight SQL client for executing SQL queries and managing transactions.

    FlightSqlClient wraps FlightClient using composition, providing Flight SQL specific operations while delegating core Flight RPC to the underlying client.

    const client = new FlightSqlClient({ url: "https://flight.example.com:8815" })

    // Execute a query and get results as a Table
    const table = await client.query("SELECT * FROM users")
    console.log(`Got ${table.numRows} rows`)

    // Execute an update
    const result = await client.executeUpdate("INSERT INTO users (name) VALUES ('Alice')")
    console.log(`Inserted ${result.recordCount} rows`)

    // Use prepared statements
    const stmt = await client.prepare("SELECT * FROM users WHERE id = ?")
    // ... bind parameters and execute ...
    await client.closePreparedStatement(stmt)

    client.close()
    Index

    Constructors

    Accessors

    Methods

    • Authenticate with the server using configured credentials.

      Returns Promise<string | undefined>

    • Begin a new transaction.

      Returns Promise<Transaction>

      Transaction handle

      const txn = await client.beginTransaction()
      try {
      await client.executeUpdate("INSERT INTO users ...", { transactionId: txn.id })
      await client.executeUpdate("INSERT INTO logs ...", { transactionId: txn.id })
      await client.commit(txn)
      } catch (e) {
      await client.rollback(txn)
      throw e
      }
    • Execute a prepared query statement and return results as a Table.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      Returns Promise<Table<T>>

      Arrow Table containing query results

    • Execute a prepared query statement and return results as a stream.

      Parameters

      Returns AsyncGenerator<FlightData>

      FlightData messages

    • Execute a prepared update statement and return affected row count.

      Parameters

      • statement: PreparedStatement

        Prepared statement from prepare()

      • Optionalparameters: AsyncIterable<RecordBatch<any>, any, any> | Iterable<RecordBatch<any>, any, any>

        Optional parameter values as RecordBatches

      Returns Promise<UpdateResult>

      Update result with affected row count

    • Execute a SQL update statement (INSERT, UPDATE, DELETE, DDL).

      Parameters

      Returns Promise<UpdateResult>

      Update result with affected row count

      const result = await client.executeUpdate("DELETE FROM users WHERE inactive = true")
      console.log(`Deleted ${result.recordCount} inactive users`)
    • Get the list of catalogs in the database.

      Type Parameters

      • T extends TypeMap = TypeMap

      Returns Promise<Table<T>>

      Arrow Table with catalog_name column

      const catalogs = await client.getCatalogs()
      for (const row of catalogs) {
      console.log(row.catalog_name)
      }
    • Get the list of database schemas.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      • Optionaloptions: { catalog?: string; dbSchemaFilterPattern?: string }

        Filter options

        • Optionalcatalog?: string

          Filter by catalog name

        • OptionaldbSchemaFilterPattern?: string

          Filter pattern for schema names (supports % and _ wildcards)

      Returns Promise<Table<T>>

      Arrow Table with catalog_name and db_schema_name columns

      const schemas = await client.getDbSchemas({ catalog: "my_catalog" })
      
    • Get the primary keys for a table.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      • table: string

        Table name (required)

      • Optionaloptions: { catalog?: string; dbSchema?: string }

        Additional filter options

        • Optionalcatalog?: string

          Catalog containing the table

        • OptionaldbSchema?: string

          Schema containing the table

      Returns Promise<Table<T>>

      Arrow Table with catalog_name, db_schema_name, table_name, column_name, key_name, key_sequence columns

      const keys = await client.getPrimaryKeys("users", { catalog: "my_db" })
      
    • Get FlightInfo for a SQL query without executing it.

      Use this to inspect the query plan, schema, or endpoints before fetching data.

      Parameters

      Returns Promise<FlightInfo>

      FlightInfo describing the query results

    • Get the list of tables.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      • Optionaloptions: {
            catalog?: string;
            dbSchemaFilterPattern?: string;
            includeSchema?: boolean;
            tableNameFilterPattern?: string;
            tableTypes?: string[];
        }

        Filter options

        • Optionalcatalog?: string

          Filter by catalog name

        • OptionaldbSchemaFilterPattern?: string

          Filter pattern for schema names (supports % and _ wildcards)

        • OptionalincludeSchema?: boolean

          Include table schema in results

        • OptionaltableNameFilterPattern?: string

          Filter pattern for table names (supports % and _ wildcards)

        • OptionaltableTypes?: string[]

          Filter by table types (e.g., "TABLE", "VIEW")

      Returns Promise<Table<T>>

      Arrow Table with catalog_name, db_schema_name, table_name, table_type columns

      const tables = await client.getTables({ tableTypes: ["TABLE", "VIEW"] })
      
    • Get the list of table types supported by the server.

      Type Parameters

      • T extends TypeMap = TypeMap

      Returns Promise<Table<T>>

      Arrow Table with table_type column

      const tableTypes = await client.getTableTypes()
      // Common types: TABLE, VIEW, SYSTEM TABLE
    • Prepare a SQL statement for repeated execution.

      Parameters

      • query: string

        SQL query with optional parameter placeholders

      • OptionaltransactionId: Uint8Array<ArrayBufferLike>

        Optional transaction to associate with the statement

      Returns Promise<PreparedStatement>

      Prepared statement handle

      const stmt = await client.prepare("SELECT * FROM users WHERE id = ?")
      // Use executePrepared() to execute with parameters
      await client.closePreparedStatement(stmt)
    • Execute a SQL query and return results as an Arrow Table.

      This is a convenience method that combines getFlightInfo and doGet to fetch all query results into memory.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      Returns Promise<Table<T>>

      Arrow Table containing query results

      const table = await client.query("SELECT * FROM users WHERE active = true")
      console.log(`Found ${table.numRows} active users`)
    • Execute a SQL query and return results as a stream of RecordBatches.

      Use this for large result sets to avoid loading all data into memory.

      Type Parameters

      • T extends TypeMap = TypeMap

      Parameters

      Returns AsyncGenerator<RecordBatch<T>>

      RecordBatch objects

      for await (const batch of client.queryBatches("SELECT * FROM large_table")) {
      processBatch(batch)
      }
    • Execute a SQL query and return the raw FlightData stream.

      This is the lowest-level query method, useful when you need access to raw Flight data or custom decoding.

      Parameters

      Returns AsyncGenerator<FlightData>

      FlightData messages