

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

# 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\_VALUE 関数   APPROXIMATE PERCENTILE\_DISC 関数   AVG 関数   COUNT および COUNT DISTINCT 関数   MAX 関数   MEDIAN 関数   MIN 関数   PERCENTILE\_CONT 関数   STDDEV\_SAMP および STDDEV\_POP 関数   SUM および SUM DISTINCT 関数   VAR\_SAMP および VAR\_POP 関数    | 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 列を設定して、ユーザーの定義がテーブル間で一貫していることを確認します。<br />差分プライバシーを有効にして 2 つ以上のリレーションを組み合わせる場合、CROSS JOIN 関数はサポートされません。 | 
| Set operators | UNION, UNION ALL, INTERSECT, EXCEPT \| MINUS (these are synonyms) | UNION, UNION ALL, INTERSECT, EXCEPT \| MINUS (these are synonyms) | Not supported | 
| Window functions | 集計関数  AVG ウィンドウ関数   COUNT ウィンドウ関数   CUME\_DIST ウィンドウ関数   DENSE\_RANK ウィンドウ関数   FIRST\_VALUE ウィンドウ関数   LAG ウィンドウ関数   LAST\_VALUE ウィンドウ関数   LEAD ウィンドウ関数   MAX ウィンドウ関数   MEDIAN ウィンドウ関数   MIN ウィンドウ関数   NTH\_VALUE ウィンドウ関数   STDDEV\_SAMP および STDDEV\_POP ウィンドウ関数 (STDDEV\_SAMP および STDDEV はシノニムです)   SUM ウィンドウ関数   VAR\_SAMP および VAR\_POP ウィンドウ関数 (VAR\_SAMP および VARIANCE はシノニムです)  <br />ランク付け関数  DENSE\_RANK ウィンドウ関数   NTILE ウィンドウ関数   PERCENT\_RANK ウィンドウ関数   RANK ウィンドウ関数   ROW\_NUMBER ウィンドウ関数   | 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\_MONTHS 関数   CONVERT\_TIMEZONE 関数   CURRENT\_DATE 関数   DATEADD 関数   DATEDIFF 関数   DATE\_PART 関数   DATE\_TRUNC 関数   EXTRACT 関数   TO\_TIMESTAMP 関数   日付関数またはタイムスタンプ関数の日付部分    | All are supported | All are supported | 
| String functions |    \|\| (連結) 演算子   BTRIM 関数   CHAR\_LENGTH 関数   CHARACTER\_LENGTH 関数   CONCAT 関数   LEFT 関数および RIGHT 関数   LEN 関数   LENGTH 関数   LOWER 関数   LPAD 関数および RPAD 関数   LTRIM 関数   POSITION 関数   REGEXP\_COUNT 関数   REGEXP\_INSTR 関数   REGEXP\_REPLACE 関数   REGEXP\_SUBSTR 関数   REPEAT 関数   REPLACE 関数   REVERSE 関数   RTRIM 関数   SPLIT\_PART 関数   SUBSTRING 関数   TRANSLATE 関数   TRIM 関数   UPPER 関数    | All are supported | All are supported | 
| Data type formatting functions |    CAST 関数   TO\_CHAR   TO\_DATE 関数   TO\_NUMBER   日時形式の文字列   数値形式の文字列    | All are supported | All are supported | 
| Hash functions |    AES\_ENCRYPT   AES\_DECRYPT   ENCODE   DECODE   MD5 関数   SHA1 関数   SHA2 関数   XX\_HASH64    | All are supported | All are supported | 
| Mathematical operator symbols | \+, -, \*, /, %, 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\_SKETCH\_AGG、    HLL\_SKETCH\_ESTIMATE   HLL\_UNION   HLL\_UNION\_AGG    | All are supported | All are supported | 
| JSON |    TO\_JSON   GET\_JSON\_OBJECT    | All are supported | All are supported | 
| Array functions |    ARRAY\_CONTAINS   ARRAY\_DISTINCT   ARRAY\_EXCEPT   ARRAY\_INTERSECT   ARRAY\_JOIN   ARRAY\_REMOVE   ARRAY\_SORT   ARRAY\_UNION    | 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\_CONT   PERCENTILE\_DISC    | You can use the equivalent aggregate function with GROUP BY. | 
| Mathematical operator symbols |    $column \|\|/ 2   $column \|/ 2   $column ^ 2    |    CBRT   SQRT   POWER($column, 2)    | 
| Scalar functions |    SYSDATE   $column::integer   convert(type, $column)    |    CURRENT\_DATE   CAST $column AS integer   CAST $column 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. | 