Skip to content

Commit

Permalink
Merge pull request #35 from metabolicdata/set_prefix_athena_filesink
Browse files Browse the repository at this point in the history
Set prefix Athena filesink
  • Loading branch information
margon8 authored Apr 5, 2024
2 parents 2b76364 + 9bbb08d commit 30bf16c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,11 @@ gradle-app.setting
terraform/.terraform

old_envs/*

### VSCode ###
.bloop/
.metals/
.vscode/
project/.bloop/
project/metals.sbt
project/project/
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,21 @@ class AthenaAction extends AfterAction with Logging {

val options = config.environment

val s3Path = config.sink.asInstanceOf[FileSink].path
.replace("version=1/", "")
val region = options.region
val dbName = options.dbName
val prefix = ConfigUtilsService.getTablePrefix(options.namespaces, s3Path)
val tableName = prefix+ConfigUtilsService.getTableName(config)

val athena = new AthenaCatalogueService()(region)

config.sink match {
case sink: FileSink =>
sink.format match {
case IOFormat.DELTA =>

logger.info(f"After Action $name: Creating Delta Table for ${config.name}")

athena.dropView(dbName, tableName)

val s3Path = sink.path.replaceAll("version=\\d+", "")
val prefix =
ConfigUtilsService.getTablePrefix(options.namespaces, s3Path)
val tableName = prefix + ConfigUtilsService.getTableName(config)
athena.dropView(dbName, tableName)
athena.createDeltaTable(dbName, tableName, s3Path)

case _ =>
Expand Down

0 comments on commit 30bf16c

Please sign in to comment.