SQL-inf supports combining SQL-inf commands through chaining.
For example, to use
EXPLAIN you need to chain it with another command.
SELECT * FROM customers EXPLAIN(PREDICT(churn))
You can also chain several commands together through nesting of SQL-statements.
In this example we nest a
SENTIMENTstatement within an
EXPLAIN-PREDICT statement to allow us to explain the inner command, ie the output of the
SELECT * FROM (SELECT * FROM customer_feedback SENTIMENT("Review Text")) EXPLAIN(PREDICT(prediction))
Finally, you can join multiple SQL-inf statements together to derive combined statistics.
In this example (from the tutorial on Lead Scoring),
PREDICT statements are run and joined to calculate a weighted revenue prediction.
SELECT left_stmt.mql_id, 12 * conversion.prediction * revenue.prediction as expected_arr FROM (
(SELECT mql_id, landing_page_id, origin, declared_monthly_revenue, prediction
FROM Olist_Seller_Data PREDICT(declared_monthly_revenue, ignore=mql_id, model='reg')) as revenue
(SELECT mql_id, landing_page_id, origin, prediction,
CASE WHEN seller_id IS NULL THEN 0 ELSE 1 END as converted
FROM Olist_Seller_Data PREDICT(converted, ignore=mql_id)) as conversion
ON revenue.mql_id = conversion.mql_id
) WHERE converted=0 ORDER BY expected_arr DESC