create_table Action

Implement the create_table DoAction to support CREATE TABLE statements with schemas, constraints, and default values.

The create_table action creates a new table in the database with the specified schema and constraints. This action is invoked when executing a CREATE TABLE SQL statement.

SQL Example

CREATE TABLE example.main.employees (
  id INTEGER,
  name VARCHAR,
  email VARCHAR UNIQUE,
  salary INTEGER CHECK (salary > 0)
);

CREATE OR REPLACE TABLE example.main.orders AS SELECT * FROM source_table;

Input Parameters

The action receives a single msgpack-serialized parameter:

struct AirportCreateTableParameters
{
  string catalog_name;
  string schema_name;
  string table_name;

  // The serialized Arrow schema for the table.
  string arrow_schema;

  // This will be "error", "ignore", or "replace"
  string on_conflict;

  // The list of constraint expressions.
  vector<uint64_t> not_null_constraints;
  vector<uint64_t> unique_constraints;
  vector<string> check_constraints;

  MSGPACK_DEFINE_MAP(
    catalog_name, schema_name,
    table_name, arrow_schema,
    on_conflict, not_null_constraints,
    unique_constraints, check_constraints)
};

Return Value

The action must return a single FlightInfo structure representing the newly created table. This flight can be used to query and retrieve the table’s contents. The app_metadata field must be populated appropriately to identify the flight as a table.