Skip to content

Commit

Permalink
Separating Redshift connector from Database library into a new `AWS…
Browse files Browse the repository at this point in the history
…` library (#6550)

Related to #5777
  • Loading branch information
radeusgd authored May 4, 2023
1 parent a832c5e commit 41a8257
Show file tree
Hide file tree
Showing 111 changed files with 400 additions and 187 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@
`Text.write`.][6459]
- [Implemented `create_database_table` allowing saving queries as database
tables.][6467]
- [Moved `Redshift` connector into a separate `AWS` library.][6550]

[debug-shortcuts]:
https://github.com/enso-org/enso/blob/develop/app/gui/docs/product/shortcuts.md#debug
Expand Down Expand Up @@ -614,6 +615,7 @@
[6429]: https://github.com/enso-org/enso/pull/6429
[6459]: https://github.com/enso-org/enso/pull/6459
[6467]: https://github.com/enso-org/enso/pull/6467
[6550]: https://github.com/enso-org/enso/pull/6550

#### Enso Compiler

Expand Down
54 changes: 48 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@ GatherLicenses.distributions := Seq(
),
makeStdLibDistribution("Table", Distribution.sbtProjects(`std-table`)),
makeStdLibDistribution("Database", Distribution.sbtProjects(`std-database`)),
makeStdLibDistribution("Image", Distribution.sbtProjects(`std-image`))
makeStdLibDistribution("Image", Distribution.sbtProjects(`std-image`)),
makeStdLibDistribution("AWS", Distribution.sbtProjects(`std-aws`))
)

GatherLicenses.licenseConfigurations := Set("compile")
Expand Down Expand Up @@ -295,6 +296,7 @@ lazy val enso = (project in file("."))
`std-google-api`,
`std-image`,
`std-table`,
`std-aws`,
`simple-httpbin`,
`enso-test-java-helpers`
)
Expand Down Expand Up @@ -1376,6 +1378,7 @@ lazy val runtime = (project in file("engine/runtime"))
.dependsOn(`std-database` / Compile / packageBin)
.dependsOn(`std-google-api` / Compile / packageBin)
.dependsOn(`std-table` / Compile / packageBin)
.dependsOn(`std-aws` / Compile / packageBin)
.value
)
.settings(
Expand Down Expand Up @@ -1905,6 +1908,8 @@ val `google-api-polyglot-root` =
stdLibComponentRoot("Google_Api") / "polyglot" / "java"
val `database-polyglot-root` =
stdLibComponentRoot("Database") / "polyglot" / "java"
val `std-aws-polyglot-root` =
stdLibComponentRoot("AWS") / "polyglot" / "java"

lazy val `std-base` = project
.in(file("std-bits") / "base")
Expand Down Expand Up @@ -2064,10 +2069,35 @@ lazy val `std-database` = project
autoScalaLibrary := false,
Compile / packageBin / artifactPath :=
`database-polyglot-root` / "std-database.jar",
libraryDependencies ++= Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided",
"org.xerial" % "sqlite-jdbc" % sqliteVersion,
"org.postgresql" % "postgresql" % "42.4.0"
),
Compile / packageBin := Def.task {
val result = (Compile / packageBin).value
val _ = StdBits
.copyDependencies(
`database-polyglot-root`,
Seq("std-database.jar"),
ignoreScalaLibrary = true
)
.value
result
}.value
)
.dependsOn(`std-base` % "provided")
.dependsOn(`std-table` % "provided")

lazy val `std-aws` = project
.in(file("std-bits") / "aws")
.settings(
frgaalJavaCompilerSetting,
autoScalaLibrary := false,
Compile / packageBin / artifactPath :=
`std-aws-polyglot-root` / "std-aws.jar",
libraryDependencies ++= Seq(
"org.netbeans.api" % "org-openide-util-lookup" % netbeansApiVersion % "provided",
"org.xerial" % "sqlite-jdbc" % sqliteVersion,
"org.postgresql" % "postgresql" % "42.4.0",
"com.amazon.redshift" % "redshift-jdbc42" % "2.1.0.9",
"com.amazonaws" % "aws-java-sdk-core" % "1.12.273",
"com.amazonaws" % "aws-java-sdk-redshift" % "1.12.273",
Expand All @@ -2077,15 +2107,17 @@ lazy val `std-database` = project
val result = (Compile / packageBin).value
val _ = StdBits
.copyDependencies(
`database-polyglot-root`,
Seq("std-database.jar"),
`std-aws-polyglot-root`,
Seq("std-aws.jar"),
ignoreScalaLibrary = true
)
.value
result
}.value
)
.dependsOn(`std-base` % "provided")
.dependsOn(`std-table` % "provided")
.dependsOn(`std-database` % "provided")

/* Note [Native Image Workaround for GraalVM 20.2]
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down Expand Up @@ -2191,7 +2223,14 @@ runEngineDistribution := {

val allStdBitsSuffix = List("All", "AllWithIndex")
val stdBitsProjects =
List("Base", "Database", "Google_Api", "Image", "Table") ++ allStdBitsSuffix
List(
"AWS",
"Base",
"Database",
"Google_Api",
"Image",
"Table"
) ++ allStdBitsSuffix
val allStdBits: Parser[String] =
stdBitsProjects.map(v => v: Parser[String]).reduce(_ | _)

Expand Down Expand Up @@ -2240,13 +2279,16 @@ pkgStdLibInternal := Def.inputTask {
(`std-table` / Compile / packageBin).value
case "TestHelpers" =>
(`enso-test-java-helpers` / Compile / packageBin).value
case "AWS" =>
(`std-aws` / Compile / packageBin).value
case _ if buildAllCmd =>
(`std-base` / Compile / packageBin).value
(`enso-test-java-helpers` / Compile / packageBin).value
(`std-table` / Compile / packageBin).value
(`std-database` / Compile / packageBin).value
(`std-image` / Compile / packageBin).value
(`std-google-api` / Compile / packageBin).value
(`std-aws` / Compile / packageBin).value
case _ =>
}
val libs =
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,2 @@
/************************************************************************
* Licensed under Public Domain (CC0) *
* *
* To the extent possible under law, the person who associated CC0 with *
* this code has waived all copyright and related or neighboring *
* rights to this code. *
* *
* You should have received a copy of the CC0 legalcode along with this *
* work. If not, see <http://creativecommons.org/publicdomain/zero/1.0/>.*
************************************************************************/
See https://github.com/reactive-streams/reactive-streams-jvm for more information.

77 changes: 77 additions & 0 deletions distribution/lib/Standard/AWS/0.0.0-dev/THIRD-PARTY/NOTICE
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
Enso
Copyright 2020 - 2023 New Byte Order sp. z o. o.

'redshift-jdbc42', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.amazon.redshift.redshift-jdbc42-2.1.0.9`.


'aws-java-sdk-core', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.amazonaws.aws-java-sdk-core-1.12.273`.


'aws-java-sdk-redshift', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.amazonaws.aws-java-sdk-redshift-1.12.273`.


'aws-java-sdk-sts', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.amazonaws.aws-java-sdk-sts-1.12.273`.


'jmespath-java', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.amazonaws.jmespath-java-1.12.273`.


'jackson-annotations', licensed under the The Apache Software License, Version 2.0, is distributed with the AWS.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.core.jackson-annotations-2.12.6`.


'jackson-core', licensed under the The Apache Software License, Version 2.0, is distributed with the AWS.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.core.jackson-core-2.12.6`.


'jackson-databind', licensed under the The Apache Software License, Version 2.0, is distributed with the AWS.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.core.jackson-databind-2.12.6.1`.


'jackson-dataformat-cbor', licensed under the The Apache Software License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `com.fasterxml.jackson.dataformat.jackson-dataformat-cbor-2.12.6`.


'commons-codec', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `commons-codec.commons-codec-1.15`.


'commons-logging', licensed under the The Apache Software License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `commons-logging.commons-logging-1.1.3`.


'joda-time', licensed under the Apache 2, is distributed with the AWS.
The license information can be found along with the copyright notices.
Copyright notices related to this dependency can be found in the directory `joda-time.joda-time-2.8.1`.


'httpclient', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.apache.httpcomponents.httpclient-4.5.13`.


'httpcore', licensed under the Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `org.apache.httpcomponents.httpcore-4.4.13`.


'ion-java', licensed under the The Apache License, Version 2.0, is distributed with the AWS.
The license file can be found at `licenses/APACHE2.0`.
Copyright notices related to this dependency can be found in the directory `software.amazon.ion.ion-java-1.0.2`.

10 changes: 10 additions & 0 deletions distribution/lib/Standard/AWS/0.0.0-dev/package.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: AWS
namespace: Standard
version: 0.0.0-dev
license: APLv2
authors:
- name: Enso Team
email: [email protected]
maintainers:
- name: Enso Team
email: [email protected]
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,32 @@ import Standard.Table.Internal.Naming_Helpers.Naming_Helpers
from Standard.Table import Aggregate_Column
from Standard.Table import Value_Type

import project.Connection.Connection.Connection
import project.Data.Dialect
import project.Data.SQL.Builder
import project.Data.SQL_Statement.SQL_Statement
import project.Data.SQL_Type.SQL_Type
import project.Data.Table.Table
import project.Internal.Base_Generator
import project.Internal.Column_Fetcher.Column_Fetcher
import project.Internal.Column_Fetcher as Column_Fetcher_Module
import project.Internal.Error_Mapper.Error_Mapper
import project.Internal.IR.Context.Context
import project.Internal.IR.From_Spec.From_Spec
import project.Internal.IR.Internal_Column.Internal_Column
import project.Internal.IR.SQL_Expression.SQL_Expression
import project.Internal.IR.SQL_Join_Kind.SQL_Join_Kind
import project.Internal.IR.Order_Descriptor.Order_Descriptor
import project.Internal.IR.Query.Query
import project.Internal.Postgres.Postgres_Dialect
import project.Internal.Common.Database_Join_Helper
import project.Internal.Postgres.Postgres_Type_Mapping.Postgres_Type_Mapping
import project.Internal.Redshift.Redshift_Error_Mapper.Redshift_Error_Mapper
import project.Internal.SQL_Type_Mapping.SQL_Type_Mapping
import project.Internal.SQL_Type_Reference.SQL_Type_Reference
import project.Internal.Statement_Setter.Statement_Setter
from project.Errors import Unsupported_Database_Operation
import Standard.Database.Connection.Connection.Connection
import Standard.Database.Data.Dialect
import Standard.Database.Data.SQL.Builder
import Standard.Database.Data.SQL_Statement.SQL_Statement
import Standard.Database.Data.SQL_Type.SQL_Type
import Standard.Database.Data.Table.Table
import Standard.Database.Internal.Base_Generator
import Standard.Database.Internal.Column_Fetcher.Column_Fetcher
import Standard.Database.Internal.Column_Fetcher as Column_Fetcher_Module
import Standard.Database.Internal.Error_Mapper.Error_Mapper
import Standard.Database.Internal.IR.Context.Context
import Standard.Database.Internal.IR.From_Spec.From_Spec
import Standard.Database.Internal.IR.Internal_Column.Internal_Column
import Standard.Database.Internal.IR.SQL_Expression.SQL_Expression
import Standard.Database.Internal.IR.SQL_Join_Kind.SQL_Join_Kind
import Standard.Database.Internal.IR.Order_Descriptor.Order_Descriptor
import Standard.Database.Internal.IR.Query.Query
import Standard.Database.Internal.Postgres.Postgres_Dialect
import Standard.Database.Internal.Common.Database_Join_Helper
import Standard.Database.Internal.Postgres.Postgres_Type_Mapping.Postgres_Type_Mapping
import Standard.Database.Internal.SQL_Type_Mapping.SQL_Type_Mapping
import Standard.Database.Internal.SQL_Type_Reference.SQL_Type_Reference
import Standard.Database.Internal.Statement_Setter.Statement_Setter
from Standard.Database.Errors import Unsupported_Database_Operation

import project.Database.Redshift.Internal.Redshift_Error_Mapper.Redshift_Error_Mapper

## PRIVATE

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from Standard.Base import all

from project.Errors import SQL_Error
from Standard.Database.Errors import SQL_Error

## PRIVATE
type Redshift_Error_Mapper
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
from Standard.Base import all

import project.Connection.Client_Certificate.Client_Certificate
import project.Connection.Connection.Connection
import project.Connection.Connection_Options.Connection_Options
import project.Connection.Credentials.Credentials
import project.Connection.SSL_Mode.SSL_Mode
import project.Data.Dialect
import project.Internal.JDBC_Connection
import project.Internal.Postgres.Pgpass
import Standard.Database.Connection.Client_Certificate.Client_Certificate
import Standard.Database.Connection.Connection.Connection
import Standard.Database.Connection.Connection_Options.Connection_Options
import Standard.Database.Connection.Credentials.Credentials
import Standard.Database.Connection.SSL_Mode.SSL_Mode
import Standard.Database.Internal.JDBC_Connection
import Standard.Database.Internal.Postgres.Pgpass

import project.Database.Redshift.Internal.Redshift_Dialect

polyglot java import com.amazon.redshift.jdbc.Driver
polyglot java import java.util.Properties
polyglot java import org.enso.database.JDBCProxy

type Redshift_Options
type Redshift_Details
## Connect to a AWS Redshift database.

Arguments:
Expand All @@ -40,7 +40,7 @@ type Redshift_Options
java_props.setProperty pair.first pair.second

jdbc_connection = JDBC_Connection.create self.jdbc_url properties
Connection.Value jdbc_connection Dialect.redshift
Connection.Value jdbc_connection Redshift_Dialect.redshift

## PRIVATE
Provides the jdbc url for the connection.
Expand All @@ -49,7 +49,7 @@ type Redshift_Options
prefix = case self.credentials of
_ : AWS_Credential -> 'jdbc:redshift:iam://'
_ -> 'jdbc:redshift://'
prefix + self.host + ':' + self.port.to_text + (if self.schema == '' then '' else '/' + self.schema)
prefix + self.host + ':' + self.port.to_text + '/' + self.schema

## PRIVATE
Provides the properties for the connection.
Expand Down
7 changes: 7 additions & 0 deletions distribution/lib/Standard/AWS/0.0.0-dev/src/Main.enso
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import project.Database.Redshift.Redshift_Details.Redshift_Details
import project.Database.Redshift.Redshift_Details.AWS_Credential

export project.Database.Redshift.Redshift_Details.Redshift_Details
export project.Database.Redshift.Redshift_Details.AWS_Credential

from project.Database.Redshift.Redshift_Details.Redshift_Details export Redshift
Loading

0 comments on commit 41a8257

Please sign in to comment.