Skip to content

Commit

Permalink
Merge branch 'master' into SNOW-1213115-Move-test-categories-to-have-…
Browse files Browse the repository at this point in the history
…equal-distribution
  • Loading branch information
sfc-gh-ext-simba-jf authored Oct 24, 2024
2 parents 0ef35fe + 8bc1ae5 commit 63c3782
Show file tree
Hide file tree
Showing 66 changed files with 2,108 additions and 1,396 deletions.
3 changes: 2 additions & 1 deletion .github/ISSUE_TEMPLATE/BUG_REPORT.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ In order to accurately debug the issue this information is required. Thanks!

https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

7. What is your Snowflake account identifier, if any? (Optional)
Before sharing any information, please be sure to review the log and remove any sensitive
information.
2 changes: 0 additions & 2 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,4 @@ otherwise continue here.
## How would this improve `snowflake-jdbc`?

## References, Other Background

## What is your Snowflake account identifier, if any?

22 changes: 5 additions & 17 deletions FIPS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,17 @@
<parent>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc-parent</artifactId>
<version>3.19.0</version>
<version>3.19.1-SNAPSHOT</version>
<relativePath>../parent-pom.xml</relativePath>
</parent>

<artifactId>snowflake-jdbc-fips</artifactId>
<version>3.19.0</version>
<version>3.19.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>snowflake-jdbc-fips</name>
<url>http://maven.apache.org</url>

<repositories>
<repository>
<id>Central</id>
<name>Internal Central Repo2</name>
<layout>default</layout>
<url>https://nexus.int.snowflakecomputing.com/repository/maven-central/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>

<prerequisites>
<maven>3.3.9</maven>
</prerequisites>
Expand Down Expand Up @@ -608,15 +596,15 @@
<unzip dest="${project.build.directory}/relocate" src="${project.build.directory}/${project.build.finalName}.jar"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<mkdir dir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/19/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/21/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<zip basedir="${project.build.directory}/relocate" destfile="${project.build.directory}/${project.build.finalName}.jar"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/19/${relocationBase}"/>
<delete dir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
</target>
</configuration>
</execution>
Expand Down
4 changes: 2 additions & 2 deletions FIPS/public_pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
</scm>

<properties>
<bouncycastle.bcfips.version>1.0.2.4</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.5</bouncycastle.bcpkixfips.version>
<bouncycastle.bcfips.version>1.0.2.5</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.7</bouncycastle.bcpkixfips.version>
<jna.version>5.13.0</jna.version>
</properties>

Expand Down
2 changes: 2 additions & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ timestamps {
}.collectEntries { jobDefinition ->
return [(jobDefinition.runName): { build job: jobDefinition.jobToRun, parameters: jobDefinition.params }]
}

jobDefinitions.put('JDBC-AIX-Unit', { build job: 'JDBC-AIX-UnitTests', parameters: [ string(name: 'BRANCH', value: scmInfo.GIT_BRANCH ) ] } )
stage('Test') {
parallel (jobDefinitions)
}
Expand Down
2 changes: 1 addition & 1 deletion dependencies/Readme.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Arrow dependencies are built from internal branch `upgradeto17.0.0`. This build was applied the AIX fix.
Arrow dependencies are built from internal branch `upgradeTo17.0.0-v2`. This build was applied the AIX fix and the customer logger instead of slf4j logger.

Binary file modified dependencies/arrow-format-17.0.0.jar
Binary file not shown.
Binary file modified dependencies/arrow-memory-core-17.0.0.jar
Binary file not shown.
Binary file modified dependencies/arrow-memory-netty-buffer-patch-17.0.0.jar
Binary file not shown.
Binary file modified dependencies/arrow-memory-unsafe-17.0.0.jar
Binary file not shown.
Binary file modified dependencies/arrow-vector-17.0.0.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions linkage-checker-exclusion-rules.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,16 @@
<Source><Package name="org.bouncycastle.pkix"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="java.nio"/></Target>
<Source><Package name="org.bouncycastle.jcajce.provider.symmetric.util"/></Source>
<Reason>?</Reason>
</LinkageError>
<LinkageError>
<Target><Package name="java.nio"/></Target>
<Source><Package name="org.bouncycastle.pqc.legacy.crypto.ntru"/></Source>
<Reason>?</Reason>
</LinkageError>
<!--
<LinkageError>
<Target><Package name=""/></Target>
Expand Down
16 changes: 11 additions & 5 deletions parent-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc-parent</artifactId>
<version>3.19.0</version>
<version>3.19.1-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
Expand All @@ -25,9 +25,9 @@
<awaitility.version>4.2.0</awaitility.version>
<awssdk.version>1.12.655</awssdk.version>
<azure.storage.version>5.0.0</azure.storage.version>
<bouncycastle.version>1.74</bouncycastle.version>
<bouncycastle.bcfips.version>1.0.2.4</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.5</bouncycastle.bcpkixfips.version>
<bouncycastle.version>1.78.1</bouncycastle.version>
<bouncycastle.bcfips.version>1.0.2.5</bouncycastle.bcfips.version>
<bouncycastle.bcpkixfips.version>1.0.7</bouncycastle.bcpkixfips.version>
<bytebuddy.version>1.14.17</bytebuddy.version>
<classworlds.version>1.1</classworlds.version>
<checkerframework.version>3.33.0</checkerframework.version>
Expand All @@ -49,7 +49,7 @@
<google.guava.version>32.1.1-jre</google.guava.version>
<google.http.client.version>1.43.3</google.http.client.version>
<google.jsr305.version>3.0.2</google.jsr305.version>
<google.protobuf.java.version>3.23.3</google.protobuf.java.version>
<google.protobuf.java.version>3.25.5</google.protobuf.java.version>
<grpc.version>1.60.0</grpc.version>
<hamcrest.version>2.2</hamcrest.version>
<hikaricp.version>2.4.3</hikaricp.version>
Expand Down Expand Up @@ -448,6 +448,12 @@
<artifactId>bcprov-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<!-- for non-FIPS JAR -->
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
<version>${bouncycastle.version}</version>
</dependency>
<dependency>
<!-- for FIPS JAR -->
<groupId>org.bouncycastle</groupId>
Expand Down
11 changes: 8 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
<parent>
<groupId>net.snowflake</groupId>
<artifactId>snowflake-jdbc-parent</artifactId>
<version>3.19.0</version>
<version>3.19.1-SNAPSHOT</version>
<relativePath>./parent-pom.xml</relativePath>
</parent>

<!-- Maven complains about using property here, but it makes install and deploy process easier to override final package names and localization -->
<artifactId>${artifactId}</artifactId>
<version>3.19.0</version>
<version>3.19.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>${artifactId}</name>
Expand All @@ -36,6 +36,10 @@
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
</dependency>
<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcutil-jdk18on</artifactId>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -1031,6 +1035,7 @@
<move file="${project.build.directory}/relocate/META-INF/versions/9/org" todir="${project.build.directory}/relocate/META-INF/versions/9/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/11/org" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/15/org" todir="${project.build.directory}/relocate/META-INF/versions/15/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/21/org" todir="${project.build.directory}/relocate/META-INF/versions/21/${relocationBase}"/>
<!-- com.fasterxml.* packages are relocated to ${relocationBase}.fasterxml.* -->
<move file="${project.build.directory}/relocate/META-INF/versions/11/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/11/${relocationBase}"/>
<move file="${project.build.directory}/relocate/META-INF/versions/17/com/fasterxml" todir="${project.build.directory}/relocate/META-INF/versions/17/${relocationBase}"/>
Expand Down Expand Up @@ -1105,7 +1110,7 @@
<!--
Downloading
1. japicmp
2. maven-dependency-lugin analyst
2. maven-dependency-plugin analyst
in jenkins node would cause http connection failure. Temporarily disable them.
-->
<plugin>
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/net/snowflake/client/core/CancellationReason.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* Copyright (c) 2024 Snowflake Computing Inc. All rights reserved.
*/
package net.snowflake.client.core;

@SnowflakeJdbcInternalApi
public enum CancellationReason {
UNKNOWN,
CLIENT_REQUESTED,
TIMEOUT
}
14 changes: 14 additions & 0 deletions src/main/java/net/snowflake/client/core/SFBaseStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,23 @@ public abstract SFBaseResultSet asyncExecute(
*
* @throws SFException if the statement is already closed.
* @throws SQLException if there are server-side errors from trying to abort.
* @deprecated use {@link #cancel(CancellationReason)} instead
*/
@Deprecated
public abstract void cancel() throws SFException, SQLException;

/**
* Aborts the statement.
*
* @param cancellationReason reason for the cancellation
* @throws SFException if the statement is already closed.
* @throws SQLException if there are server-side errors from trying to abort.
*/
@SnowflakeJdbcInternalApi
public void cancel(CancellationReason cancellationReason) throws SFException, SQLException {
cancel(); // default cancel is called to keep interface backward compatibility
}

/**
* Sets a property within session properties, i.e., if the sql is using set-sf-property
*
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/snowflake/client/core/SFLoginOutput.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public class SFLoginOutput {
private int databaseMajorVersion;
private int databaseMinorVersion;
private Duration httpClientSocketTimeout;
private Duration httpClientConnectionTimeout;
private String sessionDatabase;
private String sessionSchema;
private String sessionRole;
Expand Down Expand Up @@ -53,6 +54,7 @@ public class SFLoginOutput {
this.databaseMajorVersion = databaseMajorVersion;
this.databaseMinorVersion = databaseMinorVersion;
this.httpClientSocketTimeout = Duration.ofMillis(httpClientSocketTimeout);
this.httpClientConnectionTimeout = Duration.ofMillis(httpClientConnectionTimeout);
this.sessionDatabase = sessionDatabase;
this.sessionSchema = sessionSchema;
this.sessionRole = sessionRole;
Expand Down Expand Up @@ -113,7 +115,7 @@ Duration getHttpClientSocketTimeout() {
}

Duration getHttpClientConnectionTimeout() {
return httpClientSocketTimeout;
return httpClientConnectionTimeout;
}

Map<String, Object> getCommonParams() {
Expand Down
15 changes: 11 additions & 4 deletions src/main/java/net/snowflake/client/core/SFStatement.java
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private TimeBombTask(SFStatement statement) {
@Override
public Void call() throws SQLException {
try {
statement.cancel();
statement.cancel(CancellationReason.TIMEOUT);
} catch (SFException ex) {
throw new SnowflakeSQLLoggedException(
session, ex.getSqlState(), ex.getVendorCode(), ex, ex.getParams());
Expand Down Expand Up @@ -711,10 +711,11 @@ private void reauthenticate() throws SFException, SnowflakeSQLException {
*
* @param sql sql statement
* @param mediaType media type
* @param cancellationReason reason for the cancellation
* @throws SnowflakeSQLException if failed to cancel the statement
* @throws SFException if statement is already closed
*/
private void cancelHelper(String sql, String mediaType)
private void cancelHelper(String sql, String mediaType, CancellationReason cancellationReason)
throws SnowflakeSQLException, SFException {
synchronized (this) {
if (isClosed) {
Expand All @@ -734,7 +735,7 @@ private void cancelHelper(String sql, String mediaType)
.setMaxRetries(session.getMaxHttpRetries())
.setHttpClientSettingsKey(session.getHttpClientKey());

StmtUtil.cancel(stmtInput);
StmtUtil.cancel(stmtInput, cancellationReason);

synchronized (this) {
/*
Expand Down Expand Up @@ -842,6 +843,12 @@ public void close() {
@Override
public void cancel() throws SFException, SQLException {
logger.trace("void cancel()", false);
cancel(CancellationReason.UNKNOWN);
}

@Override
public void cancel(CancellationReason cancellationReason) throws SFException, SQLException {
logger.trace("void cancel(CancellationReason)", false);

if (canceling.get()) {
logger.debug("Query is already cancelled", false);
Expand All @@ -866,7 +873,7 @@ public void cancel() throws SFException, SQLException {
}

// cancel the query on the server side if it has been issued
cancelHelper(this.sqlText, StmtUtil.SF_MEDIA_TYPE);
cancelHelper(this.sqlText, StmtUtil.SF_MEDIA_TYPE, cancellationReason);
}
}

Expand Down
17 changes: 16 additions & 1 deletion src/main/java/net/snowflake/client/core/StmtUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -681,8 +681,23 @@ protected static JsonNode getQueryResultJSON(String queryId, SFSession session)
* @param stmtInput input statement
* @throws SFException if there is an internal exception
* @throws SnowflakeSQLException if failed to cancel the statement
* @deprecated use {@link #cancel(StmtInput, CancellationReason)} instead
*/
@Deprecated
public static void cancel(StmtInput stmtInput) throws SFException, SnowflakeSQLException {
cancel(stmtInput, CancellationReason.UNKNOWN);
}

/**
* Cancel a statement identifiable by a request id
*
* @param stmtInput input statement
* @param cancellationReason reason for the cancellation
* @throws SFException if there is an internal exception
* @throws SnowflakeSQLException if failed to cancel the statement
*/
public static void cancel(StmtInput stmtInput, CancellationReason cancellationReason)
throws SFException, SnowflakeSQLException {
HttpPost httpRequest = null;

AssertUtil.assertTrue(
Expand All @@ -701,7 +716,7 @@ public static void cancel(StmtInput stmtInput) throws SFException, SnowflakeSQLE

try {
URIBuilder uriBuilder = new URIBuilder(stmtInput.serverUrl);

logger.warn("Cancelling query {} with reason {}", stmtInput.requestId, cancellationReason);
logger.debug("Aborting query: {}", stmtInput.sql);

uriBuilder.setPath(SF_PATH_ABORT_REQUEST_V1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@

import net.snowflake.client.core.DataConversionContext;
import net.snowflake.client.core.SFException;
import net.snowflake.client.core.arrow.tostringhelpers.ArrowArrayStringRepresentationBuilder;
import net.snowflake.client.jdbc.SnowflakeSQLException;
import net.snowflake.client.jdbc.SnowflakeType;
import org.apache.arrow.vector.FieldVector;
import org.apache.arrow.vector.complex.ListVector;

public class ArrayConverter extends AbstractArrowVectorConverter {
Expand All @@ -21,6 +24,25 @@ public Object toObject(int index) throws SFException {

@Override
public String toString(int index) throws SFException {
return vector.getObject(index).toString();
FieldVector vectorUnpacked = vector.getChildrenFromFields().get(0);
SnowflakeType logicalType =
ArrowVectorConverterUtil.getSnowflakeTypeFromFieldMetadata(vectorUnpacked.getField());

ArrowArrayStringRepresentationBuilder builder =
new ArrowArrayStringRepresentationBuilder(logicalType);

final ArrowVectorConverter converter;

try {
converter = ArrowVectorConverterUtil.initConverter(vectorUnpacked, context, columnIndex);
} catch (SnowflakeSQLException e) {
return vector.getObject(index).toString();
}

for (int i = vector.getElementStartIndex(index); i < vector.getElementEndIndex(index); i++) {
builder.appendValue(converter.toString(i));
}

return builder.toString();
}
}
Loading

0 comments on commit 63c3782

Please sign in to comment.