Repository navigation
Conversation
Add `client.datasources.sample()` and `TinybirdApi.sampleDatasource()`,
porting the Python SDK's `sample_datasource` to match `tb datasource
sample`. POSTs to `/v0/datasources/{name}/sample` with
`{max_files, full_export, rows?, max_bytes?}`; `rows` and `maxBytes`
are mutually exclusive (DynamoDB-only options) and raise when both
are provided.
Closes PROTM-2267.
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
jalbertsr
approved these changes
Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
sampleDatasourcemethod toTinybirdApi(src/api/api.ts) that POSTs to/v0/datasources/{datasourceName}/samplewith{max_files, full_export, rows?, max_bytes?}, mirroring the raw HTTP shape used bytb datasource sample.client.datasources.sample(datasourceName, options)inTinybirdClient(src/client/base.ts), following the sameappend/delete/truncatepattern (resolve token → call API layer → rethrowTinybirdApiErrorasTinybirdError).SampleOptions/SampleResulttypes tosrc/client/types.tsandTinybirdApiSampleOptionstosrc/api/api.ts, all exported fromsrc/index.ts.sample_datasourcewith this exact request shape.Closes https://linear.app/tinybird/issue/PROTM-2267/typescript-sdk-add-bounded-sampling-api-for-s3gcsdynamodb-datasources
Design notes
TinybirdApi.sampleDatasource/client.datasources.sample, matching the existingappendDatasource/client.datasources.append,deleteDatasource/client.datasources.delete, etc. pairing.maxFiles,maxBytes,fullExport) at the TS API surface, matching this SDK's existing convention (e.g.deleteCondition,dryRun), while the JSON body sent over the wire uses the Python SDK's snake_case field names (max_files,full_export,rows,max_bytes) to match the Tinybird API contract exactly.rowsandmaxBytesare mutually exclusive (DynamoDB-only): passing both throws synchronously before any request is made, matching the Python SDK'sValueErrorbehavior (ported as a plainError, consistent with this SDK's other client-side validation like the missing-deleteConditioncheck).maxFilesdefaults to1,fullExportdefaults tofalse.Out of scope
tinybird datasource sample) — the issue only asked for the SDK-level API, matching how other datasource operations (delete/truncate) were added without CLI commands.maxFilesbounds (e.g. max 10) — left to the Tinybird API to enforce and return as an error, same as the Python SDK.Test plan
pnpm typecheckpnpm test:run(1072 tests passing, including newsampleDatasourcecoverage insrc/api/api.test.tsfor defaults,maxFiles, DynamoDBrows, DynamoDBmaxBytes,fullExport, the mutual-exclusion error, and per-request token override)pnpm build🤖 Generated with Claude Code