Skip to content

Preserve non-param template helpers#156

Merged
gnzjgo merged 3 commits into
mainfrom
feat/optional-output-fields-147
May 18, 2026
Merged

Preserve non-param template helpers#156
gnzjgo merged 3 commits into
mainfrom
feat/optional-output-fields-147

Conversation

@gnzjgo
Copy link
Copy Markdown
Member

@gnzjgo gnzjgo commented May 17, 2026

Summary

Fixes a regression from param metadata generation where non-param template helpers could receive Tinybird parameter metadata.

  • Only inject default/required/description metadata into typed Tinybird parameter functions such as String(...), DateTime(...), Int32(...), etc.
  • Preserve helper calls such as split_to_array(siteIds) unchanged.
  • Preserve column(orderBy) behavior while still allowing its supported default positional argument.
  • Adds regression coverage for optional/described params used with split_to_array(...) and column(...).

Template function coverage

The generator uses an allowlist for metadata injection. Only documented transform type functions receive default, required, or description metadata:

  • Boolean, Date, DateTime, DateTime64
  • Float32, Float64
  • Int8, Int16, Int32, Int64, Int128, Int256
  • UInt8, UInt16, UInt32, UInt64, UInt128, UInt256
  • String, Array

Everything else from the template-functions reference is preserved as written, including helpers like split_to_array(...), sql_and(...), and other non-transform helpers. column(...) is handled separately because Tinybird supports its positional default argument, but not required= or description= keyword args.

Problem

This TypeScript:

params: {
  siteIds: p.string().optional().describe("Comma-separated list of framerSiteId. Only used for test isolation"),
},
sql: `{{ split_to_array(siteIds) }}`,

could be generated as:

{{ split_to_array(siteIds, required=False, description="Comma-separated list of framerSiteId. Only used for test isolation") }}

Tinybird rejects that because split_to_array does not accept those keyword args:

split_to_array() got an unexpected keyword argument 'required'

How to test

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm use 20
pnpm vitest run src/generator/pipe.test.ts
pnpm typecheck

@gnzjgo gnzjgo requested a review from juliavallina May 18, 2026 07:11
@gnzjgo gnzjgo merged commit d49c585 into main May 18, 2026
2 checks passed
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.

2 participants