Examples¶
Four production patterns for Computed Files across JSON log parsing, IoT time-series rollup, array explosion, and event deduplication. Each scenario shows the Spark SQL query to paste into the Query field of the Add Computed File dialog. The file names in backticks stand for the file pattern each query reads.
Context. A platform team ingests raw application logs as JSON files into their data lake. Each line carries a nested payload (level, service, trace_id, latency_ms, error.message). They want Qualytics to monitor error rates and latency percentiles without first running an ETL job to flatten the logs into a warehouse table.
What happens. The team creates a Computed File over the JSON file pattern that already scans the log path (for example, s3://logs-raw/app/), then projects the nested payload into typed top-level columns and keeps only the events they care about. Every scan re-reads the underlying files, so newly landed logs are covered automatically. Quality checks land on latency_ms and error_message; a spike in error volume or p99 latency flags the incident directly on the container.
SELECT
event_time,
payload.level AS level,
payload.service AS service,
payload.trace_id AS trace_id,
payload.latency_ms AS latency_ms,
payload.error.message AS error_message
FROM `app_logs.json`
WHERE payload.level IN ('ERROR', 'WARN')
Why it works. Parsing structured fields inside the Computed File keeps the raw JSON unchanged while still giving business quality checks a typed surface to target. If a new deploy renames payload.error.message to payload.err.msg, the next profile surfaces the loss as a Missing field on the Computed File and the team sees the schema drift before a downstream dashboard does.
Context. A manufacturing team lands sensor readings as Parquet files partitioned by date (dt=YYYY-MM-DD/). They monitor daily min, max, and average readings per device and want an anomaly the moment a day is missing or a device goes silent.
What happens. The Computed File aggregates by day and device across the partitioned Parquet file pattern that scans s3://iot-sensors/dt=*/. A predicate on the partition column lets Qualytics skip whole partitions instead of listing every file. Freshness tracking and an automated freshness check turn a delayed ingest into an anomaly the same day.
SELECT
date_trunc('day', reading_time) AS reading_date,
device_id,
site_code,
MIN(reading_value) AS min_reading,
MAX(reading_value) AS max_reading,
AVG(reading_value) AS avg_reading,
COUNT(*) AS reading_count
FROM `iot_sensors.parquet`
WHERE dt >= '2026-01-01' AND reading_value IS NOT NULL
GROUP BY date_trunc('day', reading_time), device_id, site_code
Why it works. A rolling metric that gets stale defeats its own purpose. Because a Computed File is not materialized, every scan re-reads the object store; there is no refresh job to forget. The partition predicate on dt skips whole directories instead of listing every file, so the cost scales with the window you monitor rather than the full history.
Context. A product-analytics team lands events as JSON files. Each event carries a tags array (["premium", "beta", "us-west"]) and they want one row per (user, tag) pair for downstream tag-level quality checks.
What happens. A LATERAL VIEW with EXPLODE(tags) unfolds the array into rows. The Computed File exposes a flat user_id, tag shape that quality checks can target without dealing with array types.
Why it works. A lateral view is the Spark SQL way to flatten nested arrays: select the alias it declares (tag), not the array. Use LATERAL VIEW OUTER EXPLODE(...) to keep users whose array is empty, with a null tag. Quality checks like "at most one row per user per tag" or "no null tags" can then target the flat tag column directly.
Context. A data-engineering team lands click-stream events as Parquet files, but the upstream ingest occasionally replays batches, producing duplicate rows for the same event_id. They want to run uniqueness and reconciliation checks against a clean projection without changing the raw file layout.
What happens. A window function numbers the rows of each event_id from the most recent event_time, and the outer query keeps the first one. The result is one row per event_id, always the most recent.
SELECT event_id, user_id, event_type, event_time, session_id
FROM (
SELECT
*,
ROW_NUMBER() OVER (PARTITION BY event_id ORDER BY event_time DESC) AS rn
FROM `clickstream.parquet`
) ranked
WHERE rn = 1
Why it works. Splitting "raw" and "clean" projections of the same files as two containers keeps monitoring meaningful: the raw file pattern stays observable for pipeline-health checks (duplicate counts, ingest lag), and the clean Computed File is what business quality checks reference. Because the subquery reads the same single file, the query still meets the one-file rule.