{"id":22528877,"url":"https://github.com/zaneli/scalikejdbc-athena","last_synced_at":"2025-08-03T23:32:46.348Z","repository":{"id":48533390,"uuid":"116586028","full_name":"zaneli/scalikejdbc-athena","owner":"zaneli","description":"Library for using Amazon Athena JDBC Driver with ScalikeJDBC","archived":false,"fork":false,"pushed_at":"2023-11-19T13:27:51.000Z","size":65,"stargazers_count":20,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-11-19T14:29:46.132Z","etag":null,"topics":["amazon-athena","athena","athena-jdbc-driver","aws","scala","scalikejdbc"],"latest_commit_sha":null,"homepage":"","language":"Scala","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zaneli.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-01-07T17:41:20.000Z","updated_at":"2023-11-19T14:29:54.552Z","dependencies_parsed_at":"2023-11-19T14:43:02.172Z","dependency_job_id":null,"html_url":"https://github.com/zaneli/scalikejdbc-athena","commit_stats":null,"previous_names":[],"tags_count":7,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaneli%2Fscalikejdbc-athena","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaneli%2Fscalikejdbc-athena/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaneli%2Fscalikejdbc-athena/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zaneli%2Fscalikejdbc-athena/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zaneli","download_url":"https://codeload.github.com/zaneli/scalikejdbc-athena/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228571859,"owners_count":17938773,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-athena","athena","athena-jdbc-driver","aws","scala","scalikejdbc"],"created_at":"2024-12-07T07:12:51.510Z","updated_at":"2024-12-07T07:12:52.158Z","avatar_url":"https://github.com/zaneli.png","language":"Scala","funding_links":[],"categories":[],"sub_categories":[],"readme":"# scalikejdbc-athena\n\nLibrary for using [Amazon Athena](https://aws.amazon.com/athena/) JDBC Driver with [ScalikeJDBC](http://scalikejdbc.org/)\n\n![CI Status](https://github.com/zaneli/scalikejdbc-athena/actions/workflows/ci.yml/badge.svg)\n\n## setup\n\n- Download [Athena JDBC 2.x driver](https://docs.aws.amazon.com/athena/latest/ug/jdbc-v2.html)\n  - This library is basically depends on Athena JDBC 2.x driver.  \n    Choose your preferred or latest version in 2.x.  \n    If you encounter problems with a particular version, please feel free to [report it](https://github.com/zaneli/scalikejdbc-athena/issues).\n```sh\n\u003e mkdir lib\n\u003e curl -L -O https://downloads.athena.us-east-1.amazonaws.com/drivers/JDBC/SimbaAthenaJDBC-2.1.1.1000/AthenaJDBC42-2.1.1.1000.jar\n\u003e mv AthenaJDBC42-2.1.1.1000.jar lib/\n```\n\n- Add library dependencies to sbt build settings\n```scala\nlibraryDependencies ++= Seq(\n  \"org.scalikejdbc\" %% \"scalikejdbc\" % \"4.0.0\",\n  \"com.zaneli\" %% \"scalikejdbc-athena\" % \"0.3.0\"\n)\n```\n\n- Configure the JDBC Driver Options on `resources/application.conf`\n\n```\nathena {\n  default {\n    driver=\"com.simba.athena.jdbc.Driver\"\n    url=\"jdbc:awsathena://AwsRegion={REGION}\"\n    readOnly=\"false\"\n    S3OutputLocation=\"s3://query-results-bucket/folder/\"\n    AwsCredentialsProviderClass=\"com.simba.athena.amazonaws.auth.profile.ProfileCredentialsProvider\"\n    LogPath=\"logs/application.log\"\n    LogLevel=3\n  }\n}\n```\n\nIf you need to update partitions etc., set `readOnly=\"false\"`\n\n## Usage\n\n### Run query\n\n```scala\nimport scalikejdbc._\nimport scalikejdbc.athena._\n\nval name = \"elb_demo_001\"\nDB.athena { implicit s =\u003e\n  val r = sql\"\"\"\n          |SELECT * FROM default.elb_logs_raw_native\n          |WHERE elb_name = $name LIMIT 10;\n         \"\"\".stripMargin.map(_.toMap).list.apply()\n  r.foreach(println)\n}\n```\n\n### Delete `S3OutputLocation` after run query\n\n* set `S3OutputLocationPrefix` instead of `S3OutputLocation`\n```\nathena {\n  default {\n    driver=\"com.simba.athena.jdbc.Driver\"\n    url=\"jdbc:awsathena://AwsRegion={REGION}\"\n    readOnly=\"false\"\n    S3OutputLocationPrefix=\"s3://query-results-bucket/folder\"\n    AwsCredentialsProviderClass=\"com.simba.athena.amazonaws.auth.profile.ProfileCredentialsProvider\"\n    LogPath=\"logs/application.log\"\n    LogLevel=3\n  }\n}\n```\n\n* use [aws-java-sdk-s3](https://docs.aws.amazon.com/AmazonS3/latest/dev/DeletingMultipleObjectsUsingJava.html)\n\n```scala\nimport com.amazonaws.auth.profile.ProfileCredentialsProvider\nimport com.amazonaws.services.s3.AmazonS3ClientBuilder\nimport com.amazonaws.services.s3.model.DeleteObjectsRequest\n\nimport scalikejdbc._\nimport scalikejdbc.athena._\n\nimport scala.collection.JavaConverters._\n\nval s3Client = AmazonS3ClientBuilder.standard().withCredentials(new ProfileCredentialsProvider()).build()\nval regex = \"\"\"s3://(.+?)/(.+)\"\"\".r\n\nDB.athena { implicit s =\u003e\n  val r = sql\"...\".map(_.toMap).list.apply()\n  r.foreach(println)\n\n  s.getTmpStagingDir.foreach { // Some(\"s3://query-results-bucket/folder/${java.util.UUID.randomUUID}\")\n    case regex(bucketName, path) =\u003e\n      val keys = s3Client.listObjects(bucketName, path).getObjectSummaries.asScala\n        .map(s =\u003e new DeleteObjectsRequest.KeyVersion(s.getKey))\n      if (keys.nonEmpty) {\n        val delReq = new DeleteObjectsRequest(bucketName)\n        delReq.setKeys(keys.asJava)\n        s3Client.deleteObjects(delReq)\n      }\n  }\n}\n```\n\n---\n\nscalikejdbc-athena is inspired by [scalikejdbc-bigquery](https://github.com/ocadaruma/scalikejdbc-bigquery).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaneli%2Fscalikejdbc-athena","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzaneli%2Fscalikejdbc-athena","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzaneli%2Fscalikejdbc-athena/lists"}