Example #1
0
class DataSet(struct.Schema):
    """Testing schema.

    The actual fields are irrelevant.
    """

    feature: struct.Field = struct.Field(kind.Integer())
    label: struct.Field = struct.Field(kind.Float())
Example #2
0
    def schema(self) -> typing.Type['struct.Schema']:
        """Get the schema type for this source.

        Returns:
            Schema type.
        """
        return Table.Schema(
            f'{self.__class__.__name__}Schema',
            (struct.Schema.schema,),
            {(c.name or f'_{i}'): struct.Field(c.kind, c.name) for i, c in enumerate(self.columns)},
        )
Example #3
0
    class Human(struct.Schema):
        """Human schema representation."""

        name = struct.Field(kind.String())
        age = struct.Field(kind.Integer())
Example #4
0
    class School(struct.Schema):
        """School table."""

        sid = struct.Field(kind.Integer(), 'id')
        name = struct.Field(kind.String())
Example #5
0
class Demo(struct.Schema):
    """Demo schema representation."""

    Label = struct.Field(kind.Integer())
    Age = struct.Field(kind.Integer())
Example #6
0
    class Person(struct.Schema):
        """Base table."""

        surname = struct.Field(kind.String())
        dob = struct.Field(kind.Date(), 'birthday')
Example #7
0
    class Student(person):
        """Extended table."""

        level = struct.Field(kind.Integer())
        score = struct.Field(kind.Float())
        school = struct.Field(kind.Integer())
Example #8
0
        class Child(Base):
            """Child schema - adding a field "last" plus overriding kind of the "fixme" field."""

            last = struct.Field(kind.Integer())
            fixme = struct.Field(kind.String(), name='new')
Example #9
0
        class Base(struct.Schema):
            """Base schema."""

            first = struct.Field(kind.Integer())
            fixme = struct.Field(kind.Float(), name='old')
Example #10
0
        class Override(schema):
            """Schema with overridden field kind."""

            school = struct.Field(kind.String())
Example #11
0
            class Colliding(schema):
                """Schema with colliding field names."""

                birthday = struct.Field(kind.Integer())
Example #12
0
class HelloWorld(struct.Schema):
    """Base table."""

    name = struct.Field(kind.String())