Skip to content
Merged
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
92 changes: 30 additions & 62 deletions java/adapter/jdbc/pom.xml
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->
license agreements. See the NOTICE file distributed with this work for additional
information regarding copyright ownership. The ASF licenses this file to
You under the Apache License, Version 2.0 (the "License"); you may not use
this file except in compliance with the License. You may obtain a copy of
the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
by applicable law or agreed to in writing, software distributed under the
License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
OF ANY KIND, either express or implied. See the License for the specific
language governing permissions and limitations under the License. -->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.arrow</groupId>
<artifactId>arrow-java-root</artifactId>
Expand All @@ -21,6 +22,7 @@
<artifactId>arrow-jdbc</artifactId>
<name>Arrow JDBC Adapter</name>
<url>http://maven.apache.org</url>

<dependencies>

<!-- https://mvnrepository.com/artifact/org.apache.arrow/arrow-memory -->
Expand All @@ -36,6 +38,7 @@
<artifactId>arrow-vector</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
Expand All @@ -57,82 +60,47 @@
<version>1.4.196</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>${dep.jackson.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${dep.jackson.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${dep.jackson.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${dep.jackson.version}</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.1</version>
<executions>
<!-- Prepares property pointing to JaCoCo runtime agent which is passed as VM argument when Surefire is executed. -->
<execution>
<id>default-prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
<!--Sets the name of the property containing the settings for JaCoCo runtime agent. -->
<propertyName>surefireArgLine</propertyName>
</configuration>
</execution>
<!--Ensures that the code coverage report for unit tests is created after unit tests have been run. -->
<execution>
<id>post-unit-test</id>
<phase>test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Sets the path to the file which contains the execution data. -->
<dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
<!-- Sets the output directory for the code coverage report. -->
<includeTests>true</includeTests>
<outputDirectory>${project.build.directory}/jacoco-ut</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<user.timezone>UTC</user.timezone>
</systemPropertyVariables>
<!-- Sets the VM argument line used when unit tests are run. -->
<argLine>${surefireArgLine}</argLine>
</configuration>
</plugin>
</plugins>
</build>

</project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<user.timezone>UTC</user.timezone>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
import java.sql.Statement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.Locale;
import java.util.TimeZone;

/**
* Utility class to convert JDBC objects to columnar Arrow format objects.
Expand Down Expand Up @@ -85,7 +87,7 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B
Preconditions.checkArgument(query != null && query.length() > 0, "SQL query can not be null or empty");
Preconditions.checkNotNull(allocator, "Memory allocator object can not be null");

return sqlToArrow(connection, query, allocator, Calendar.getInstance());
return sqlToArrow(connection, query, allocator, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT));
}

/**
Expand Down Expand Up @@ -121,7 +123,7 @@ public static VectorSchemaRoot sqlToArrow(Connection connection, String query, B
public static VectorSchemaRoot sqlToArrow(ResultSet resultSet) throws SQLException, IOException {
Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");

return sqlToArrow(resultSet, Calendar.getInstance());
return sqlToArrow(resultSet, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT));
}

/**
Expand All @@ -136,7 +138,7 @@ public static VectorSchemaRoot sqlToArrow(ResultSet resultSet, BaseAllocator all
Preconditions.checkNotNull(resultSet, "JDBC ResultSet object can not be null");
Preconditions.checkNotNull(allocator, "Memory Allocator object can not be null");

return sqlToArrow(resultSet, allocator, Calendar.getInstance());
return sqlToArrow(resultSet, allocator, Calendar.getInstance(TimeZone.getTimeZone("UTC"), Locale.ROOT));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ public static void jdbcToArrowVectors(ResultSet rs, VectorSchemaRoot root, Calen
case Types.VARBINARY:
case Types.LONGVARBINARY:
updateVector((VarBinaryVector)root.getVector(columnName),
// rs.getBytes(i), !rs.wasNull(), rowCount);
rs.getBinaryStream(i), !rs.wasNull(), rowCount);
break;
case Types.ARRAY:
Expand Down Expand Up @@ -474,7 +473,7 @@ private static void updateVector(VarBinaryVector varBinaryVector, InputStream is
if (read == -1) {
break;
}
arrowBuf.setBytes(total, new ByteArrayInputStream(bytes, 0, read), read);
arrowBuf.setBytes(total, bytes, total, read);
total += read;
}
holder.end = total;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public abstract class AbstractJdbcToArrowTest {
protected Connection conn = null;
protected Table table;

/**
* This method creates Table object after reading YAML file
* @param ymlFilePath
Expand All @@ -45,7 +45,7 @@ public abstract class AbstractJdbcToArrowTest {
*/
protected static Table getTable(String ymlFilePath, Class clss) throws IOException {
return new ObjectMapper(new YAMLFactory()).readValue(
clss.getClassLoader().getResourceAsStream(ymlFilePath), Table.class);
clss.getClassLoader().getResourceAsStream(ymlFilePath), Table.class);
}


Expand All @@ -67,7 +67,7 @@ public void setUp() throws SQLException, ClassNotFoundException {
}
}
}

/**
* Clean up method to close connection after test completes
* @throws SQLException
Expand All @@ -79,7 +79,7 @@ public void destroy() throws SQLException {
conn = null;
}
}

/**
* This method returns collection of Table object for each test iteration
* @return
Expand All @@ -88,14 +88,14 @@ public void destroy() throws SQLException {
* @throws IOException
*/
public static Object[][] prepareTestData(String[] testFiles, Class clss) throws SQLException, ClassNotFoundException, IOException {
Object[][] tableArr = new Object[testFiles.length][];
Object[][] tableArr = new Object[testFiles.length][];
int i = 0;
for (String testFile: testFiles) {
tableArr[i++] = new Object[]{getTable(testFile, clss)};
}
return tableArr;
}

/**
* Abstract method to implement test Functionality to test JdbcToArrow methods
* @throws SQLException
Expand Down
Loading