ComposableStack.AI CDP
HomeAssessmentAgentLibraryCurriculumHow It WorksSolutionsAbout
← All tasks
Operational taskmodule4· status: no-aep

Schedule and export query results as derived datasets

Convert an ad-hoc analytical query into a scheduled, persisted CTAS query that writes results to a named derived dataset, then connect a BI tool or downstream system to that dataset for repeatable reporting or activation.

This task produces a named derived dataset containing the pre-computed results of a complex analytical query, ready for consumption by BI tools, downstream activation systems, or data science pipelines without incurring per-query execution cost. The output is a persistent dataset with a stable table name, a creation timestamp, and a row count that can be refreshed on a schedule. This pattern is the bridge between exploratory SQL analysis and production reporting pipelines.

CTAS as a pre-computation pattern. Create Table As Select (CTAS) is a standard SQL construct that stores a query's result set as a new table. In the context of platform query services, CTAS serves two additional purposes: it decouples query execution time from BI tool timeout limits (since the result is pre-materialized), and it creates a versioned snapshot of data at a specific point in time that can be compared with future snapshots to detect changes. Each CTAS execution overwrites the previous result unless a naming convention (e.g., appending a date suffix) is used to create a historical series.

Scheduling strategies. The appropriate refresh cadence depends on the downstream use case. Daily snapshots are sufficient for campaign targeting and executive dashboards. Hourly or sub-hourly snapshots are appropriate for operational monitoring (churn signals, support ticket volumes). Near-real-time views are better served by streaming queries or live BI connections to the raw dataset, bypassing CTAS entirely. The Query Service API's Schedules endpoint supports cron-style schedule expressions; the UI provides a visual schedule builder.

BI tool integration. Once a CTAS dataset exists, any PostgreSQL-compatible BI tool can connect using the Query Service connection string and query the derived table as if it were a native PostgreSQL table. AEP Query Service does not require a separate JDBC driver — the standard libpq or JDBC PostgreSQL driver is sufficient. Reports built against derived datasets are faster and more reliable than reports that query raw event datasets directly, because the aggregation has already been computed.

Parallel viability (high). CTAS and scheduled query materialization are universal patterns: Snowflake Dynamic Tables, BigQuery Materialized Views, dbt models, Databricks Delta Live Tables. The API-based query management pattern (submit → poll status → retrieve results) is also universal across cloud data warehouse APIs. Phase 3 will document equivalent Snowflake task scheduling and dbt model run configuration.

Side-by-side implementations

Adobe Experience Platform (AEP)

Parallel implementation not yet available.

Snowflake·confidence 85%
SnowflakeAuto-drafted, pending review

In Snowflake, `CREATE TABLE AS SELECT` (CTAS) pre-computes query results as persistent tables; Snowflake Dynamic Tables automatically refresh these derived tables on a configurable target lag (e.g., `TARGET_LAG = '1 minute'`), removing the need for manually scheduled COPY or INSERT jobs. For dbt-managed pipelines, scheduled dbt Cloud Jobs run on cron schedules and materialize models as Snowflake tables or views; dbt's `ref()` dependency graph ensures correct execution order across dependent models. BI tool export uses `COPY INTO @<stage>` to write query results to S3, Azure Blob, or GCS for downstream consumption by data consumers outside Snowflake. Snowflake's `RESULT_SCAN(LAST_QUERY_ID())` function accesses the output of any recent query by query ID, providing a lightweight equivalent to AEP's `referenced_datasets` API link pattern for programmatic result retrieval.

Capability: Reverse-ETL (CDW-to-Destination Sync)

Sources

  • source.docs-snowflake-com.user-guide-dynamic-tables-intro
  • source.docs-snowflake-com.sql-reference-sql-create-dynamic-table
  • source.docs-getdbt-com.docs-running-a-dbt-project-dbt-cloud-jobs
Hightouch

Parallel implementation not yet available.

Task-level sources

  • technical-training/module4/index.md
  • technical-training/module4/ex4.md
  • technical-training/module4/ex5.md
  • technical-training/module4/ex7.md

How is this implementation?

Sign-in-gated. Tomorrow morning's curriculum-ingestor consumes your feedback: "Inaccurate" queues the task for re-review, "needs update" queues it for a refresh, and "one vendor panel is wrong" re-drafts just that panel.

What kind of feedback?
Sign-in required. Free.