Skip to content

feat(ampsync): configurable destination table#1988

Open
matiasedgeandnode wants to merge 2 commits intomainfrom
ma/ampsync-destination-table-raw
Open

feat(ampsync): configurable destination table#1988
matiasedgeandnode wants to merge 2 commits intomainfrom
ma/ampsync-destination-table-raw

Conversation

@matiasedgeandnode
Copy link

Adds two new config options for controlling PostgreSQL destination table names:

  • TABLE_SUFFIX: appends a static suffix (e.g., "green" → usdc_transfers_green)
  • TABLE_VERSION: appends sanitized dataset revision (e.g., 1.0.0 → usdc_transfers_v1_0_0)

Composition order: {table}v{revision}{suffix}. Both options are independent and backward compatible — omitting both preserves existing behavior.

Introduces TableMapping (source → destination) to separate the dataset table name used in streaming queries from the PostgreSQL table name used for writes.

Adds two new config options for controlling PostgreSQL destination table names:

- TABLE_SUFFIX: appends a static suffix (e.g., "green" → usdc_transfers_green)
- TABLE_VERSION: appends sanitized dataset revision (e.g., 1.0.0 → usdc_transfers_v1_0_0)

Composition order: {table}_v{revision}_{suffix}. Both options are independent
and backward compatible — omitting both preserves existing behavior.

Introduces TableMapping (source → destination) to separate the dataset table name
used in streaming queries from the PostgreSQL table name used for writes.
@matiasedgeandnode matiasedgeandnode force-pushed the ma/ampsync-destination-table-raw branch from 7f8b975 to b12ddc5 Compare March 17, 2026 18:02
///
/// Replaces non-alphanumeric characters with underscores and prepends `v`.
/// Example: `1.0.0` → `v1_0_0`, `abc123...` → `vabc123...`
fn sanitize_revision(revision: &str) -> String {
Copy link
Member

Choose a reason for hiding this comment

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

There might be collisions here for example 1.0.0 and 1-0-0 both resolve to 1_0_0. At least worth documenting imo.

Copy link
Author

Choose a reason for hiding this comment

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

added a comment

/// # Composition order
///
/// `{source}_v{revision}_{suffix}`
pub fn build_table_mappings(
Copy link
Member

Choose a reason for hiding this comment

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

we should probably throw if table_suffix = ""

Copy link
Author

Choose a reason for hiding this comment

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

actually defaulted to no prefix. Doesn't that make sense?

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