awswrangler.quicksight.create_athena_dataset

awswrangler.quicksight.create_athena_dataset(name: str, database: str | None = None, table: str | None = None, sql: str | None = None, sql_name: str = 'CustomSQL', data_source_name: str | None = None, data_source_arn: str | None = None, import_mode: str = 'DIRECT_QUERY', allowed_to_use: List[str] | None = None, allowed_to_manage: List[str] | None = None, logical_table_alias: str = 'LogicalTable', rename_columns: Dict[str, str] | None = None, cast_columns_types: Dict[str, str] | None = None, tag_columns: Dict[str, List[Dict[str, Any]]] | None = None, tags: Dict[str, str] | None = None, account_id: str | None = None, boto3_session: Session | None = None, namespace: str = 'default') str

Create a QuickSight dataset.

Note

You will not be able to see the the dataset in the console if you not pass your username to one of the allowed_* arguments.

Note

You must pass database/table OR sql argument.

Note

You must pass data_source_name OR data_source_arn argument.

Parameters:
  • name (str) – Dataset name.

  • database (str) – Athena’s database name.

  • table (str) – Athena’s table name.

  • sql (str) – Use a SQL query to define your table.

  • sql_name (str) – Query name.

  • data_source_name (str, optional) – QuickSight data source name.

  • data_source_arn (str, optional) – QuickSight data source ARN.

  • import_mode (str) – Indicates whether you want to import the data into SPICE. ‘SPICE’|’DIRECT_QUERY’

  • tags (Dict[str, str], optional) – Key/Value collection to put on the Cluster. e.g. {“foo”: “boo”, “bar”: “xoo”}

  • allowed_to_use (optional) – List of usernames that will be allowed to see and use the data source. e.g. [“john”, “Mary”]

  • allowed_to_manage (optional) – List of usernames that will be allowed to see, use, update and delete the data source. e.g. [“Mary”]

  • logical_table_alias (str) – A display name for the logical table.

  • rename_columns (Dict[str, str], optional) – Dictionary to map column renames. e.g. {“old_name”: “new_name”, “old_name2”: “new_name2”}

  • cast_columns_types (Dict[str, str], optional) – Dictionary to map column casts. e.g. {“col_name”: “STRING”, “col_name2”: “DECIMAL”} Valid types: ‘STRING’|’INTEGER’|’DECIMAL’|’DATETIME’

  • tag_columns (Dict[str, List[Dict[str, Any]]], optional) –

    Dictionary to map column tags. e.g. {“col_name”: [{ “ColumnGeographicRole”: “CITY” }],

    ”col_name2”: [{ “ColumnDescription”: { “Text”: “description” }}]}

    Valid geospatial roles: ‘COUNTRY’|’STATE’|’COUNTY’|’CITY’|’POSTCODE’|’LONGITUDE’|’LATITUDE’

  • account_id (str, optional) – If None, the account ID will be inferred from your boto3 session.

  • boto3_session (boto3.Session(), optional) – Boto3 Session. The default boto3 session will be used if boto3_session receive None.

  • namespace (str) – The namespace. Currently, you should set this to default.

Returns:

Dataset ID.

Return type:

str

Examples

>>> import awswrangler as wr
>>> dataset_id = wr.quicksight.create_athena_dataset(
...     name="...",
...     database="..."
...     table="..."
...     data_source_name="..."
...     allowed_to_manage=["Mary"]
... )