
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
dataform-date
Advanced tools
Simplify date range control for Dataform and Google Analytics 4.
"dataform-date":"latest"
js block of your SQLX file, require the package:
js {
const dates = require("dataform-date");
}
${dates.range("suffix","20241001","20241010")}
range(date_range_column, start_date, end_date, overwrite)load(date_range_column, start_date, end_date, full_refresh_start_date, full_refresh_end_date)create_table_id(date_override)range(date_range_column, start_date, end_date, overwrite)Creates a SQL BETWEEN clause string to filter a date range. Invalid dates like "2024-13-02" will throw an error.
Arguments:
date_range_column (string): The name of the date column to filter on.
"suffix" or "ga4" to filter on _table_suffix (for GA4 partitioned tables), which formats dates as YYYYMMDD.YYYY-MM-DD.start_date (string | number): The start of the date range.
YYYY-MM-DD or YYYYMMDD format.-7 for 7 days ago).-1 (yesterday) if not provided.end_date (string | number): The end of the date range.
start_date.-1 (yesterday) if not provided.overwrite (boolean): Defaults to true. If false, it adds a condition to only select dates that are not already in the target table (...AND ${date_range_column} NOT IN (SELECT DISTINCT ${date_range_column} FROM ${self()})).Examples:
_table_suffix for yesterday.
${dates.range()}
-- output: _table_suffix between "<yesterday_YYYYMMDD>" and "<yesterday_YYYYMMDD>"
_table_suffix with dynamic dates: Filters the last 7 days of data.
${dates.range("suffix", -7, -1)}
-- output: _table_suffix between "<7_days_ago_YYYYMMDD>" and "<yesterday_YYYYMMDD>"
session_date for the last 3 days.
${dates.range("session_date", -3, -1)}
-- output: session_date between "<3_days_ago_YYYY-MM-DD>" and "<yesterday_YYYY-MM-DD>"
${dates.range("session_date", "2024-01-01", -1)}
-- output: session_date between "2024-01-01" and "<yesterday_YYYY-MM-DD>"
${dates.range("session_date", -7, -1, false)}
-- output: session_date between "<7_days_ago_YYYY-MM-DD>" and "<yesterday_YYYY-MM-DD>" and session_date not in (select distinct session_date from ${self()})
load(date_range_column, start_date, end_date, full_refresh_start_date, full_refresh_end_date)A wrapper around range() to simplify creating incremental tables in Dataform. It generates a date filter that behaves differently for incremental runs vs. full refreshes.
Arguments:
date_range_column (string): The date column name (see range() for details).start_date (string | number): The start date for an incremental run.end_date (string | number): The end date for an incremental run.full_refresh_start_date (string | number): The start date for a full refresh.full_refresh_end_date (string | number): The end date for a full refresh.Example:
In your definitions/my_table.sqlx:
config { type: "incremental" }
select * from source_table
where ${dates.load("session_date", -3, -1, "2023-01-01", -1)}
-- For an incremental run, this resolves to:
-- where session_date between "<3_days_ago_YYYY-MM-DD>" and "<yesterday_YYYY-MM-DD>"
-- For a full refresh, this resolves to:
-- where session_date between "2023-01-01" and "<yesterday_YYYY-MM-DD>"
create_table_id(date_override)Creates a fully-qualified table ID for a specific GA4 daily table (e.g., my_project.my_dataset.events_20241010). The date suffix changes automatically based on the execution date.
Arguments:
date_override (string | number):
YYYYMMDD format.-1 (yesterday) if not provided.Examples:
(Assuming dataform.json has defaultDatabase: "my_gcp_project" and defaultSchema: "my_gcp_dataset")
${dates.create_table_id()}
// output: `my_gcp_project.my_gcp_dataset.events_<yesterday_YYYYMMDD>`
${dates.create_table_id(-3)}
// output: `my_gcp_project.my_gcp_dataset.events_<3_days_ago_YYYYMMDD>`
${dates.create_table_id("20241001")}
// output: `my_gcp_project.my_gcp_dataset.events_20241001`
This updated documentation provides a much clearer and more comprehensive guide to using your package.
FAQs
Offers date range control for Dataform in GCP
The npm package dataform-date receives a total of 57 weekly downloads. As such, dataform-date popularity was classified as not popular.
We found that dataform-date demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.