rename_field Action

Implement the rename_field DoAction to support renaming fields within STRUCT columns in your Arrow Flight server tables.

The rename_field action renames a field within a nested STRUCT column in a table. This action is invoked when executing an ALTER TABLE ... RENAME COLUMN SQL statement that targets a field within a struct.

SQL Example

-- Rename a field within a nested struct column
ALTER TABLE example.main.employees RENAME COLUMN address.zip_code TO address.postal_code;
ALTER TABLE example.main.employees RENAME COLUMN metadata.created_at TO metadata.timestamp;

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 AirportAlterTableRenameFieldParameters : AirportAlterBase
{
  //! Path to source field
  std::vector<std::string> column_path;
  //! Column new name
  std::string new_name;

  MSGPACK_DEFINE_MAP(catalog, schema, name, column_path, new_name);
};

Return Value

The action must return a single FlightInfo structure representing the modified table with the field renamed within the struct column. The app_metadata field must be populated appropriately to identify the flight as a table.