

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# AWS Clean Rooms 差分プライバシーの SQL 機能
<a name="dp-sql-capabilities"></a>

AWS Clean Rooms 差分プライバシーは、汎用クエリ構造を使用して複雑な SQL クエリをサポートします。カスタム分析テンプレートは、差分プライバシーで保護されたテーブルで実行できるよう、この構造に対して検証されます。次の表は、どの関数がサポートされているかを示しています。詳細については「[クエリの構造と構文](analysis-rules-custom.md#dp-query-structure-syntax)」を参照してください。


| Category | Spark 分析エンジンでサポートされている SQL コンストラクト | テーブル共通式 (CTE) | 最終 SELECT 句 | 
| --- |--- |--- |--- |
| Aggregate functions |    ANY\$1VALUE 関数   APPROXIMATE PERCENTILE\$1DISC 関数   AVG 関数   COUNT および COUNT DISTINCT 関数   MAX 関数   MEDIAN 関数   MIN 関数   PERCENTILE\$1CONT 関数   STDDEV\$1SAMP および STDDEV\$1POP 関数   SUM および SUM DISTINCT 関数   VAR\$1SAMP および VAR\$1POP 関数    | 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 | 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 |    SELECT   HAVING   JOIN   JOIN 条件   FROM   WHERE    | 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 |    INNER JOIN   LEFT JOIN   左半結合   左アンチ結合   RIGHT JOIN   FULL JOIN   [JOIN] OR 演算子   CROSS JOIN    |  ユーザー識別子列の等価結合である JOIN 関数のみがサポートされ、差分プライバシーが有効になっている複数のテーブルをクエリする場合は必須であるという条件でサポートされます。必須の等価結合条件が正しいことを確認してください。テーブル所有者がすべてのテーブルに同じユーザー ID 列を設定して、ユーザーの定義がテーブル間で一貫していることを確認します。 差分プライバシーを有効にして 2 つ以上のリレーションを組み合わせる場合、CROSS JOIN 関数はサポートされません。  | 
| Set operators | UNION, UNION ALL, INTERSECT, EXCEPT \$1 MINUS (these are synonyms) | UNION, UNION ALL, INTERSECT, EXCEPT \$1 MINUS (these are synonyms) | Not supported | 
| Window functions |  集計関数   AVG ウィンドウ関数   COUNT ウィンドウ関数   CUME\$1DIST ウィンドウ関数   DENSE\$1RANK ウィンドウ関数   FIRST\$1VALUE ウィンドウ関数   LAG ウィンドウ関数   LAST\$1VALUE ウィンドウ関数   LEAD ウィンドウ関数   MAX ウィンドウ関数   MEDIAN ウィンドウ関数   MIN ウィンドウ関数   NTH\$1VALUE ウィンドウ関数   STDDEV\$1SAMP および STDDEV\$1POP ウィンドウ関数 (STDDEV\$1SAMP および STDDEV はシノニムです)   SUM ウィンドウ関数   VAR\$1SAMP および VAR\$1POP ウィンドウ関数 (VAR\$1SAMP および VARIANCE はシノニムです)   ランク付け関数   DENSE\$1RANK ウィンドウ関数   NTILE ウィンドウ関数   PERCENT\$1RANK ウィンドウ関数   RANK ウィンドウ関数   ROW\$1NUMBER ウィンドウ関数    | 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 |    CASE 条件式   COALESCE 式   GREATEST および LEAST 関数   NVL および COALESCE 関数   NVL2 関数   NULLIF 関数    | All are supported | All are supported | 
| Conditions |    比較条件   論理条件   パターンマッチング条件   BETWEEN 範囲条件   Null 条件    | EXISTS and IN can't be used because they require subqueries. All others are supported. | All are supported | 
| Date-time functions |    トランザクションにおける日付および時刻関数   連結演算子   ADD\$1MONTHS 関数   CONVERT\$1TIMEZONE 関数   CURRENT\$1DATE 関数   DATEADD 関数   DATEDIFF 関数   DATE\$1PART 関数   DATE\$1TRUNC 関数   EXTRACT 関数   TO\$1TIMESTAMP 関数   日付関数またはタイムスタンプ関数の日付部分    | All are supported | All are supported | 
| String functions |    \$1\$1 (連結) 演算子   BTRIM 関数   CHAR\$1LENGTH 関数   CHARACTER\$1LENGTH 関数   CONCAT 関数   LEFT 関数および RIGHT 関数   LEN 関数   LENGTH 関数   LOWER 関数   LPAD 関数および RPAD 関数   LTRIM 関数   POSITION 関数   REGEXP\$1COUNT 関数   REGEXP\$1INSTR 関数   REGEXP\$1REPLACE 関数   REGEXP\$1SUBSTR 関数   REPEAT 関数   REPLACE 関数   REVERSE 関数   RTRIM 関数   SPLIT\$1PART 関数   SUBSTRING 関数   TRANSLATE 関数   TRIM 関数   UPPER 関数    | All are supported | All are supported | 
| Data type formatting functions |    CAST 関数   TO\$1CHAR   TO\$1DATE 関数   TO\$1NUMBER   日時形式の文字列   数値形式の文字列    | All are supported | All are supported | 
| Hash functions |    AES\$1ENCRYPT   AES\$1DECRYPT   ENCODE   DECODE   MD5 関数   SHA1 関数   SHA2 関数   XX\$1HASH64    | All are supported | All are supported | 
| Mathematical operator symbols | \$1, -, \$1, /, %, and @ | All are supported | All are supported | 
| Math functions |    ABS 関数   ACOS 関数   ASIN 関数   ATAN 関数   ATAN2 関数   CBRT 関数   CEILING (または CEIL）関数   COS 関数   COT 関数   DEGREES 関数   LTRIM 関数   EXP 関数   FLOOR 関数   LN 関数   LOG 関数   MOD 関数   PI 関数   POWER 関数   RADIANS 関数   RANDOM 関数   ROUND 関数   SIGN 関数   SIN 関数   SQRT 関数   TRUNC 関数    | All are supported | All are supported | 
| VARBYTE functions |    UNHEX、   UNBASE64   HEX    HLL\$1SKETCH\$1AGG、    HLL\$1SKETCH\$1ESTIMATE   HLL\$1UNION   HLL\$1UNION\$1AGG    | All are supported | All are supported | 
| JSON |    TO\$1JSON   GET\$1JSON\$1OBJECT    | All are supported | All are supported | 
| Array functions |    ARRAY\$1CONTAINS   ARRAY\$1DISTINCT   ARRAY\$1EXCEPT   ARRAY\$1INTERSECT   ARRAY\$1JOIN   ARRAY\$1REMOVE   ARRAY\$1SORT   ARRAY\$1UNION    | Not supported | Not supported | 
| Extended GROUP BY | GROUPING SETS, ROLLUP, CUBE | Not supported | Not supported | 
| Sort operation | 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 | 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 | 

## サポートされていない SQL コンストラクトの一般的な代替方法
<a name="common-alternatives"></a>


| Category | SQL コンストラクト | 代替 | 
| --- |--- |--- |
|  Window 関数  |    LISTAGG   PERCENTILE\$1CONT   PERCENTILE\$1DISC    | You can use the equivalent aggregate function with GROUP BY. | 
| Mathematical operator symbols |    \$1column \$1\$1/ 2   \$1column \$1/ 2   \$1column ^ 2    |    CBRT   SQRT   POWER(\$1column, 2)    | 
| Scalar functions |    SYSDATE   \$1column::integer   convert(type, \$1column)    |    CURRENT\$1DATE   CAST \$1column AS integer   CAST \$1column AS type    | 
| Literals | INTERVAL ‘1 SECOND' | INTERVAL '1' SECOND | 
| Row limiting | TOP n | LIMIT n | 
| Join |    USING   NATURAL    | ON clause should explicitly contain a join criterion. | 