MCPcopy
hub / github.com/pathwaycom/pathway / column_definition

Function column_definition

python/pathway/internals/schema.py:756–827  ·  view source on GitHub ↗

Creates column definition Args: primary_key: should column be a part of a primary key. default_value: default value replacing blank entries. The default value of the column must be specified explicitly, otherwise there will be no default value. dt

(
    *,
    primary_key: bool = False,
    default_value: Any | None = _no_default_value_marker,
    dtype: Any | None = None,
    name: str | None = None,
    append_only: bool | None = None,
    description: str | None = None,
    example: Any = None,
    source_component: Literal["key", "payload"] = "payload",
    _serialized_default_value: Any | None = None,
    _serialized_example: Any | None = None,
)

Source from the content-addressed store, hash-verified

754
755
756def column_definition(
757 *,
758 primary_key: bool = False,
759 default_value: Any | None = _no_default_value_marker,
760 dtype: Any | None = None,
761 name: str | None = None,
762 append_only: bool | None = None,
763 description: str | None = None,
764 example: Any = None,
765 source_component: Literal["key", "payload"] = "payload",
766 _serialized_default_value: Any | None = None,
767 _serialized_example: Any | None = None,
768) -> Any: # Return any so that mypy does not complain
769 """Creates column definition
770
771 Args:
772 primary_key: should column be a part of a primary key.
773 default_value: default value replacing blank entries. The default value of the
774 column must be specified explicitly,
775 otherwise there will be no default value.
776 dtype: data type. When used in schema class,
777 will be deduced from the type annotation.
778 name: name of a column. When used in schema class,
779 will be deduced from the attribute name.
780 append_only: whether column is append-only. if unspecified, defaults to False
781 or to value specified at the schema definition level
782 description: human-readable description for the column. Used by HTTP input
783 connector in automated OpenAPI schema generation.
784 example: example of the column value. Used by HTTP input connector in automated
785 OpenAPI schema generation.
786 source_component: the part of the input message from which the value should be
787 parsed when JSON format is used. In Kafka, this can be used to specify that
788 certain fields must be parsed from the message key.
789
790 Returns:
791 Column definition.
792
793 Example:
794
795 >>> import pathway as pw
796 >>> class NewSchema(pw.Schema):
797 ... key: int = pw.column_definition(primary_key=True)
798 ... timestamp: str = pw.column_definition(name="@timestamp")
799 ... data: str
800 >>> NewSchema
801 <pathway.Schema types={'key': <class 'int'>, '@timestamp': <class 'str'>, 'data': <class 'str'>}, \
802id_type=pathway.engine.Pointer[int]>
803 """
804
805 if _serialized_default_value is not None:
806 if not isinstance(default_value, _Undefined):
807 raise ValueError(
808 "Maximum one of {'default_value', '_serialized_default_value'} must be specified"
809 )
810 default_value = api.deserialize(base64.b64decode(_serialized_default_value))
811 if _serialized_example is not None:
812 if example is not None:
813 raise ValueError(

Callers 4

schema_from_pandasFunction · 0.85
create_column_definitionFunction · 0.85
schema_from_csvFunction · 0.85

Calls 3

ColumnDefinitionClass · 0.85
wrapMethod · 0.80
deserializeMethod · 0.45

Tested by

no test coverage detected