Skip to content

bug: unable to create table columns of type UUID in Python SDK #14825

@avik-ionix

Description

@avik-ionix

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

Unable to create a Table Column with the UUID type provided by the SDK. SDK version 0.1.16

Expected Behavior

Should be able to create a UUID type using the SDK.

CloudQuery (redacted) config

kind: source
spec:
  name: "azure"
  registry: "grpc"
  path: "localhost:8888"
  version: "v1.0.0"
  destinations: ["postgresql"]
  tables:
    ["a_single_col"]
  deterministic_cq_id: true

Steps To Reproduce

  1. Create a simple Source Plugin with the following table class:
from cloudquery.sdk.schema import Column, Table
from cloudquery.sdk.scheduler import TableResolver
from cloudquery.sdk.types import UUIDType
from plugin.client import Client
from typing import Any, Generator
import uuid

CQ_ID_COLUMN_NAME = "_cq_id"


class ASingleColTable(Table):
    def __init__(self) -> None:
        super().__init__(
            name="a_single_col",
            title="",
            columns=[
                Column(name=CQ_ID_COLUMN_NAME, type=UUIDType()),
            ],
        )

    @property
    def resolver(self):
        return ASingleColTableResolver(self)


class ASingleColTableResolver(TableResolver):
    def __init__(self, table: Table) -> None:
        super().__init__(table=table)

    def resolve(self, client: Client, parent_resource) -> Generator[Any, None, None]:
        yield {
            CQ_ID_COLUMN_NAME: uuid.UUID(int=0)
        }
  1. run cloudquery sync specifying the table name in the source.yaml

CloudQuery (redacted) logs


2023-10-23T08:23:16Z [info     ] Starting server                address=[::]:8888
2023-10-23T08:23:21Z [info     ] table resolver started         client_id=azure_extra_tables depth=0 table=a_single_col
2023-10-23T08:23:21Z [error    ] table resolver finished with error client_id=azure_extra_tables depth=0 resources=0 table=a_single_col
Traceback (most recent call last):
  File "/Users/.../projects/plugin-sdk-python/cloudquery/sdk/scheduler/scheduler.py", line 120, in resolve_table
    res.put(SyncInsertMessage(resource.to_arrow_record()))
                              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/../projects/plugin-sdk-python/cloudquery/sdk/schema/resource.py", line 27, in to_arrow_record
    return pa.record_batch(
           ^^^^^^^^^^^^^^^^
  File "pyarrow/table.pxi", line 5178, in pyarrow.lib.record_batch
  File "pyarrow/table.pxi", line 2615, in pyarrow.lib.RecordBatch.from_arrays
  File "pyarrow/table.pxi", line 1449, in pyarrow.lib._sanitize_arrays
  File "pyarrow/array.pxi", line 357, in pyarrow.lib.asarray
  File "pyarrow/array.pxi", line 327, in pyarrow.lib.array
  File "pyarrow/array.pxi", line 39, in pyarrow.lib._sequence_to_array
  File "pyarrow/error.pxi", line 144, in pyarrow.lib.pyarrow_internal_check_status
  File "pyarrow/error.pxi", line 123, in pyarrow.lib.check_status
pyarrow.lib.ArrowTypeError: Expected bytes, got a 'UUID' object

CloudQuery version

cloudquery version 3.17.1

Additional Context

No response

Pull request (optional)

  • I can submit a pull request

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions