add_column Action

Implement the add_column DoAction to support ALTER TABLE ADD COLUMN statements in your Arrow Flight server.

The add_column action adds a new column to an existing table. This action is invoked when executing an ALTER TABLE ... ADD COLUMN SQL statement.

SQL Example

ALTER TABLE example.main.employees ADD COLUMN department VARCHAR;
ALTER TABLE example.main.employees ADD COLUMN IF NOT EXISTS salary INTEGER;

Input Parameters

The action receives a single msgpack-serialized parameter:

// The base class for all alter parameters.
struct AirportAlterBase
{
  //! Catalog name to alter
  std::string catalog;
  //! Schema name to alter
  std::string schema;
  //! Entry name to alter
  std::string name;
  bool ignore_not_found;
};

struct AirportAlterTableAddColumnParameters : AirportAlterBase
{
  // This is a serialized Arrow schema with the column_name
  // and the arrow type of the column.
  std::string column_schema;
  bool if_column_not_exists;

  MSGPACK_DEFINE_MAP(catalog, schema, name, ignore_not_found, if_column_not_exists, column_schema);
};

Return Value

The action must return a single FlightInfo structure representing the modified table with the new column included in its schema. The app_metadata field must be populated appropriately to identify the flight as a table.