SQL capabilities of AWS Clean Rooms Differential Privacy
AWS Clean Rooms Differential Privacy uses a general-purpose query structure to support complex SQL queries. Custom analysis templates are validated against this structure to ensure that they can run on tables protected by differential privacy. The following table indicates which functions are supported. See Query structure and syntax for more information.
Category | SQL constructs supported in the Spark analytics engine | SQL constructs supported in the AWS Clean Rooms SQL analytics engine | Common table expressions (CTEs) | Final SELECT clause |
---|---|---|---|---|
Aggregate functions |
|
|
Supported with the condition that CTEs using differential privacy protected tables
must result in data with user-level records. You should write the SELECT expression in
those CTEs using `SELECT userIdentifierColumn...' format. |
Supported aggregations: AVG, COUNT, COUNT DISTINCT, STDDEV, and SUM. |
CTEs | WITH clause, WITH clause subquery | WITH clause, WITH clause subquery | Supported with the condition that CTEs using differential privacy protected tables
must result in data with user-level records. You should write the SELECT expression in
those CTEs using `SELECT userIdentifierColumn...' format. |
N/A |
Subqueries |
|
|
You can have any subquery that doesn't reference differential privacy relations in these constructs. You can have any subquery that references differential privacy relations in a FROM and JOIN clause only. | |
Join clauses |
|
|
Supported with the condition that only JOIN functions that are equi-joins on user identifier columns are supported and are mandatory when querying two or more tables with differential privacy turned on. Ensure that the mandatory equi-join conditions are correct. Confirm that the table owner has configured the same user identifier column in all tables so that the definition of a user remains consistent across tables. CROSS JOIN functions are not supported when combining two or more relations with differential privacy turned on. |
|
Set operators | UNION, UNION ALL, INTERSECT, EXCEPT | MINUS (these are synonyms) | UNION, UNION ALL, INTERSECT, EXCEPT | MINUS (these are synonyms) | All are supported | Not supported |
Window functions |
Aggregate functions
Ranking functions
|
Aggregate functions
Ranking functions
|
All are supported with the condition that the user identifier column in the window function's partition clause is required when you query a relation with differential privacy turned on. | Not supported |
Conditional expressions |
|
|
All are supported | All are supported |
Conditions |
|
|
EXISTS and IN can't be used because they require subqueries.
All others are supported. |
All are supported |
Date-time functions |
|
|
All are supported | All are supported |
String functions |
|
|
All are supported | All are supported |
Data type formatting functions |
|
|
All are supported | All are supported |
Hash functions |
|
|
All are supported | All are supported |
Mathematical operator symbols | +, -, *, /, %, and @ | +, -, *, /, %, and @ | All are supported | All are supported |
Math functions |
|
|
All are supported | All are supported |
VARBYTE functions |
|
|
All are supported | All are supported |
JSON |
|
|
All are supported | All are supported |
Array functions |
|
|
Not supported | Not supported |
Extended GROUP BY | GROUPING SETS, ROLLUP, CUBE | GROUPING SETS, ROLLUP, CUBE | Not supported | Not supported |
Sort operation | ORDER BY | ORDER BY | Supported with the condition that an ORDER BY clause is only supported in a window function's partition clause when querying tables with differential privacy turned on. | Supported |
Row limits | LIMIT, OFFSET | LIMIT, OFFSET | Not supported in CTEs using differential privacy protected tables | All are supported |
Table and column aliasing | Supported | Supported | ||
Math functions on aggregate functions | Supported | Supported | ||
Scalar functions within aggregate functions | Supported | Supported |
Common alternatives for unsupported SQL constructs
Category | SQL construct | Alternative |
---|---|---|
Window functions |
|
You can use the equivalent aggregate function with GROUP BY. |
Mathematical operator symbols |
|
|
Scalar functions |
|
|
Literals | INTERVAL ‘1 SECOND' | INTERVAL '1' SECOND |
Row limiting | TOP n | LIMIT n |
Join |
|
ON clause should explicitly contain a join criterion. |