Skip to main content

Class GPUdbRecordType

class gpudb.GPUdbRecordType(columns: List[GPUdbRecordColumn] = None, label=, schema_string=None, column_properties: List[str] = None)[source]

Represent the data type for a given record in GPUdb. Has convenience functions for creating the type in GPUdb (among others).

Create a GPUdbRecordType object which represents the data type for a given record for GPUdb.

Parameters

columns (list) –

A list of GPUdbRecordColumn objects. Either this argument or the schema_string argument must be given.

label (str) –

Optional string label for the column.

schema_string (str) –

The JSON string containing the schema for the type. Either this argument or the columns argument must be given.

column_properties (dict) –

Optional dict that lists the properties for the columns of the type. Meant to be used in conjunction with schema_string only; will be ignored if columns is given.

property columns

A list of columns for the record type.

property column_names

A list of the names of the columns for the record type.

property label

A label for the record type.

property schema_string

The schema string for the record type.

property base_definition

The bare column definition for the record type, as the compact JSON list of [name, type] pairs that the server’s request_schema_str insertion option expects; a column that is nullable carries a third “nullable” entry.

Only the base (avro) type of each column is listed–any sub-type or other property, such as ‘timestamp’ or ‘char8’, is left out, since this describes the payload being sent rather than the table it is being sent to.

Declaring this on an insertion tells the server which columns the records actually carry. A column of the target table that is absent from the list is populated by the server from its own default value (‘default’, ‘init_with_now’ or ‘init_with_uuid’), which is how a record can omit a column altogether.

property record_schema

The avro schema for the record type.

property record_type

The RecordType object for the record type.

property column_properties

The properties for the type’s columns.

property type_id

The ID for the type, if it has already been registered with GPUdb.

create_type(gpudb, options=None)[source]

Create the record type in GPUdb so that users can create tables using this type.

Parameters

gpudb (GPUdb) –

A GPUdb object to connect to a GPUdb server.

option (dict) –

Optional dictionary containing options for the /create/type call.

Returns

The type ID.

get_column(column_id)[source]

Return the desired column; fetch by name or index.

Parameters

column_id (str or int) –

If string, then the name of the column. If an integer, then the index of the column. Must be a valid column name or be within bounds.

Returns

The GPUdbRecordColumn object pertaining to the desired column.