From 720a1c06f18bece28e698cfbd187862e196ee68a Mon Sep 17 00:00:00 2001 From: Gavin Ray Date: Wed, 3 Jul 2024 11:51:57 -0400 Subject: [PATCH] Updates --- ndc-cli.dockerfile | 24 +- ndc-cli/src/main/kotlin/io/hasura/cli/main.kt | 23 +- .../.hasura-connector/connector-metadata.yaml | 11 +- ndc-connector-mysql/README.md | 4 +- .../.hasura-connector/connector-metadata.yaml | 10 +- ndc-connector-oracle/README.md | 4 +- ndc-connector-oracle/configuration.json | 1429 ++++++++--------- .../.hasura-connector/connector-metadata.yaml | 8 +- ndc-connector-snowflake/README.md | 6 +- 9 files changed, 720 insertions(+), 799 deletions(-) diff --git a/ndc-cli.dockerfile b/ndc-cli.dockerfile index aa17b51..114e82a 100644 --- a/ndc-cli.dockerfile +++ b/ndc-cli.dockerfile @@ -1,12 +1,26 @@ -FROM registry.access.redhat.com/ubi9/openjdk-17:1.18-4 +# Build stage +FROM registry.access.redhat.com/ubi9/openjdk-21:1.20-2 AS build ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' - -WORKDIR /app -COPY . /app +WORKDIR /build +COPY . /build # Run Gradle build USER root RUN ./gradlew :ndc-cli:installDist --no-daemon --console=plain -x test -ENTRYPOINT ["/app/ndc-cli/build/install/ndc-cli/bin/ndc-cli"] +# Final stage +FROM registry.access.redhat.com/ubi9/openjdk-21:1.20-2 + +ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' +WORKDIR /app + +# The "/app/output" directory is used by the NDC CLI "update" command as a bind-mount volume: +# +# docker run \ +# -e HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH \ +# -v ${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH}:/app/output +RUN mkdir -p /app/output && chmod 777 /app/output + +COPY --from=build /build/ndc-cli/build/install/ndc-cli /app +ENTRYPOINT ["/app/bin/ndc-cli"] diff --git a/ndc-cli/src/main/kotlin/io/hasura/cli/main.kt b/ndc-cli/src/main/kotlin/io/hasura/cli/main.kt index 87f9b53..137db7b 100644 --- a/ndc-cli/src/main/kotlin/io/hasura/cli/main.kt +++ b/ndc-cli/src/main/kotlin/io/hasura/cli/main.kt @@ -4,6 +4,8 @@ import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper import picocli.CommandLine import picocli.CommandLine.* import java.io.File +import java.nio.file.Files +import java.nio.file.attribute.PosixFilePermissions import kotlin.system.exitProcess enum class DatabaseType { @@ -46,7 +48,7 @@ class CLI { names = ["-d", "--database"], description = ["Type of the database to introspect"] ) - database: DatabaseType?, + database: DatabaseType, @Option( names = ["-s", "--schemas"], arity = "0..*", @@ -57,7 +59,7 @@ class CLI { schemas: List = emptyList() ) { - val configGenerator = when (database ?: DatabaseType.ORACLE) { + val configGenerator = when (database) { DatabaseType.ORACLE -> OracleConfigGenerator DatabaseType.MYSQL -> MySQLConfigGenerator DatabaseType.SNOWFLAKE -> SnowflakeConfigGenerator @@ -68,7 +70,22 @@ class CLI { schemas = schemas ) - mapper.writerWithDefaultPrettyPrinter().writeValue(File(outfile),config) + val file = File(outfile) + try { + mapper.writerWithDefaultPrettyPrinter().writeValue(file, config) + } catch (e: Exception) { + println("Error writing configuration to file: ${e.message}") + + val parentDir = file.parentFile + val permissions = Files.getPosixFilePermissions(parentDir.toPath()) + val posixPermissions = PosixFilePermissions.toString(permissions) + + println("Parent directory: ${parentDir.absolutePath}") + println("Readable: ${parentDir.canRead()}, Writable: ${parentDir.canWrite()}") + println("Permissions: $posixPermissions") + + exitProcess(1) + } } companion object { diff --git a/ndc-connector-mysql/.hasura-connector/connector-metadata.yaml b/ndc-connector-mysql/.hasura-connector/connector-metadata.yaml index d199e07..9110d77 100644 --- a/ndc-connector-mysql/.hasura-connector/connector-metadata.yaml +++ b/ndc-connector-mysql/.hasura-connector/connector-metadata.yaml @@ -1,16 +1,15 @@ packagingDefinition: type: PrebuiltDockerImage - dockerImage: "ndc-jvm-cli:v1" + dockerImage: "ghcr.io/hasura/ndc-jvm-mysql:v0.1.0-test.2" supportedEnvironmentVariables: - - name: HASURA_JDBC_URL + - name: JDBC_URL description: "The JDBC URL to connect to the database" commands: update: | docker run \ -e HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH \ -v ${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH}:/app/output \ - ndc-jvm-cli:v1 update $HASURA_JDBC_URL \ + ghcr.io/hasura/ndc-jvm-cli:v0.1.0-test.2 update $JDBC_URL \ --database MYSQL \ - --schemas $HASURA_JDBC_SCHEMAS \ - --outfile /app/output/configuration.json - \ No newline at end of file + --schemas $JDBC_SCHEMAS \ + --outfile /app/output/configuration.json \ No newline at end of file diff --git a/ndc-connector-mysql/README.md b/ndc-connector-mysql/README.md index bcbf919..6133a0c 100644 --- a/ndc-connector-mysql/README.md +++ b/ndc-connector-mysql/README.md @@ -67,10 +67,10 @@ documentation [here](https://hasura.io/docs/3.0/getting-started/connect-to-data/ Add your credentials to `my_subgraph/connector/my_sql/.env.local` ```env title="my_subgraph/connector/my_mysql/.env.local" -HASURA_JDBC_URL="jdbc:MySQL:thin:@//host.docker.internal:1521/XE?user=&password=" +JDBC_URL="jdbc:MySQL:thin:@//host.docker.internal:1521/XE?user=&password=" ``` -### 3. Intropsect your indices +### 3. Introspect your indices ```bash title="From the root of your project run:" ddn connector introspect --connector my_subgraph/connector/my_mysql/connector.yaml diff --git a/ndc-connector-oracle/.hasura-connector/connector-metadata.yaml b/ndc-connector-oracle/.hasura-connector/connector-metadata.yaml index 4f67d68..fa560fa 100644 --- a/ndc-connector-oracle/.hasura-connector/connector-metadata.yaml +++ b/ndc-connector-oracle/.hasura-connector/connector-metadata.yaml @@ -1,18 +1,18 @@ packagingDefinition: type: PrebuiltDockerImage - dockerImage: "ndc-jvm-cli:v1" + dockerImage: "ghcr.io/hasura/ndc-jvm-oracle:v0.1.0-test.2" supportedEnvironmentVariables: - - name: HASURA_JDBC_URL + - name: JDBC_URL description: "The JDBC URL to connect to the database" - - name: HASURA_JDBC_SCHEMAS + - name: JDBC_SCHEMAS description: "A comma-separated list of schemas to include in the metadata" commands: update: | docker run \ -e HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH \ -v ${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH}:/app/output \ - ndc-jvm-cli:v1 update $HASURA_JDBC_URL \ + ghcr.io/hasura/ndc-jvm-cli:v0.1.0-test.2 update $JDBC_URL \ --database ORACLE \ - --schemas $HASURA_JDBC_SCHEMAS \ + --schemas $JDBC_SCHEMAS \ --outfile /app/output/configuration.json \ No newline at end of file diff --git a/ndc-connector-oracle/README.md b/ndc-connector-oracle/README.md index af41e77..604f318 100644 --- a/ndc-connector-oracle/README.md +++ b/ndc-connector-oracle/README.md @@ -67,10 +67,10 @@ documentation [here](https://hasura.io/docs/3.0/getting-started/connect-to-data/ Add your credentials to `my_subgraph/connector/my_sql/.env.local` ```env title="my_subgraph/connector/my_oracle/.env.local" -HASURA_JDBC_URL="jdbc:oracle:thin:@//host.docker.internal:1521/XE?user=&password=" +JDBC_URL="jdbc:oracle:thin:@//host.docker.internal:1521/XE?user=&password=" ``` -### 3. Intropsect your indices +### 3. Introspect your indices ```bash title="From the root of your project run:" ddn connector introspect --connector my_subgraph/connector/my_oracle/connector.yaml diff --git a/ndc-connector-oracle/configuration.json b/ndc-connector-oracle/configuration.json index 6323c87..0c30c8a 100644 --- a/ndc-connector-oracle/configuration.json +++ b/ndc-connector-oracle/configuration.json @@ -1,779 +1,670 @@ { - "jdbcUrl": "jdbc:oracle:thin:@//localhost:1521/XE?user=chinook&password=Password123", - "schemas": [], - "tables": [ - { - "tableName": "ALBUM", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "ALBUMID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "TITLE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "ARTISTID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "ALBUMID" - ], - "fks": { - "FK_ALBUMARTISTID": { - "column_mapping": { - "ARTISTID": "ARTISTID" - }, - "foreign_collection": "ARTIST" - } + "jdbcUrl" : "jdbc:oracle:thin:@//host.docker.internal:1521/XE?user=chinook&password=Password123", + "jdbcProperties" : { }, + "schemas" : [ ], + "tables" : [ { + "tableName" : "CHINOOK.ALBUM", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "ALBUMID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "TITLE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "ARTISTID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "ALBUMID" ], + "fks" : { + "FK_ALBUMARTISTID" : { + "column_mapping" : { + "ARTISTID" : "ARTISTID" + }, + "foreign_collection" : "CHINOOK.ARTIST" } - }, - { - "tableName": "GENRE", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "GENREID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "NAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "GENREID" - ], - "fks": null - }, - { - "tableName": "TRACK", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "TRACKID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "NAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "ALBUMID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "MEDIATYPEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "GENREID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "COMPOSER", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "MILLISECONDS", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BYTES", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "UNITPRICE", - "description": null, - "type": "NUMBER", - "numeric_scale": 2, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "TRACKID" - ], - "fks": { - "FK_TRACKALBUMID": { - "column_mapping": { - "ALBUMID": "ALBUMID" - }, - "foreign_collection": "ALBUM" - }, - "FK_TRACKMEDIATYPEID": { - "column_mapping": { - "MEDIATYPEID": "MEDIATYPEID" - }, - "foreign_collection": "MEDIATYPE" - }, - "FK_TRACKGENREID": { - "column_mapping": { - "GENREID": "GENREID" - }, - "foreign_collection": "GENRE" - } + } + }, { + "tableName" : "CHINOOK.GENRE", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "GENREID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "NAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "GENREID" ], + "fks" : null + }, { + "tableName" : "CHINOOK.TRACK", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "TRACKID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "NAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "ALBUMID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "MEDIATYPEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "GENREID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "COMPOSER", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "MILLISECONDS", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BYTES", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "UNITPRICE", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : 2, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "TRACKID" ], + "fks" : { + "FK_TRACKALBUMID" : { + "column_mapping" : { + "ALBUMID" : "ALBUMID" + }, + "foreign_collection" : "CHINOOK.ALBUM" + }, + "FK_TRACKMEDIATYPEID" : { + "column_mapping" : { + "MEDIATYPEID" : "MEDIATYPEID" + }, + "foreign_collection" : "CHINOOK.MEDIATYPE" + }, + "FK_TRACKGENREID" : { + "column_mapping" : { + "GENREID" : "GENREID" + }, + "foreign_collection" : "CHINOOK.GENRE" } - }, - { - "tableName": "ARTIST", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "ARTISTID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "NAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "ARTISTID" - ], - "fks": null - }, - { - "tableName": "INVOICE", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "INVOICEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "CUSTOMERID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "INVOICEDATE", - "description": null, - "type": "DATE", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BILLINGADDRESS", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BILLINGCITY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BILLINGSTATE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BILLINGCOUNTRY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BILLINGPOSTALCODE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "TOTAL", - "description": null, - "type": "NUMBER", - "numeric_scale": 2, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "INVOICEID" - ], - "fks": { - "FK_INVOICECUSTOMERID": { - "column_mapping": { - "CUSTOMERID": "CUSTOMERID" - }, - "foreign_collection": "CUSTOMER" - } + } + }, { + "tableName" : "CHINOOK.ARTIST", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "ARTISTID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "NAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "ARTISTID" ], + "fks" : null + }, { + "tableName" : "CHINOOK.INVOICE", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "INVOICEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "CUSTOMERID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "INVOICEDATE", + "description" : null, + "type" : "DATE", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BILLINGADDRESS", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BILLINGCITY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BILLINGSTATE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BILLINGCOUNTRY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BILLINGPOSTALCODE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "TOTAL", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : 2, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "INVOICEID" ], + "fks" : { + "FK_INVOICECUSTOMERID" : { + "column_mapping" : { + "CUSTOMERID" : "CUSTOMERID" + }, + "foreign_collection" : "CHINOOK.CUSTOMER" } - }, - { - "tableName": "CUSTOMER", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "CUSTOMERID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "FIRSTNAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "LASTNAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "COMPANY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "ADDRESS", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "CITY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "STATE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "COUNTRY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "POSTALCODE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "PHONE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "FAX", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "EMAIL", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "SUPPORTREPID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "CUSTOMERID" - ], - "fks": { - "FK_CUSTOMERSUPPORTREPID": { - "column_mapping": { - "SUPPORTREPID": "EMPLOYEEID" - }, - "foreign_collection": "EMPLOYEE" - } + } + }, { + "tableName" : "CHINOOK.CUSTOMER", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "CUSTOMERID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "FIRSTNAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "LASTNAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "COMPANY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "ADDRESS", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "CITY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "STATE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "COUNTRY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "POSTALCODE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "PHONE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "FAX", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "EMAIL", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "SUPPORTREPID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "CUSTOMERID" ], + "fks" : { + "FK_CUSTOMERSUPPORTREPID" : { + "column_mapping" : { + "SUPPORTREPID" : "EMPLOYEEID" + }, + "foreign_collection" : "CHINOOK.EMPLOYEE" } - }, - { - "tableName": "EMPLOYEE", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "EMPLOYEEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "LASTNAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "FIRSTNAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "TITLE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "REPORTSTO", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "BIRTHDATE", - "description": null, - "type": "DATE", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "HIREDATE", - "description": null, - "type": "DATE", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "ADDRESS", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "CITY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "STATE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "COUNTRY", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "POSTALCODE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "PHONE", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "FAX", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "EMAIL", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "EMPLOYEEID" - ], - "fks": { - "FK_EMPLOYEEREPORTSTO": { - "column_mapping": { - "REPORTSTO": "EMPLOYEEID" - }, - "foreign_collection": "EMPLOYEE" - } + } + }, { + "tableName" : "CHINOOK.EMPLOYEE", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "EMPLOYEEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "LASTNAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "FIRSTNAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "TITLE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "REPORTSTO", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "BIRTHDATE", + "description" : null, + "type" : "DATE", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "HIREDATE", + "description" : null, + "type" : "DATE", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "ADDRESS", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "CITY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "STATE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "COUNTRY", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "POSTALCODE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "PHONE", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "FAX", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "EMAIL", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "EMPLOYEEID" ], + "fks" : { + "FK_EMPLOYEEREPORTSTO" : { + "column_mapping" : { + "REPORTSTO" : "EMPLOYEEID" + }, + "foreign_collection" : "CHINOOK.EMPLOYEE" } - }, - { - "tableName": "PLAYLIST", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "PLAYLISTID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "NAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "PLAYLISTID" - ], - "fks": null - }, - { - "tableName": "MEDIATYPE", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "MEDIATYPEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "NAME", - "description": null, - "type": "VARCHAR2", - "numeric_scale": null, - "nullable": true, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "MEDIATYPEID" - ], - "fks": null - }, - { - "tableName": "INVOICELINE", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "INVOICELINEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "INVOICEID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "TRACKID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "UNITPRICE", - "description": null, - "type": "NUMBER", - "numeric_scale": 2, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "QUANTITY", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "INVOICELINEID" - ], - "fks": { - "FK_INVOICELINETRACKID": { - "column_mapping": { - "TRACKID": "TRACKID" - }, - "foreign_collection": "TRACK" - }, - "FK_INVOICELINEINVOICEID": { - "column_mapping": { - "INVOICEID": "INVOICEID" - }, - "foreign_collection": "INVOICE" - } + } + }, { + "tableName" : "CHINOOK.PLAYLIST", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "PLAYLISTID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "NAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "PLAYLISTID" ], + "fks" : null + }, { + "tableName" : "CHINOOK.MEDIATYPE", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "MEDIATYPEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "NAME", + "description" : null, + "type" : "VARCHAR2", + "numeric_scale" : null, + "nullable" : true, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "MEDIATYPEID" ], + "fks" : null + }, { + "tableName" : "CHINOOK.INVOICELINE", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "INVOICELINEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "INVOICEID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "TRACKID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "UNITPRICE", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : 2, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "QUANTITY", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "INVOICELINEID" ], + "fks" : { + "FK_INVOICELINETRACKID" : { + "column_mapping" : { + "TRACKID" : "TRACKID" + }, + "foreign_collection" : "CHINOOK.TRACK" + }, + "FK_INVOICELINEINVOICEID" : { + "column_mapping" : { + "INVOICEID" : "INVOICEID" + }, + "foreign_collection" : "CHINOOK.INVOICE" } - }, - { - "tableName": "PLAYLISTTRACK", - "tableType": "TABLE", - "description": null, - "columns": [ - { - "name": "PLAYLISTID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - }, - { - "name": "TRACKID", - "description": null, - "type": "NUMBER", - "numeric_scale": null, - "nullable": false, - "auto_increment": false, - "is_primarykey": null - } - ], - "pks": [ - "PLAYLISTID", - "TRACKID" - ], - "fks": { - "FK_PLAYLISTTRACKTRACKID": { - "column_mapping": { - "TRACKID": "TRACKID" - }, - "foreign_collection": "TRACK" - }, - "FK_PLAYLISTTRACKPLAYLISTID": { - "column_mapping": { - "PLAYLISTID": "PLAYLISTID" - }, - "foreign_collection": "PLAYLIST" - } + } + }, { + "tableName" : "CHINOOK.PLAYLISTTRACK", + "tableType" : "TABLE", + "description" : null, + "columns" : [ { + "name" : "PLAYLISTID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + }, { + "name" : "TRACKID", + "description" : null, + "type" : "NUMBER", + "numeric_scale" : null, + "nullable" : false, + "auto_increment" : false, + "is_primarykey" : null + } ], + "pks" : [ "PLAYLISTID", "TRACKID" ], + "fks" : { + "FK_PLAYLISTTRACKTRACKID" : { + "column_mapping" : { + "TRACKID" : "TRACKID" + }, + "foreign_collection" : "CHINOOK.TRACK" + }, + "FK_PLAYLISTTRACKPLAYLISTID" : { + "column_mapping" : { + "PLAYLISTID" : "PLAYLISTID" + }, + "foreign_collection" : "CHINOOK.PLAYLIST" } } - ], - "functions": [], - "nativeQueries": {} + } ], + "functions" : [ ], + "nativeQueries" : { } } \ No newline at end of file diff --git a/ndc-connector-snowflake/.hasura-connector/connector-metadata.yaml b/ndc-connector-snowflake/.hasura-connector/connector-metadata.yaml index 6ce6a46..8d674a0 100644 --- a/ndc-connector-snowflake/.hasura-connector/connector-metadata.yaml +++ b/ndc-connector-snowflake/.hasura-connector/connector-metadata.yaml @@ -2,17 +2,17 @@ packagingDefinition: type: PrebuiltDockerImage dockerImage: "ndc-jvm-cli:v1" supportedEnvironmentVariables: - - name: HASURA_JDBC_URL + - name: JDBC_URL description: "The JDBC URL to connect to the database" - - name: HASURA_JDBC_SCHEMAS + - name: JDBC_SCHEMAS description: "A comma-separated list of schemas to include in the metadata" commands: update: | docker run \ -e HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH \ -v ${HASURA_PLUGIN_CONNECTOR_CONTEXT_PATH}:/app/output \ - ndc-jvm-cli:v1 update $HASURA_JDBC_URL \ + ndc-jvm-cli:v1 update $JDBC_URL \ --database SNOWFLAKE \ - --schemas $HASURA_JDBC_SCHEMAS \ + --schemas $JDBC_SCHEMAS \ --outfile /app/output/configuration.json \ No newline at end of file diff --git a/ndc-connector-snowflake/README.md b/ndc-connector-snowflake/README.md index cd179f1..b4a6403 100644 --- a/ndc-connector-snowflake/README.md +++ b/ndc-connector-snowflake/README.md @@ -67,11 +67,11 @@ documentation [here](https://hasura.io/docs/3.0/getting-started/connect-to-data/ Add your credentials to `my_subgraph/connector/my_sql/.env.local` ```env title="my_subgraph/connector/my_snowflake/.env.local" -HASURA_JDBC_URL="jdbc:snowflake://ak1234.us-east-2.aws.snowflakecomputing.com/?user=&password=&db=CHINOOK&schema=PUBLIC&warehouse=COMPUTE_WH&role=ACCOUNTADMIN" -HASURA_JDBC_SCHEMAS=PUBLIC +JDBC_URL="jdbc:snowflake://ak1234.us-east-2.aws.snowflakecomputing.com/?user=&password=&db=CHINOOK&schema=PUBLIC&warehouse=COMPUTE_WH&role=ACCOUNTADMIN" +JDBC_SCHEMAS=PUBLIC ``` -### 3. Intropsect your indices +### 3. Introspect your indices ```bash title="From the root of your project run:" ddn connector introspect --connector my_subgraph/connector/my_snowflake/connector.yaml