本文へ移動
cccskills
無料GitHub で公開

schema-null-defaults

Handle NULL values and set default values for missing fields in collections and materializations. Use when fields need defaults, nullable primary key errors occur, or source data has gaps. Use when user says "NULL values", "default value", "missing field", "nullable primary key error", or "fill in missing data".

インストール方法を見る

含まれるファイル(1)

  • SKILL.md5.4 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

Handle NULLs and Default Values

Handle NULL values and set default values for missing fields in materializations.

Docs: https://docs.estuary.dev/concepts/schemas/#default-annotations

When to Use

  • Need to provide default values for missing/optional fields
  • Handling nullable primary key errors in materializations (cannot materialize collection with nullable key field unless it has a default value annotation)
  • Ensuring consistent values when source data has gaps

Prerequisites

  • Existing collection to modify
  • flowctl authenticated

Key Concepts

  • default applies only to missing fields, not to explicit null values. A field present with null stays null.
  • default is read by materializations only — captures and derivations ignore it. Add defaults to the readSchema so auto-discover (which only touches writeSchema/connector-schema) can't overwrite them.

Procedure

Step 1: Pull Collection Specs

flowctl catalog pull-specs --name <tenant>/<collection-name>

Step 2: Identify the Read Schema

Find the read schema file (e.g., collection.read.schema.yaml).

Typical structure for collections using schema inference:

allOf:
  - $ref: flow://relaxed-write-schema
  - $ref: flow://inferred-schema

Step 3: Add Default Values

Add default annotations at the top level of the readSchema, alongside allOf:

allOf:
  - $ref: flow://relaxed-write-schema
  - $ref: flow://inferred-schema
properties:
  status:
    type: string
    default: "pending"
  count:
    type: integer
    default: 0
  is_active:
    type: boolean
    default: true

The properties block with defaults sits alongside the allOf, not inside it.

Step 4: Publish Changes

flowctl catalog publish --source flow.yaml

Common Patterns

Default for Optional String Field

allOf:
  - $ref: flow://relaxed-write-schema
  - $ref: flow://inferred-schema
properties:
  category:
    type:
      - string
      - "null"
    default: "uncategorized"

Note: Default only applies when field is missing. If value is explicitly null, it remains null.

Nullable Primary Key with Default

The most common use case. SQL materializations reject key fields that are nullable unless they have a default. This often happens when the inferred schema doesn't mark the field as required (e.g., because it was absent in historical data).

allOf:
  - $ref: flow://relaxed-write-schema
  - $ref: flow://inferred-schema
properties:
  year:
    default: 0

Timestamp Default

allOf:
  - $ref: flow://relaxed-write-schema
  - $ref: flow://inferred-schema
properties:
  created_at:
    type: string
    format: date-time
    default: "1970-01-01T00:00:00Z"

Handling Explicit NULLs

default doesn't replace explicit null values, only missing fields. If you can't fix the source data, use a SQL derivation to replace nulls and materialize the derived collection instead:

collections:
  tenant/derived/collection:
    schema: schema.yaml      # schema + key for the derived collection
    key: [/id]
    derive:
      using:
        sqlite: {}
      transforms:
        - name: replaceNulls
          source: tenant/source/collection
          shuffle: any
          lambda: SELECT COALESCE($status, 'unknown') AS status, $id AS id;

Troubleshooting

Default Not Applied

  • Check if field is missing vs explicitly null
  • Defaults only apply to missing fields
  • Verify default is in readSchema, not just writeSchema
  • Defaults are only used by materializations — ignored by captures and derivations

Nullable PK Error in Materialization

cannot materialize collection 'X' with nullable key field 'Y' unless it has a default value annotation
  • Add default annotation to the key field in readSchema (alongside allOf, not inside it)
  • This can happen even if the field looks non-nullable in the current schema — the inferred schema may have seen it as nullable historically
  • Alternatives: collection reset (reset: true) to re-infer from scratch, or add the field to required in the readSchema

Schema Validation Errors After Adding Default

  • Ensure default value matches the field's type
  • For typed fields, default must be valid: default: 0 for integer, not default: "0"

Existing NULL Data Causing Issues

  • Defaults don't transform existing null values
  • Use a derivation to replace nulls (see "Handling Explicit NULLs" above)
  • Or perform a Dataflow reset after fixing source data

Related Skills

  • schema-field-selection — Control which nullable fields materialize
  • schema-define-fields — Define fields in the readSchema (pruned fields, type refinement, etc.). Note: that skill adds new field definitions as a third entry inside allOf:, while this skill places properties: as a peer of allOf:. Both are valid JSON Schema (sibling keywords are AND'd at the same level). The peer-properties pattern is convenient for annotation-only changes like default; the third-allOf pattern is preferred when introducing new field structure.

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Create an Alpaca capture using flowctl to stream stock trade data into Estuary collections. Use when setting up an Alpaca Market Data source for historical and real-time stock trades. Use when user says "capture Alpaca", "stream stock trades", "Alpaca market data", or "connect Alpaca to Estuary".

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

Create a capture for ANY Estuary connector using dynamic schema discovery. Use when the user wants to capture from a source that doesn't have a dedicated skill (e.g., Kafka, Salesforce, HubSpot, Stripe, S3, GCS, Kinesis, or any of the 148+ connectors). Use when user says "capture from <source>", "stream from <source>", "connect <source> to Estuary", or "set up <source> capture" and no connector-specific skill exists.

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

Create an HTTP Ingest (webhook) capture to receive data via HTTP POST requests. Use when setting up webhooks from GitHub, Shopify, Stripe, or any JSON source. Use when user says "set up webhook capture", "HTTP ingest to Estuary", "receive POST requests to Estuary", or "webhook capture".

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

Create a HubSpot Real-Time capture using flowctl to stream CRM data into Estuary collections. Use when setting up a HubSpot source for contacts, companies, deals, tickets, or other HubSpot resources. Use when user says "capture HubSpot", "stream from HubSpot", "HubSpot CDC", or "connect HubSpot to Estuary".

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

Create a MongoDB CDC capture using flowctl. Use when setting up real-time streaming from MongoDB Atlas, DocumentDB, or self-hosted MongoDB. Use when user says "capture MongoDB", "stream from Mongo", "MongoDB CDC", or "connect MongoDB to Estuary".

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

Create a MySQL CDC capture using flowctl with binlog replication. Use when setting up streaming from MySQL, Amazon RDS MySQL, or Aurora MySQL. Use when user says "capture MySQL", "stream from MySQL", "MySQL CDC", "binlog replication", or "connect MySQL to Estuary".

日本語の概要は準備中です。原文の説明を表示しています。

estuary/agent-skills72026年9月25日 更新

estuary のスキルをすべて見る

このスキルの問題を報告する