Skip to content

Instantly share code, notes, and snippets.

@arihantsurana
Created July 22, 2020 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arihantsurana/2361c435355ab0131636949428ce4fc4 to your computer and use it in GitHub Desktop.
Save arihantsurana/2361c435355ab0131636949428ce4fc4 to your computer and use it in GitHub Desktop.
And example use of writing SQL to generate performant Athena tables
from hip_data_tools.etl.athena_to_athena import AthenaToAthena, AthenaToAthenaSettings
from hip_data_tools.aws.common import AwsConnectionSettings
aws_conn = AwsConnectionSettings(
region="ap-southeast-2",
secrets_manager=None,
profile="default") # to access the default aws profile on your machine
etl = AthenaToAthena(
settings=AthenaToAthenaSettings(
source_sql="SELECT 'abc' as abc",
source_database="test",
target_database="test",
target_table="test_table",
target_data_format="PARQUET",
target_s3_bucket="test_bucket",
target_s3_dir="test_dir",
target_partition_columns=["abc"],
connection_settings=aws_conn
)
)
sql = etl.generate_create_table_statement()
print(sql)
etl.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment