Skip to content

fix(api): name the multipart field after the detected format in append_datasource - #36

Open
RaphaelFakhri wants to merge 1 commit into
tinybirdco:mainfrom
RaphaelFakhri:fix/append-datasource-multipart-field-name
Open

RaphaelFakhri wants to merge 1 commit into
tinybirdco:mainfrom
RaphaelFakhri:fix/append-datasource-multipart-field-name

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

append_datasource now names the multipart form field after the detected file format (csv, ndjson or parquet). Fixes #23.

Problem

When you pass a local file, append_datasource always sent the file under the form field csv. The Tinybird API requires the field name to be ndjson or parquet for those formats, so uploads of .ndjson, .jsonl and .parquet files failed with NDJSON/Parquet multipart requests require name field set to 'ndjson'/'parquet'.

Fix

The multipart field name is detected_format or "csv". The format detection already existed and already set the format query parameter. Files with an unrecognized extension keep the csv field name.

Testing

A new parametrized test in tests/test_api_parity.py uploads .csv, .ndjson, .jsonl, .parquet and .dat files and checks the field name in the multipart body. The .ndjson, .jsonl and .parquet cases fail on the previous code and pass now. make lint, make typecheck and make test pass.

Checklist

  • CI checks (lint, typecheck, test) pass locally
  • Tests were added
  • No public API or typing changes
  • CHANGELOG.md was updated

…d_datasource

append_datasource always sent local files under the csv form field. The API requires the field name to be ndjson or parquet for those formats, so NDJSON and Parquet uploads failed. Use the format detected from the file extension and keep csv as the fallback.

Closes tinybirdco#23

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: append_datasource hardcodes multipart form field name to 'csv', breaking Parquet and NDJSON file uploads

1 participant