-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[COST-5551] add config for local Glue Data Catalog utilization (#5471)
- Loading branch information
Showing
6 changed files
with
92 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,21 @@ | ||
connector.name=hive | ||
hive.metastore=glue | ||
hive.storage-format=Parquet | ||
hive.compression-codec=SNAPPY | ||
hive.collect-column-statistics-on-write=true | ||
hive.recursive-directories=true | ||
hive.compression-codec=SNAPPY | ||
hive.non-managed-table-writes-enabled=true | ||
hive.recursive-directories=true | ||
hive.storage-format=Parquet | ||
|
||
fs.hadoop.enabled=false | ||
fs.native-s3.enabled=true | ||
s3.region=${ENV:S3_REGION} | ||
s3.endpoint=${ENV:S3_ENDPOINT} | ||
s3.region=${ENV:AWS_REGION} | ||
s3.endpoint=${ENV:MINIO_ENDPOINT} | ||
s3.aws-access-key=${ENV:S3_ACCESS_KEY} | ||
s3.aws-secret-key=${ENV:S3_SECRET} | ||
s3.path-style-access=true | ||
|
||
hive.metastore.glue.default-warehouse-dir=s3://${ENV:S3_BUCKET_NAME}/data | ||
hive.metastore.glue.region=${ENV:S3_REGION} | ||
hive.metastore.glue.aws-access-key=${ENV:S3_ACCESS_KEY} | ||
hive.metastore.glue.aws-secret-key=${ENV:S3_SECRET} | ||
hive.metastore.glue.catalogid=${ENV:AWS_CATALOG_ID} | ||
hive.metastore.glue.default-warehouse-dir=${ENV:TRINO_S3A_OR_S3}://${ENV:S3_BUCKET_NAME}/data | ||
hive.metastore.glue.region=${ENV:AWS_REGION} | ||
hive.metastore.glue.aws-access-key=${ENV:AWS_ACCESS_KEY_ID} | ||
hive.metastore.glue.aws-secret-key=${ENV:AWS_SECRET_ACCESS_KEY} | ||
# hive.metastore.glue.skip-archive=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# | ||
# Copyright 2024 Red Hat Inc. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
"""Clear out our glue testing data.""" | ||
import argparse | ||
import os | ||
|
||
import boto3 | ||
|
||
|
||
def delete_glue_data(schema): | ||
# this client requires AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY set in env | ||
glue_client = boto3.client("glue", region_name="us-east-1") | ||
try: | ||
glue_client.delete_database(Name=schema) | ||
print(f"Deleting database: {schema}") | ||
except Exception as e: | ||
print(f"Failed to delete db: {schema}, its possible it was already deleted: {e}") | ||
|
||
# cleanup S3 data | ||
endpoint = os.environ.get("S3_ENDPOINT") | ||
bucket_name = os.environ.get("S3_BUCKET_NAME") | ||
credentials = { | ||
"aws_access_key_id": os.environ.get("S3_ACCESS_KEY"), | ||
"aws_secret_access_key": os.environ.get("S3_SECRET"), | ||
"region_name": os.environ.get("S3_REGION") or "us-east-1", | ||
} | ||
path_prefixes = { | ||
"s3_csv_path": f"data/csv/{schema}", | ||
"s3_parquet_path": f"data/parquet/{schema}", | ||
"s3_daily_parquet": f"data/parquet/daily/{schema}", | ||
"s3_schema_db_path": f"data/{schema}", | ||
} | ||
|
||
s3_client = boto3.client("s3", endpoint_url=endpoint, **credentials) | ||
for _, file_prefix in path_prefixes.items(): | ||
paginator = s3_client.get_paginator("list_objects_v2") | ||
for obj_list in paginator.paginate(Bucket=bucket_name, Prefix=file_prefix): | ||
if "Contents" in obj_list: | ||
s3_client.delete_objects( | ||
Bucket=bucket_name, Delete={"Objects": [{"Key": x["Key"]} for x in obj_list["Contents"]]} | ||
) | ||
print(f"Removed s3 files for prefix: {file_prefix}") | ||
|
||
|
||
def main(): | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("schema") | ||
args = parser.parse_args() | ||
|
||
delete_glue_data(args.schema) | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters