Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Azure Synapse Analytics to supported products #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/gem-push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Ruby Gem

on:
workflow_dispatch:
push:
tags:
- '*'

jobs:
build:
name: Build + Publish
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
strategy:
matrix:
type:
- jdbc
- mysql
- postgresql
- redshift
- sqlserver
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.7
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
- name: push gem
uses: trocco-io/push-gem-to-gpr-action@v2
with:
language: java
gem-path: "embulk-input-${{ matrix.type }}/build/gems/*.gem"
github-token: "${{ secrets.GITHUB_TOKEN }}"
gradle-subproject: "embulk-input-${{ matrix.type }}"
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id "signing"
id 'checkstyle'
id "org.embulk.embulk-plugins" version "0.5.5" apply false
id "com.palantir.git-version" version "3.0.0"
}

allprojects {
Expand All @@ -15,12 +16,17 @@ allprojects {
description = "Selects records from a table."
}

ext {
troccoVersion = "0.0.1"
}

subprojects {
apply plugin: 'java'
apply plugin: "maven-publish"
apply plugin: "signing"
apply plugin: "checkstyle"
apply plugin: "org.embulk.embulk-plugins"
apply plugin: 'com.palantir.git-version'

repositories {
mavenCentral()
Expand Down Expand Up @@ -132,6 +138,7 @@ subprojects {
summary = "JDBC input plugin for Embulk"
homepage = "https://github.com/embulk/embulk-input-jdbc"
licenses = [ "Apache-2.0" ]
archiveVersion = "${project.version}.trocco.${project.troccoVersion}"

into("default_jdbc_driver") {
from configurations.defaultJdbcDriver
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.embulk.input.sqlserver;

import java.util.Locale;

import org.embulk.config.ConfigException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

public enum Product
{
// https://learn.microsoft.com/en-us/sql/sql-server/sql-docs-navigation-guide?view=sql-server-ver16#applies-to
SQL_SERVER,
AZURE_SYNAPSE_ANALYTICS;

@JsonValue
@Override
public String toString()
{
return name().toLowerCase(Locale.ENGLISH);
}

@JsonCreator
public static Product fromString(String value)
{
for (Product product : Product.values()) {
if (product.toString().equals(value)) {
return product;
}
}
throw new ConfigException(String.format("Unknown product '%s'.", value));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ public interface SQLServerPluginTask
@ConfigDefault("\"embulk-input-sqlserver\"")
@Size(max = 128)
public String getApplicationName();

@Config("product")
@ConfigDefault("\"sql_server\"")
public Product getProduct();

@Config("host_name_in_certificate")
@ConfigDefault("null")
public Optional<String> getHostNameInCertificate();
}

@Override
Expand Down Expand Up @@ -283,6 +291,19 @@ private UrlAndProperties buildUrlAndProperties(SQLServerPluginTask sqlServerTask
throw new ConfigException("'user' option is required but not set.");
}
}

// https://learn.microsoft.com/en-us/azure/synapse-analytics/sql-data-warehouse/sql-data-warehouse-connect-overview#jdbc-connection-string-example
// jdbc:sqlserver://yourserver.database.windows.net:1433;database=yourdatabase;user={your_user_name};password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.database.windows.net;loginTimeout=30;
// https://learn.microsoft.com/en-us/azure/synapse-analytics/sql/connect-overview#jdbc-connection-string-example
// jdbc:sqlserver://yourserver.sql.azuresynapse.net:1433;database=yourdatabase;user={your_user_name};password={your_password_here};encrypt=true;trustServerCertificate=false;hostNameInCertificate=*.sql.azuresynapse.net;loginTimeout=30;
// https://learn.microsoft.com/en-us/sql/connect/jdbc/setting-the-connection-properties?view=azure-sqldw-latest#properties
if (sqlServerTask.getProduct() == Product.AZURE_SYNAPSE_ANALYTICS) {
props.setProperty("encrypt", "true");
props.setProperty("trustServerCertificate", "false");
String host = sqlServerTask.getHost().get();
String hostNameInCertificate = sqlServerTask.getHostNameInCertificate().orElse(host.replaceFirst("^[^.]+\\.(.*)$", "*.$1"));
props.setProperty("hostNameInCertificate", hostNameInCertificate);
}
}

return new UrlAndProperties(url, props);
Expand Down
Loading