Module materialize.data_ingest.row

Expand source code Browse git
# Copyright Materialize, Inc. and contributors. All rights reserved.
#
# Use of this software is governed by the Business Source License
# included in the LICENSE file at the root of this repository.
#
# As of the Change Date specified in that file, in accordance with
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0.

from enum import Enum
from typing import Any

from materialize.data_ingest.field import Field


class Operation(Enum):
    INSERT = 1
    UPSERT = 2
    DELETE = 3


class Row:
    fields: list[Field]
    values: list[Any]
    operation: Operation

    def __init__(self, fields: list[Field], values: list[Any], operation: Operation):
        self.fields = fields
        self.values = values
        self.operation = operation

    def __repr__(self) -> str:
        return f"Row({self.fields}, {self.values}, {self.operation})"

Classes

class Operation (*args, **kwds)

Create a collection of name/value pairs.

Example enumeration:

>>> class Color(Enum):
...     RED = 1
...     BLUE = 2
...     GREEN = 3

Access them by:

  • attribute access::
>>> Color.RED
<Color.RED: 1>
  • value lookup:
>>> Color(1)
<Color.RED: 1>
  • name lookup:
>>> Color['RED']
<Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

>>> len(Color)
3
>>> list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Expand source code Browse git
class Operation(Enum):
    INSERT = 1
    UPSERT = 2
    DELETE = 3

Ancestors

  • enum.Enum

Class variables

var DELETE
var INSERT
var UPSERT
class Row (fields: list[Field], values: list[typing.Any], operation: Operation)
Expand source code Browse git
class Row:
    fields: list[Field]
    values: list[Any]
    operation: Operation

    def __init__(self, fields: list[Field], values: list[Any], operation: Operation):
        self.fields = fields
        self.values = values
        self.operation = operation

    def __repr__(self) -> str:
        return f"Row({self.fields}, {self.values}, {self.operation})"

Class variables

var fields : list[Field]
var operationOperation
var values : list[typing.Any]