-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathserver_action_add_field.qmd
More file actions
47 lines (35 loc) · 1.55 KB
/
server_action_add_field.qmd
File metadata and controls
47 lines (35 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
---
title: "`add_field` Action"
description: "Implement the add_field DoAction to support adding fields to STRUCT columns in your Arrow Flight server tables."
---
The `add_field` action adds a new field to a nested `STRUCT` column within a table. This action is invoked when executing an `ALTER TABLE ... ADD COLUMN` SQL statement that targets a field within a struct.
## SQL Example
```sql
-- Add a field to a nested struct column
ALTER TABLE example.main.employees ADD COLUMN address.city VARCHAR;
ALTER TABLE example.main.employees ADD COLUMN IF NOT EXISTS metadata.created_by VARCHAR;
```
## Input Parameters
The action receives a single `msgpack`-serialized parameter:
```c++
// 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 AirportAlterTableAddFieldParameters : AirportAlterBase
{
// Contains the path to the field and the Arrow type for the new field.
std::string column_schema;
bool if_field_not_exists;
MSGPACK_DEFINE_MAP(catalog, schema, name, ignore_not_found, if_field_not_exists, column_schema);
};
```
## Return Value
The action must return a single [`FlightInfo`](https://github.com/apache/arrow/blob/ac1f05f28e18e85ee55cf7aaf3c8ae1ffe0e92d7/format/Flight.proto#L275) structure representing the modified table with the new field added to the struct column. The `app_metadata` field must be populated appropriately to identify the flight as a table.