Skip to content

Missing "name" attribute under <Column> class #62

@adrivn

Description

@adrivn

After updating to 0.11 and running our pipelines as usual an error printed:

  File "C:\Users\adrivn\Projects\etl\config\functions.py", line 271, in write_to_table
    f'"{col_name}" {col.data_type.ddl()}' for col_name, col in pg_schema.columns
                                              ^^^^^^^^^^^^^
TypeError: cannot unpack non-iterable pgpq._pgpq.Column object

After inspection, I ran a test with dummy data and noticed that the Column class does have "data_type" and "nullable" attributes but "name" has gone missing, for some reason.

import polars as pl
from pgpq import ArrowToPostgresBinaryEncoder

test_sch = pl.from_dict({"a": [1,2,3], "words": ["hey", "test", "this"]})

dataset = test_sch.to_arrow()
encoder = ArrowToPostgresBinaryEncoder(dataset.schema)

pg_schema = encoder.schema()

first = next(iter(pg_schema.columns))
print(type(first), dir(first))

Prints:

<class 'pgpq._pgpq.Column'> ['__class__', '__delattr__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'data_type', 'nullable']

Am I looking at this the wrong way?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions