Skip to content

Commit

Permalink
chore(deps): update all java deps
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Mar 31, 2022
1 parent 789b982 commit 35e8ffb
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:

# Caches
- name: Gradle cache
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=0.4.1-SNAPSHOT
kestraVersion=0.4.+
micronautVersion=3.3.4
micronautVersion=3.4.1
lombokVersion=1.18.22
2 changes: 1 addition & 1 deletion plugin-jdbc-clickhouse/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
implementation group: 'ru.yandex.clickhouse', name: 'clickhouse-jdbc', version: '0.3.1'
implementation group: 'com.clickhouse', name: 'clickhouse-jdbc', version: '0.3.2-patch7'
implementation project(':plugin-jdbc')

testImplementation project(':plugin-jdbc').sourceSets.test.output
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package io.kestra.plugin.jdbc.clickhouse;

import io.kestra.plugin.jdbc.AbstractCellConverter;
import ru.yandex.clickhouse.ClickHouseArray;

import java.net.Inet4Address;
import java.net.Inet6Address;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

public class ClickHouseCellConverter extends AbstractCellConverter {
private static final Pattern PATTERN = Pattern.compile("DateTime(64)?\\((.*)'(.*)'\\)");
Expand All @@ -30,11 +35,6 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)
Object columnVal = rs.getObject(columnIndex);
String columnTypeName = rs.getMetaData().getColumnTypeName(columnIndex);

if (columnVal instanceof ClickHouseArray) {
ClickHouseArray col = (ClickHouseArray) columnVal;
return col.getArray();
}

if (columnTypeName.startsWith("DateTime")) {
Matcher matcher = PATTERN.matcher(columnTypeName);
if (!matcher.find() || matcher.groupCount() < 3) {
Expand All @@ -50,6 +50,33 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)
.withZoneSameInstant(zoneId);
}

if (columnTypeName.equals("Int8")) {
Byte col = (Byte) columnVal;
return col.intValue();
}

if (columnTypeName.equals("Date")) {
return columnVal;
}

if (columnTypeName.startsWith("Array(")) {
return columnVal;
}

if (columnTypeName.startsWith("Tuple(")) {
return columnVal;
}

if (columnTypeName.equals("IPv4")) {
Inet4Address col = (Inet4Address) columnVal;
return col.toString().substring(1);
}

if (columnTypeName.equals("IPv6")) {
Inet6Address col = (Inet6Address) columnVal;
return col.toString().substring(1);
}

return super.convert(columnIndex, rs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ protected AbstractCellConverter getCellConverter(ZoneId zoneId) {

@Override
protected void registerDriver() throws SQLException {
DriverManager.registerDriver(new ru.yandex.clickhouse.ClickHouseDriver());
DriverManager.registerDriver(new com.clickhouse.jdbc.ClickHouseDriver());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
public class ClickHouseDriverTest extends AbstractJdbcDriverTest {
@Override
protected Class<? extends Driver> getDriverClass() {
return ru.yandex.clickhouse.ClickHouseDriver.class;
return com.clickhouse.jdbc.ClickHouseDriver.class;
}
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package io.kestra.plugin.jdbc.clickhouse;

import com.google.common.collect.ImmutableMap;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;
import io.kestra.core.runners.RunContext;
import io.kestra.plugin.jdbc.AbstractJdbcQuery;
import io.kestra.plugin.jdbc.AbstractRdbmsTest;
import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
import org.junit.jupiter.api.Test;

import java.io.FileNotFoundException;
import java.math.BigDecimal;
Expand All @@ -14,13 +14,14 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.UUID;
import java.util.List;

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

@MicronautTest
public class ClickHouseTest extends AbstractRdbmsTest {
@SuppressWarnings("unchecked")
@Test
void select() throws Exception {
RunContext runContext = runContextFactory.of(ImmutableMap.of());
Expand Down Expand Up @@ -50,12 +51,12 @@ void select() throws Exception {
assertThat(runOutput.getRow().get("Enum"), is("hello"));
assertThat(runOutput.getRow().get("LowCardinality"), is("four"));
assertThat(runOutput.getRow().get("Array"), is(new String[]{"a", "b"}));
assertThat(runOutput.getRow().get("Nested.NestedId"), is(new Integer[]{123}));
assertThat(runOutput.getRow().get("Nested.NestedId"), is(new Byte[]{Byte.valueOf("123")}));
assertThat(runOutput.getRow().get("Nested.NestedString"), is(new String[]{"four"}));
assertThat(runOutput.getRow().get("Tuple"), is("('a',1)"));
assertThat((List<Object>) runOutput.getRow().get("Tuple"), containsInAnyOrder("a", Byte.valueOf("1")));
assertThat(runOutput.getRow().get("Nullable"), is(nullValue()));
assertThat(runOutput.getRow().get("Ipv4"), is("116.253.40.133"));
assertThat(runOutput.getRow().get("Ipv6"), is("2a02:aa08:e000:3100::2"));
assertThat(runOutput.getRow().get("Ipv6"), is("2a02:aa08:e000:3100:0:0:0:2"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,27 +76,6 @@ public Object convertCell(int columnIndex, ResultSet rs, Connection connection)
return ((Timestamp) data).toLocalDateTime().toLocalDate();
}


// if (columnVal instanceof ClickHouseArray) {
// ClickHouseArray col = (ClickHouseArray) columnVal;
// return col.getArray();
// }
//
// if (columnTypeName.startsWith("DateTime")) {
// Matcher matcher = PATTERN.matcher(columnTypeName);
// if (!matcher.find() || matcher.groupCount() < 3) {
// throw new IllegalArgumentException("Invalid Column Type '" + columnTypeName + "'");
// }
//
// return LocalDateTime
// .parse(
// rs.getString(columnIndex),
// DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss[.SSSSSS][.SSSSS][.SSSS][.SSS][.SS][.S]")
// )
// .atZone(ZoneId.of(matcher.group(3)))
// .withZoneSameInstant(zoneId);
// }

return super.convert(columnIndex, rs);
}

Expand Down
2 changes: 1 addition & 1 deletion plugin-jdbc-redshift/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
jdbcDriver 'com.amazon.redshift:redshift-jdbc42:2.1.0.4'
jdbcDriver 'com.amazon.redshift:redshift-jdbc42:2.1.0.5'
implementation project(':plugin-jdbc')

testImplementation project(':plugin-jdbc').sourceSets.test.output
Expand Down
2 changes: 1 addition & 1 deletion plugin-jdbc-snowflake/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
implementation("net.snowflake:snowflake-jdbc:3.13.14")
implementation("net.snowflake:snowflake-jdbc:3.13.16")
implementation project(':plugin-jdbc')
implementation("javax.xml.bind:jaxb-api:2.3.1")

Expand Down

0 comments on commit 35e8ffb

Please sign in to comment.