{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/amazon-clean-rooms/json-schema/amazon-clean-rooms-create-intermediate-table-analysis-rule-input-schema.json",
  "title": "CreateIntermediateTableAnalysisRuleInput",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/amazon-clean-rooms-analysisrule-api-openapi.yml#/components/schemas/CreateIntermediateTableAnalysisRuleInput",
  "type": "object",
  "properties": {
    "membershipIdentifier": {
      "type": "string",
      "description": "The unique identifier of the membership that contains the intermediate table."
    },
    "intermediateTableIdentifier": {
      "type": "string",
      "description": "The unique identifier of the intermediate table for which to create the analysis rule."
    },
    "analysisRuleType": {
      "type": "string",
      "enum": [
        "CUSTOM"
      ],
      "description": "The type of analysis rule to create. Currently, only CUSTOM is supported."
    },
    "analysisRulePolicy": {
      "$ref": "#/$defs/IntermediateTableAnalysisRulePolicy"
    }
  },
  "required": [
    "membershipIdentifier",
    "intermediateTableIdentifier",
    "analysisRuleType",
    "analysisRulePolicy"
  ],
  "$defs": {
    "AggregationThreshold": {
      "type": "object",
      "properties": {
        "identityColumns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The identity column, such as user_id, whose distinct values Clean Rooms counts to enforce minimum aggregation thresholds. Currently, you can specify only one column, and its data type must be string, varchar, or char."
        },
        "minimumIdentityCount": {
          "type": "integer",
          "description": "The minimum number of distinct identities that each query output group must represent. This threshold applies to all output columns in the table. To override this threshold for a specific column, use outputColumnThresholds."
        },
        "type": {
          "type": "string",
          "enum": [
            "COUNT_DISTINCT"
          ],
          "description": "The type of aggregation that the threshold enforces. Currently, the only supported value is COUNT_DISTINCT, which counts the distinct values in the identity column."
        },
        "outputColumnThresholds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/OutputColumnThreshold"
          },
          "description": "The per-column overrides of minimumIdentityCount. An output column without an override uses minimumIdentityCount."
        },
        "allowedAggregateExpressionType": {
          "type": "string",
          "enum": [
            "COLUMNS_ONLY",
            "ANY_EXPRESSION"
          ],
          "description": "Specifies whether a query can aggregate a transformed column. This applies to the arguments of both aggregate and window functions. Valid values are: COLUMNS_ONLY – A query can aggregate only a direct column reference, such as SUM(amount), or a constant. Clean Rooms rejects a query that transforms a column and then aggregates it, such as SUM(amount * 2) or SUM(ROUND(amount)). ANY_EXPRESSION – A query can aggregate any expression. This includes arithmetic, such as SUM(price * quantity); a cast, such as SUM(CAST(amount AS DECIMAL)); a nested function call, such as SUM(COALESCE(amount, 0)); and a"
        }
      },
      "required": [
        "identityColumns",
        "minimumIdentityCount",
        "type",
        "allowedAggregateExpressionType"
      ]
    },
    "ComparisonControls": {
      "type": "object",
      "properties": {
        "allowedLiteralComparisonColumns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The columns that a query can compare to literal values, for example, in a WHERE clause. Clean Rooms rejects a query that compares any other column to a literal value. Specify an empty list to block literal comparison on every column. You can't specify a column that you also use as an identity column in an aggregation threshold."
        },
        "allowedColumnComparisonColumns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The columns that a query can compare to another column, for example, in a join, a WHERE clause, a GROUP BY clause, or a window function. Clean Rooms rejects a query that uses any other column in a column-to-column comparison. Specify an empty list to block column-to-column comparison on every column."
        }
      },
      "required": [
        "allowedLiteralComparisonColumns",
        "allowedColumnComparisonColumns"
      ]
    },
    "DifferentialPrivacyColumn": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the column, such as user_id, that contains the unique identifier of your users, whose privacy you want to protect. If you want to turn on differential privacy for two or more tables in a collaboration, you must configure the same column as the user identifier column in both analysis rules."
        }
      },
      "required": [
        "name"
      ]
    },
    "DifferentialPrivacyConfiguration": {
      "type": "object",
      "properties": {
        "columns": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/DifferentialPrivacyColumn"
          },
          "description": "The name of the column (such as user_id) that contains the unique identifier of your users whose privacy you want to protect. If you want to turn on diﬀerential privacy for two or more tables in a collaboration, you must conﬁgure the same column as the user identiﬁer column in both analysis rules."
        }
      },
      "required": [
        "columns"
      ]
    },
    "IntermediateTableAnalysisRuleCustom": {
      "type": "object",
      "properties": {
        "allowedAnalyses": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of allowed analyses that can be performed on the intermediate table."
        },
        "additionalAnalyses": {
          "type": "string",
          "enum": [
            "ALLOWED",
            "REQUIRED",
            "NOT_ALLOWED"
          ],
          "description": "The setting that controls whether additional analyses are allowed on the intermediate table."
        },
        "allowedAdditionalAnalyses": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of allowed additional analyses for the intermediate table."
        },
        "allowedAnalysisProviders": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of Amazon Web Services account IDs for the allowed analysis providers."
        },
        "allowedResultReceivers": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of Amazon Web Services account IDs that are allowed to receive results from queries run on the intermediate table."
        },
        "differentialPrivacy": {
          "$ref": "#/$defs/DifferentialPrivacyConfiguration"
        },
        "disallowedOutputColumns": {
          "type": "array",
          "items": {
            "type": "string"
          },
          "description": "The list of columns that are not allowed in the query output."
        },
        "aggregationThresholds": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/AggregationThreshold"
          },
          "description": "The aggregation thresholds that each query output group must satisfy. Clean Rooms filters out any group that represents fewer than the specified number of distinct identities. You can specify at most one threshold. You can't use aggregation thresholds with differential privacy, or when allowedAnalyses allows only jobs."
        },
        "comparisonControls": {
          "$ref": "#/$defs/ComparisonControls"
        }
      }
    },
    "IntermediateTableAnalysisRulePolicy": {
      "type": "object",
      "properties": {
        "v1": {
          "$ref": "#/$defs/IntermediateTableAnalysisRulePolicyV1"
        }
      },
      "description": "Exactly one member is set."
    },
    "IntermediateTableAnalysisRulePolicyV1": {
      "type": "object",
      "properties": {
        "custom": {
          "$ref": "#/$defs/IntermediateTableAnalysisRuleCustom"
        }
      },
      "description": "Exactly one member is set."
    },
    "OutputColumnThreshold": {
      "type": "object",
      "properties": {
        "outputColumnName": {
          "type": "string",
          "description": "The name of the output column that the override applies to. You can specify each column only once."
        },
        "minimumIdentityCount": {
          "type": "integer",
          "description": "The minimum number of distinct identities that each query output group must represent for this column. Specify 0 to exempt the column from the threshold, or a value of 2 or greater to enforce a threshold."
        }
      },
      "required": [
        "outputColumnName",
        "minimumIdentityCount"
      ]
    }
  }
}