change_column_type Action

Implement the change_column_type DoAction to support ALTER TABLE ALTER COLUMN TYPE statements for changing column data types.

The change_column_type action changes the data type of an existing column in a table. This action is invoked when executing an ALTER TABLE ... ALTER COLUMN ... TYPE SQL statement.

SQL Example

ALTER TABLE example.main.employees ALTER COLUMN salary TYPE BIGINT;
ALTER TABLE example.main.employees ALTER COLUMN email TYPE VARCHAR USING CAST(email AS VARCHAR);

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 AirportAlterTableChangeColumnTypeParameters : AirportAlterBase
{
  std::string column_schema;
  std::string expression;

  MSGPACK_DEFINE_MAP(catalog, schema, name, column_schema, expression);
};

Return Value

The action must return a single FlightInfo structure representing the modified table with the column’s type changed. The app_metadata field must be populated appropriately to identify the flight as a table.