Skip to content

Snowflake maps its schema once at the start. - #70903

Merged
Ryan Br... (tryangul) merged 25 commits into
masterfrom
rbroughan/update-snowflake-to-table-schema-mapper
Dec 18, 2025
Merged

Ryan Br... (tryangul) merged 25 commits into
masterfrom
rbroughan/update-snowflake-to-table-schema-mapper

Conversation

@tryangul

@tryangul Ryan Br... (tryangul) commented Dec 12, 2025 •

Copy link
Copy Markdown
Contributor

What

Migrates Snowflake destination to use the new CDK schema mapper architecture (CDK 0.1.89+).

This is part of the broader effort to modernize destination connectors to use the standardized CDK components.

How

  • Deprecates ColumnUtils. Remaining logic moved to SnowflakeColumnManager for managing meta columns and column type mappings
  • Updated SnowflakeDirectLoadSqlGenerator to use StreamTableSchema instead of DestinationStream for SQL generation
  • Refactored all SQL generation methods to work with the new schema structure:
    • methods now takes StreamTableSchema / ColumnSchema with proper column mappings
    • Removed dependency on ColumnNameMapping in favor of built-in schema mapping
    • Improved SQL formatting inconsistencies using trimMargin() for better readability

Review guide

  1. SnowflakeDirectLoadSqlGenerator.kt - Main SQL generation logic changes 🌶️
  2. SnowflakeTableSchemaMapper.kt - Schema mapping logic

User Impact

N/A

Can this PR be safely reverted and rolled back?

  • YES 💚
  • NO ❌

Important

Auto-merge enabled.

This PR is set to merge automatically when all requirements are met.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Greetings, Airbyte Team Member!

Here are some helpful tips and reminders for your convenience.

Helpful Resources

PR Slash Commands

Airbyte Maintainers (that's you!) can execute the following slash commands on your PR:

  • /format-fix - Fixes most formatting issues.
  • /bump-version - Bumps connector versions.
    • You can specify a custom changelog by passing changelog. Example: /bump-version changelog="My cool update"
    • Leaving the changelog arg blank will auto-populate the changelog from the PR title.
  • /bump-progressive-rollout-version - Bumps connector version with an RC suffix for progressive rollouts.
    • Creates a release candidate version (e.g., 2.16.10-rc.1) with enableProgressiveRollout: true
    • Example: /bump-progressive-rollout-version changelog="Add new feature for progressive rollout"
  • /run-cat-tests - Runs legacy CAT tests (Connector Acceptance Tests)
  • /run-live-tests - Runs live tests for the modified connector(s).
  • /run-regression-tests - Runs regression tests for the modified connector(s).
  • /build-connector-images - Builds and publishes a pre-release docker image for the modified connector(s).
  • /publish-connectors-prerelease - Publishes pre-release connector builds (tagged as {version}-dev.{git-sha}) for all modified connectors in the PR.
  • Connector release lifecycle (AI-powered):
    • /ai-prove-fix - Runs prerelease readiness checks, including testing against customer connections.
    • /ai-canary-prerelease - Rolls out prerelease to 5-10 connections for canary testing.
    • /ai-release-watch - Monitors rollout post-release and tracks sync success rates.
  • JVM connectors:
    • /update-connector-cdk-version connector=<CONNECTOR_NAME> - Updates the specified connector to the latest CDK version.
      Example: /update-connector-cdk-version connector=destination-bigquery
    • /bump-bulk-cdk-version bump=patch changelog='foo' - Bump the Bulk CDK's version. bump can be major/minor/patch.
  • Python connectors:
    • /poe connector source-example lock - Run the Poe lock task on the source-example connector, committing the results back to the branch.
    • /poe source example lock - Alias for /poe connector source-example lock.
    • /poe source example use-cdk-branch my/branch - Pin the source-example CDK reference to the branch name specified.
    • /poe source example use-cdk-latest - Update the source-example CDK dependency to the latest available version.

📝 Edit this welcome message.

@github-actions

github-actions Bot commented Dec 13, 2025 •

Copy link
Copy Markdown
Contributor

destination-snowflake Connector Test Results

 22 files   22 suites   20m 31s ⏱️
320 tests 280 ✅ 40 💤 0 ❌
324 runs  284 ✅ 40 💤 0 ❌

Results for commit fd0a127.

♻️ This comment has been updated with latest results.

@github-actions

github-actions Bot commented Dec 13, 2025 •

Copy link
Copy Markdown
Contributor

Note

Detected that there are differences in the Gradle dependencies.

@tryangul Ryan Br... (tryangul) changed the title Claude 1 shot attempt. Let's refactor snowflake onto the new paradigm Dec 13, 2025
@tryangul Ryan Br... (tryangul) changed the title Let's refactor snowflake onto the new paradigm Snowflake maps its schema once at the start. Dec 13, 2025
@tryangul
Ryan Br... (tryangul) force-pushed the rbroughan/update-snowflake-to-table-schema-mapper branch from 2fd9722 to 3f0495e Compare December 16, 2025 22:30
@tryangul
Ryan Br... (tryangul) marked this pull request as ready for review December 17, 2025 21:30
@tryangul
Ryan Br... (tryangul) force-pushed the rbroughan/update-snowflake-to-table-schema-mapper branch from 2ad4487 to 5715ea2 Compare December 17, 2025 22:55

@edgao Edward Gao (edgao) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I didn't read the unit tests at all (LMK if you want me to)

had a few questions + nitpicks

outputRecord.add(mutableRecord.remove(COLUMN_NAME_AB_EXTRACTED_AT)?.toCsvValue() ?: "")
outputRecord.add(mutableRecord.remove(COLUMN_NAME_AB_META)?.toCsvValue() ?: "")
outputRecord.add(mutableRecord.remove(COLUMN_NAME_AB_GENERATION_ID)?.toCsvValue() ?: "")
outputRecord.add(mutableRecord.remove(COLUMN_NAME_AB_LOADED_AT)?.toCsvValue() ?: "")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonblocking: can you replace all these empty strings with "\\N"? will slightly simplify things if/when we get to #70457

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick q: what does "\\N" do?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's snowflake's default null placeholder value (COPY INTO defaults to NULL_IF = '\N')

empty string currently also evaluates to null, b/c snowflake also defaults to EMPTY_FIELD_AS_NULL = true. But we should disable that option at some point, to fix the regression that if the source emits an empty string, we write it as null. At which point, we'll need to explicitly use the \N placeholder

@github-actions

github-actions Bot commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor

Deploy preview for airbyte-docs ready!

✅ Preview
https://airbyte-docs-gykqrl2u8-airbyte-growth.vercel.app

Built with commit fd0a127.
This pull request is being automatically deployed with vercel-action

@tryangul

Ryan Br... (tryangul) commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor Author

/publish-connectors-prerelease

Pre-release Connector Publish Started

Publishing pre-release build for connector destination-snowflake.
Branch: rbroughan/update-snowflake-to-table-schema-mapper

Pre-release versions will be tagged as {version}-preview.5170ce1
and are available for version pinning via the scoped_configuration API.

View workflow run
Pre-release Publish: FAILED ❌

Docker image (pre-release):
airbyte/destination-snowflake:4.0.32-rc.1-preview.5170ce1

Docker Hub: https://hub.docker.com/layers/airbyte/destination-snowflake/4.0.32-rc.1-preview.5170ce1

Registry JSON:

@tryangul

Ryan Br... (tryangul) commented Dec 18, 2025 •

Copy link
Copy Markdown
Contributor Author

/build-connector-images

Connector Image Build Started

  • This workflow will build the connector image and run basic tests.
  • The connector image(s) will be pushed to the GitHub Container Registry.

Check job output.
Connector Image Builds job completed. See logs for details.

@tryangul
Ryan Br... (tryangul) enabled auto-merge (squash) December 18, 2025 23:13
@tryangul
Ryan Br... (tryangul) merged commit 272f243 into master Dec 18, 2025
47 checks passed
@tryangul
Ryan Br... (tryangul) deleted the rbroughan/update-snowflake-to-table-schema-mapper branch December 18, 2025 23:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants