Skip to content

Commit

Permalink
Merge pull request #3 from kkulczak/columns-description
Browse files Browse the repository at this point in the history
Columns description as optional scd argument
  • Loading branch information
lewish authored Nov 14, 2022
2 parents 2e618ee + f154a02 commit 030eb83
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions definitions/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ const { updates, view } = scd("source_data_scd", {
},
// Any tags that will be added to actions.
tags: ["slowly-changing-dimensions"],
// Optional documentation of table columns
columns: {user_id: "User ID", some_field: "Data Field", updated_at: "Timestamp for updates"},
// Any configuration parameters to apply to the incremental table that will be created.
incrementalConfig: {
bigquery: {
Expand Down
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
*/
module.exports = (
name,
{ uniqueKey, timestamp, source, tags, incrementalConfig }
{ uniqueKey, timestamp, source, tags, incrementalConfig, columns = {} }
) => {
// Create an incremental table with just pure updates, for a full history of the table.
const updates = publish(`${name}_updates`, {
type: "incremental",
tags,
columns,
...incrementalConfig,
}).query(
(ctx) => `
Expand All @@ -25,6 +26,7 @@ module.exports = (
type: "view",
tags,
columns: {
...columns,
scd_valid_from: `The timestamp from which this row is valid for the given ${uniqueKey}.`,
scd_valid_to: `The timestamp until which this row is valid for the given ${uniqueKey}, or null if this it the latest value.`,
},
Expand Down

0 comments on commit 030eb83

Please sign in to comment.