Berlin Tech Meetup: The Future of Relational Foundation Models, Systems, and Real-World Applications

Register now:
Learn14 min read

What is Predictive Query Language (PQL)? A Complete Guide

PQL is a SQL-like language for defining prediction tasks. Instead of writing hundreds of lines of Python to build an ML pipeline, you write 2-3 lines of PQL. It reads like SQL but describes future outcomes.

TL;DR

  • 1On the SAP SALT enterprise benchmark, KumoRFM scores 91% accuracy vs 75% for PhD data scientists with XGBoost and 63% for LLM+AutoML - with zero feature engineering and zero training time.
  • 2PQL (Predictive Query Language) is Kumo's SQL-like syntax for defining prediction tasks on relational data. A single PQL query replaces the entire ML pipeline: data extraction, table joins, feature engineering, model selection, training, and evaluation.
  • 3PQL uses forward time windows to define prediction horizons (e.g., 0 to 30 days ahead) and backward time windows to filter entities (e.g., only members active in the last 60 days). This eliminates noise from dead accounts and focuses predictions on actionable entities.
  • 4PQL supports five task types: binary classification, regression, multi-class, ranked recommendations (LIST_DISTINCT with RANK TOP N), and counterfactual predictions (the ASSUMING clause). The ASSUMING clause enables 'what-if' predictions that are impossible in traditional ML without holdout experiments.
  • 5A PQL query that takes 2-3 lines replaces 50+ lines of Python, 12+ hours of data science work, and 6+ distinct pipeline stages. The reduction is not incremental. It is structural: PQL describes the prediction target, and the engine discovers the features automatically.

Every enterprise ML project follows the same pattern. A business stakeholder asks a question: "Which customers will churn next month?" A data scientist then spends 2-4 weeks building a pipeline: extracting data from multiple tables, writing joins, computing hundreds of features, selecting a model, training it, evaluating it, and deploying it. The question took 10 seconds to ask. The answer takes 10 days to build.

PQL eliminates the gap between question and answer. It is a query language that lets you describe a prediction task the same way you would describe it to a colleague: "Predict which active members will stop visiting in the next 30 days." Kumo's engine takes that description and handles everything else, from feature discovery to model training to scored output.

The headline result: SAP SALT benchmark

The SAP SALT benchmark is an enterprise-grade evaluation where real business analysts and data scientists attempt prediction tasks on SAP enterprise data. It measures how accurately different approaches predict real business outcomes on production-quality enterprise databases with multiple related tables.

sap_salt_enterprise_benchmark

approachaccuracywhat_it_means
LLM + AutoML63%Language model generates features, AutoML selects model
PhD Data Scientist + XGBoost75%Expert spends weeks hand-crafting features, tunes XGBoost
KumoRFM (zero-shot)91%No feature engineering, no training, reads relational tables directly

SAP SALT benchmark: KumoRFM outperforms expert data scientists by 16 percentage points and LLM+AutoML by 28 percentage points on real enterprise prediction tasks.

KumoRFM scores 91% where PhD-level data scientists with weeks of feature engineering and hand-tuned XGBoost score 75%. The 16 percentage point gap is the value of reading relational data natively instead of flattening it into a single table.

PQL syntax: how it works

A PQL query has three parts: what to predict, who to predict for, and optionally, which entities to filter. The syntax is intentionally similar to SQL so that anyone who can write a SELECT statement can write a prediction task.

Anatomy of a PQL query

Every PQL query follows this structure:

  • PREDICT — defines the target variable using an aggregation function (COUNT, SUM, AVG, MAX, MIN, LIST_DISTINCT) over a forward time window
  • FOR EACH — specifies the entity to generate predictions for (e.g., each customer, each account, each article)
  • WHERE (optional) — filters entities using backward time windows to focus on recently-active entities
  • ASSUMING (optional) — defines a counterfactual condition for "what-if" predictions

PQL examples: 7 prediction tasks in 2-3 lines each

The following examples show real PQL queries for common enterprise prediction tasks. Each query replaces an entire ML pipeline that would otherwise require data extraction, feature engineering, model selection, and training.

1. Churn prediction

Predict which recently-active members will stop visiting in the next 30 days. The backward window (-60, 0, days) in the WHERE clause filters to members who have visited in the last 60 days, eliminating noise from already-inactive accounts.

PQL Query

PREDICT COUNT(VISITS.*, 0, 30, days) = 0
FOR EACH MEMBERS.MEMBER_ID
WHERE COUNT(VISITS.*, -60, 0, days) > 0

Binary classification: predicts whether a recently-active member will have zero visits in the next 30 days. The backward window eliminates already-churned members from the prediction set, focusing model capacity on at-risk members who are still reachable.

Output

member_idchurn_probabilitylast_visitrisk_tier
M-44010.873 days agoHigh
M-44020.121 day agoLow
M-44030.6418 days agoMedium
M-44040.9342 days agoHigh

2. Fraud detection

Predict which accounts will have suspicious transaction volume exceeding $10,000 in the next 7 days. This binary classification flags accounts likely to experience high-value anomalous activity.

PQL Query

PREDICT SUM(TRANSACTIONS.AMOUNT, 0, 7, days) > 10000
FOR EACH ACCOUNTS.ACCOUNT_ID

Binary classification: predicts whether an account's total transaction amount will exceed $10,000 in the next 7 days. The model learns spending patterns across the full relational graph, including merchant types, transaction frequency, and geographic patterns.

Output

account_idfraud_probabilitycurrent_7d_avgalert_level
A-77010.91$1,200Critical
A-77020.03$8,400Normal
A-77030.78$950High
A-77040.15$11,200Low (normal high-volume)

3. Lead scoring

Predict which leads will convert to an order in the next 30 days. This replaces manual lead scoring models that require CRM feature engineering.

PQL Query

PREDICT COUNT(ORDERS.*, 0, 30, days) > 0
FOR EACH LEADS.LEAD_ID

Binary classification: predicts whether a lead will generate at least one order in the next 30 days. The model reads across leads, contacts, activities, and historical opportunities to discover buying signals that manual scoring misses.

Output

lead_idconversion_probabilitylead_sourcepriority
L-22010.84WebinarHot
L-22020.31Cold emailWarm
L-22030.07Trade showCold
L-22040.92Inbound demoHot

4. Demand forecasting

Predict the total quantity sold for each article over the next 3 months. This is a regression task, not binary classification, because the target is a continuous value.

PQL Query

PREDICT SUM(TRANSACTIONS.QUANTITY, 0, 3, months)
FOR EACH ARTICLES.ARTICLE_ID

Regression: predicts the total units sold for each article in the next 3 months. The model learns seasonal patterns, cross-product cannibalization, and supply chain signals from the full relational structure.

Output

article_idpredicted_quantitycurrent_quarterly_avgtrend
SKU-0014,2003,800Up 10.5%
SKU-0028901,200Down 25.8%
SKU-00312,40011,900Up 4.2%
SKU-004150600Down 75.0%

5. Product recommendations

Predict the top 5 products each customer is most likely to order in the next 30 days. LIST_DISTINCT returns a ranked list of distinct values, and RANK TOP N limits the output to the top candidates.

PQL Query

PREDICT LIST_DISTINCT(ORDERS.PRODUCT_ID, 0, 30, days)
RANK TOP 5
FOR EACH CUSTOMERS.CUSTOMER_ID

Ranked recommendation: predicts the top 5 most likely products for each customer to order in the next 30 days. The model learns from purchase history, product co-occurrence, customer similarity, and temporal patterns across the full product catalog.

Output

customer_idrank_1rank_2rank_3rank_4rank_5
C-101P-44 (0.89)P-12 (0.74)P-87 (0.61)P-03 (0.55)P-91 (0.42)
C-102P-22 (0.93)P-44 (0.81)P-56 (0.67)P-78 (0.52)P-33 (0.41)
C-103P-07 (0.76)P-19 (0.71)P-44 (0.58)P-62 (0.44)P-15 (0.38)

6. Customer lifetime value (LTV)

Predict the total revenue from each customer over the next 365 days. This regression task drives budget allocation for acquisition and retention spend.

PQL Query

PREDICT SUM(ORDERS.AMOUNT, 0, 365, days)
FOR EACH CUSTOMERS.CUSTOMER_ID

Regression: predicts the total order revenue per customer over the next year. The model captures purchase frequency trends, average order value trajectories, product mix evolution, and cross-sell patterns across the full customer-order-product graph.

Output

customer_idpredicted_ltvhistorical_ltvsegment
C-101$14,200$11,800High-value growth
C-102$2,100$4,500Declining
C-103$8,700$8,200Stable
C-104$22,400$19,100High-value growth

7. Counterfactual prediction (ASSUMING clause)

Predict whether a user will make a purchase in the next 4 days, assuming they receive a push notification today. The ASSUMING clause is what makes this query fundamentally different from all the others. It enables counterfactual reasoning: predicting outcomes under hypothetical interventions.

PQL Query

PREDICT COUNT(PURCHASES.*, 1, 4, days) > 0
FOR EACH USERS.USER_ID
ASSUMING COUNT(NOTIFICATIONS.* WHERE NOTIFICATIONS.TYPE = 'PUSH', 0, 1, days) > 0

Counterfactual binary classification: predicts purchase probability assuming a push notification is sent, even for users who have never received one. This enables causal uplift modeling without holdout experiments. Compare the 'with notification' prediction to a baseline query without the ASSUMING clause to estimate the incremental lift of the intervention.

Output

user_idprob_with_pushprob_without_pushincremental_lift
U-5010.720.31+41 points
U-5020.180.16+2 points (low lift)
U-5030.850.44+41 points
U-5040.090.08+1 point (no effect)

PQL vs Python: what PQL replaces

To understand why PQL matters, you need to see what the equivalent Python pipeline looks like. A single PQL query replaces 6 distinct pipeline stages, each requiring specialized code.

pql_vs_python_pipeline

pipeline_stagePQLPython_equivalenttime_cost
Define prediction targetPREDICT clause (1 line)Target variable logic + label extraction (15-30 lines)10 min vs seconds
Data extraction & joinsHandled automaticallySQL queries + pandas merges across 3-8 tables (40-80 lines)2-4 hours vs 0
Feature computationHandled automaticallyAggregations, time windows, encodings (100-200 lines)4-6 hours vs 0
Feature selectionHandled automaticallyCorrelation analysis, importance ranking (30-50 lines)1-2 hours vs 0
Model selection & trainingHandled automaticallyTry XGBoost, LightGBM, neural nets, tune hyperparameters (50-80 lines)2-3 hours vs 0
Evaluation & deploymentHandled automaticallyCross-validation, metrics, model serialization (40-60 lines)1-2 hours vs 0
Total2-3 lines of PQL275-500 lines of Python12+ hours vs minutes

Highlighted: total effort comparison. PQL collapses the entire pipeline into a declarative query. The reduction is not about writing less code. It is about eliminating 6 pipeline stages that each require specialized expertise.

Traditional Python pipeline

  • 275-500 lines of code across 6 stages
  • Requires SQL, pandas, scikit-learn, XGBoost expertise
  • 12+ hours of data scientist time per prediction task
  • Manual feature engineering limits accuracy to available features
  • Each new prediction task requires a new pipeline
  • Counterfactual predictions require holdout experiments

PQL query

  • 2-3 lines of declarative syntax
  • Requires only SQL-level knowledge
  • Minutes from query to scored predictions
  • Automatic feature discovery across full relational graph
  • Each new task is a new query, not a new pipeline
  • Counterfactual predictions via ASSUMING clause

PQL's backward window: eliminating noise from dead accounts

One of PQL's most powerful features is the backward time window in the WHERE clause. This filters the entity set before prediction, ensuring you only predict for entities that are relevant and actionable.

Consider the churn prediction example:

WHERE COUNT(VISITS.*, -60, 0, days) > 0

This backward window (-60, 0, days) means "only include members who had at least one visit in the last 60 days." Without this filter, your churn model would waste capacity predicting that already-inactive accounts will remain inactive, which is trivially true and operationally useless.

In traditional ML, this filtering requires a separate data preprocessing step: query the database for recently-active entities, build the feature table only for those entities, then train the model. In PQL, it is one line in the query. The engine handles the filtering automatically and ensures that the training data, features, and predictions are all scoped to the right entity set.

Supported aggregations and task types

PQL supports a range of aggregation functions, each mapping to a specific type of prediction task.

pql_aggregations_and_task_types

aggregationexample_usagetask_typetypical_use_case
COUNT(...) = 0COUNT(VISITS.*, 0, 30, days) = 0Binary classificationChurn, inactivity
COUNT(...) > 0COUNT(ORDERS.*, 0, 30, days) > 0Binary classificationConversion, lead scoring
SUM(...) > NSUM(TXN.AMOUNT, 0, 7, days) > 10000Binary classificationFraud, anomaly detection
SUM(...)SUM(ORDERS.AMOUNT, 0, 365, days)RegressionLTV, revenue forecasting
AVG(...)AVG(RATINGS.SCORE, 0, 90, days)RegressionSatisfaction prediction
COUNT(...)COUNT(TICKETS.*, 0, 30, days)RegressionSupport volume forecasting
MAX(...)MAX(TRANSACTIONS.AMOUNT, 0, 30, days)RegressionPeak transaction prediction
MIN(...)MIN(RESPONSE_TIME.SECONDS, 0, 7, days)RegressionSLA prediction
LIST_DISTINCT(...) RANK TOP NLIST_DISTINCT(ORDERS.PRODUCT_ID, 0, 30, days) RANK TOP 5Ranked recommendationProduct, content recommendations

PQL aggregation functions map directly to ML task types. Adding a comparison operator (= 0, > N) converts a regression target into a binary classification target. LIST_DISTINCT with RANK TOP N produces ranked recommendation lists.

Why PQL changes who can do ML

The traditional ML pipeline requires at least three skill sets: SQL for data extraction, Python/pandas for feature engineering, and ML framework expertise for modeling. Most organizations have far more SQL-proficient analysts than ML engineers.

PQL reduces the required skill set to SQL-level knowledge. A data analyst who writes SQL queries daily can write PQL queries and produce predictions that match or exceed what a dedicated ML team builds in weeks. This is not about simplifying ML. It is about making the prediction itself the interface, rather than the pipeline.

who_can_use_pql

rolecan_write_SQLcan_build_ML_pipelinecan_write_PQLtime_to_prediction
Data analystYesNoYesMinutes
Business analystYesNoYesMinutes
Data engineerYesSometimesYesMinutes
Data scientistYesYesYesMinutes (vs weeks)
ML engineerYesYesYesMinutes (vs weeks)

Highlighted: data analysts and business analysts can use PQL directly. They represent the largest pool of data-literate professionals in most enterprises but have been locked out of ML by the Python pipeline requirement.

PQL in practice: from question to prediction

A typical PQL workflow has three steps:

  1. Connect your database. Point Kumo at your relational database (or data warehouse tables). Kumo reads the schema, foreign keys, and data types automatically.
  2. Write the PQL query. Define what you want to predict, for which entities, with optional filters and counterfactual conditions.
  3. Get scored predictions. Kumo's engine discovers features across the full relational graph, trains a model, and returns scored predictions for every entity in the query scope.

There is no feature engineering step. There is no model selection step. There is no training configuration to specify. The PQL query is the complete task specification, and the engine handles everything else.

Frequently asked questions

What is Predictive Query Language (PQL)?

PQL is Kumo's SQL-like language for defining prediction tasks on relational data. Instead of writing hundreds of lines of Python to extract data, join tables, compute features, select a model, train, evaluate, and deploy, you write 2-3 lines of PQL that describe WHAT you want to predict, WHO you want predictions for, and WHEN the prediction window is. Kumo's engine handles the entire ML pipeline automatically.

How is PQL different from SQL?

SQL queries the past: it aggregates, filters, and joins historical data. PQL describes the future: it specifies a prediction target over a forward-looking time window. For example, SQL can tell you how many visits a member had in the last 30 days. PQL predicts how many visits they will have in the next 30 days. PQL uses forward time windows (0, 30, days) to define the prediction horizon and backward time windows (-60, 0, days) to filter entities based on recent behavior.

What types of predictions does PQL support?

PQL supports five prediction task types: binary classification (will something happen yes/no), regression (predict a continuous value like revenue), multi-class classification (predict a category), ranked recommendations (predict a ranked list using LIST_DISTINCT with RANK TOP N), and counterfactual predictions using the ASSUMING clause (predict what would happen IF a specific intervention occurred).

What aggregation functions does PQL support?

PQL supports standard aggregation functions including SUM, COUNT, AVG, MAX, MIN, and LIST_DISTINCT. Each aggregation operates over a time window defined by three parameters: start offset, end offset, and time unit (days, weeks, months). For example, SUM(ORDERS.AMOUNT, 0, 365, days) sums order amounts over the next 365 days. LIST_DISTINCT returns a ranked list of distinct values, used for recommendation tasks.

What is the ASSUMING clause in PQL?

The ASSUMING clause enables counterfactual predictions: predicting what would happen IF a specific condition were true, even if it hasn't happened yet. For example, 'ASSUMING COUNT(NOTIFICATIONS.* WHERE NOTIFICATIONS.TYPE = "PUSH", 0, 1, days) > 0' asks the model to predict outcomes assuming a push notification is sent. This is impossible in traditional ML without running holdout experiments. PQL makes it a query parameter.

Do I need to know Python or machine learning to use PQL?

No. PQL is designed for anyone who can write SQL. You define the prediction target, the entity, and optional filters. Kumo's engine handles all feature engineering, model selection, training, and evaluation automatically. A data analyst who writes SQL daily can write PQL queries and get production-grade predictions without any ML expertise.

See it in action

KumoRFM delivers predictions on relational data in seconds. No feature engineering, no ML pipelines. Try it free.