Skip to content

Insert record example missing schema #4

Description

@jesseVast

In https://vast-data.github.io/data-platform-field-docs/vast_database/sdk_ref/manipulation.html#insert, the example code fails with the following error.

2025-02-05 09:27:59,897: errors:from_response:229:WARNING - RPC failed: {'code': 'TabularMismatchColumnType', 'message': 'Mismatched column type between file to import and existing table.', 'method': 'POST', 'url': 'http://main.selab-var204.selab.vastdata.com/jthaloor-db/test2/tbl_1?rows', 'status': 404, 'headers': {'x-amz-id-2': '50131000547d9', 'x-amz-request-id': '50131000547d9', 'Date': 'Wed, 05 Feb 2025 14:27:10 GMT', 'Strict-Transport-Security': 'max-age=86400', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Access-Control-Allow-Origin': '*', 'Transfer-Encoding': 'chunked', 'Server': 'vast 5.2.0.131'}}
Couldn't insert data: {'code': 'TabularMismatchColumnType', 'message': 'Mismatched column type between file to import and existing table.', 'method': 'POST', 'url': 'http://main.selab-var204.selab.vastdata.com/jthaloor-db/test2/tbl_1?rows', 'status': 404, 'headers': {'x-amz-id-2': '50131000547d9', 'x-amz-request-id': '50131000547d9', 'Date': 'Wed, 05 Feb 2025 14:27:10 GMT', 'Strict-Transport-Security': 'max-age=86400', 'X-Content-Type-Options': 'nosniff', 'X-Frame-Options': 'SAMEORIGIN', 'Access-Control-Allow-Origin': '*', 'Transfer-Encoding': 'chunked', 'Server': 'vast 5.2.0.131'}}
<pyarrow.lib.RecordBatchReader object at 0x135ae1f50>

It appears that there is problem with the schema.

ROWS = { 
    'Citizen_Name': ['Alice','Bob'], 'Citizen_Age': [25,24]
}
PA_RECORD_BATCH = pa.RecordBatch.from_pydict(ROWS)

Digging into it, the instance function definition of RecordBatch takes "schema" as one of the arguments. Providing a schema solves the issue.

I think we should always provide a schema to create the recordbatch. Alternatively, we should have the

.insert function automagically infer the schema at runtime.

Versions:
vastdb: 1.3.6
Vast: 5.2 SP10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions