Skip to content

schemas

Arrow Flight schema definitions.

count

count()

Create an Arrow Flight schema for count.

Returns:

Type Description
Schema

The count schema.

Source code in arrakis/schemas.py
60
61
62
63
64
65
66
67
68
69
def count() -> pyarrow.Schema:
    """Create an Arrow Flight schema for `count`.

    Returns
    -------
    pyarrow.Schema
        The count schema.

    """
    return pyarrow.schema([pyarrow.field("count", pyarrow.int64())])

metadata

metadata(scope=None)

Create an Arrow Flight metadata schema.

Parameters:

Name Type Description Default
scope None | str

Metadata scope, currently accepts only None or "partition".

None

Returns:

Type Description
Schema

The metadata schema.

Source code in arrakis/schemas.py
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
def metadata(scope: str | None = None) -> pyarrow.Schema:
    """Create an Arrow Flight metadata schema.

    Parameters
    ----------
    scope : None | str
        Metadata scope, currently accepts only None or "partition".

    Returns
    -------
    pyarrow.Schema
        The metadata schema.

    """
    fields = [
        "name",
        "data_type",
        "sample_rate",
    ]
    if scope == "partition":
        fields.extend([
            "partition_id",
            "partition_index",
        ])
    else:
        fields.extend([
            "publisher",
            "partition_id",
            "partition_index",
        ])
    return pyarrow.schema([METADATA_FIELDS[field] for field in fields])

publish

publish()

Create an Arrow Flight schema for publish.

Returns:

Type Description
Schema

The publish schema.

Source code in arrakis/schemas.py
 96
 97
 98
 99
100
101
102
103
104
105
106
def publish() -> pyarrow.Schema:
    """Create an Arrow Flight schema for `publish`.

    Returns
    -------
    pyarrow.Schema
        The publish schema.

    """
    dtype = pyarrow.map_(pyarrow.string(), pyarrow.string())
    return pyarrow.schema([pyarrow.field("properties", dtype, nullable=False)])

stream

stream(channels)

Create an Arrow Flight schema for stream.

Parameters:

Name Type Description Default
channels Iterable[Channel]

The list of channels for the stream request.

required

Returns:

Type Description
Schema

The stream schema.

Source code in arrakis/schemas.py
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
def stream(channels: Iterable[Channel]) -> pyarrow.Schema:
    """Create an Arrow Flight schema for `stream`.

    Parameters
    ----------
    channels : Iterable[Channel]
        The list of channels for the stream request.

    Returns
    -------
    pyarrow.Schema
        The stream schema.

    """
    columns = [pyarrow.field("time", pyarrow.int64(), nullable=False)]
    for channel in channels:
        dtype = pyarrow.from_numpy_dtype(channel.data_type)
        field = pyarrow.field(channel.name, pyarrow.list_(dtype)).with_metadata(
            {"rate": str(channel.sample_rate)}
        )
        columns.append(field)
    return pyarrow.schema(columns)