Skip to content

Commit 7c4880d

Browse files
committed
First quicksight codes. 🚀
1 parent b3837c6 commit 7c4880d

File tree

11 files changed

+1924
-1
lines changed

11 files changed

+1924
-1
lines changed

awswrangler/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import logging
99

10-
from awswrangler import athena, catalog, cloudwatch, db, emr, exceptions, s3 # noqa
10+
from awswrangler import athena, catalog, cloudwatch, db, emr, exceptions, quicksight, s3 # noqa
1111
from awswrangler.__metadata__ import __description__, __license__, __title__, __version__ # noqa
1212
from awswrangler._utils import get_account_id # noqa
1313

awswrangler/_data_types.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,34 @@ def athena2redshift( # pylint: disable=too-many-branches,too-many-return-statem
114114
raise exceptions.UnsupportedType(f"Unsupported Athena type: {dtype}") # pragma: no cover
115115

116116

117+
def athena2quicksight(dtype: str) -> str: # pylint: disable=too-many-branches,too-many-return-statements
118+
"""Athena to Quicksight data types conversion."""
119+
dtype = dtype.lower()
120+
if dtype == "smallint":
121+
return "INTEGER"
122+
if dtype in ("int", "integer"):
123+
return "INTEGER"
124+
if dtype == "bigint":
125+
return "INTEGER"
126+
if dtype == "float":
127+
return "DECIMAL"
128+
if dtype == "double":
129+
return "DECIMAL"
130+
if dtype in ("boolean", "bool"):
131+
return "BOOLEAN"
132+
if dtype in ("string", "char", "varchar"):
133+
return "STRING"
134+
if dtype == "timestamp":
135+
return "DATETIME"
136+
if dtype == "date":
137+
return "DATETIME"
138+
if dtype.startswith("decimal"):
139+
return "DECIMAL"
140+
if dtype in ("binary" or "varbinary"):
141+
return "BIT"
142+
raise exceptions.UnsupportedType(f"Unsupported Athena type: {dtype}") # pragma: no cover
143+
144+
117145
def pyarrow2athena(dtype: pa.DataType) -> str: # pylint: disable=too-many-branches,too-many-return-statements
118146
"""Pyarrow to Athena data types conversion."""
119147
if pa.types.is_int8(dtype):

awswrangler/quicksight/__init__.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
"""Amazon QuickSight Module."""
2+
3+
from awswrangler.quicksight._cancel import * # noqa
4+
from awswrangler.quicksight._create import * # noqa
5+
from awswrangler.quicksight._delete import * # noqa
6+
from awswrangler.quicksight._describe import * # noqa
7+
from awswrangler.quicksight._get import * # noqa
8+
from awswrangler.quicksight._list import * # noqa
9+
from awswrangler.quicksight._utils import list_ingestions # noqa

awswrangler/quicksight/_cancel.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"""Amazon QuickSight Cancel Module."""
2+
3+
import logging
4+
from typing import Optional
5+
6+
import boto3 # type: ignore
7+
8+
from awswrangler import _utils, exceptions
9+
from awswrangler.quicksight import _get
10+
11+
_logger: logging.Logger = logging.getLogger(__name__)
12+
13+
14+
def cancel_ingestion(
15+
ingestion_id: str = None,
16+
dataset_name: Optional[str] = None,
17+
dataset_id: Optional[str] = None,
18+
account_id: Optional[str] = None,
19+
boto3_session: Optional[boto3.Session] = None,
20+
) -> None:
21+
"""Cancel an ongoing ingestion of data into SPICE.
22+
23+
Note
24+
----
25+
You must pass a not None value for ``dataset_name`` or ``dataset_id`` argument.
26+
27+
Parameters
28+
----------
29+
ingestion_id : str
30+
Ingestion ID.
31+
dataset_name : str, optional
32+
Dataset name.
33+
dataset_id : str, optional
34+
Dataset ID.
35+
account_id : str, optional
36+
If None, the account ID will be inferred from your boto3 session.
37+
boto3_session : boto3.Session(), optional
38+
Boto3 Session. The default boto3 session will be used if boto3_session receive None.
39+
40+
Returns
41+
-------
42+
None
43+
None.
44+
45+
Examples
46+
--------
47+
>>> import awswrangler as wr
48+
>>> wr.quicksight.cancel_ingestion(ingestion_id="...", dataset_name="...")
49+
"""
50+
if (dataset_name is None) and (dataset_id is None):
51+
raise exceptions.InvalidArgument("You must pass a not None name or dataset_id argument.")
52+
session: boto3.Session = _utils.ensure_session(session=boto3_session)
53+
if account_id is None:
54+
account_id = _utils.get_account_id(boto3_session=session)
55+
if (dataset_id is None) and (dataset_name is not None):
56+
dataset_id = _get.get_dataset_id(name=dataset_name, account_id=account_id, boto3_session=session)
57+
client: boto3.client = _utils.client(service_name="quicksight", session=session)
58+
client.cancel_ingestion(IngestionId=ingestion_id, AwsAccountId=account_id, DataSetId=dataset_id)

0 commit comments

Comments
 (0)