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

SNOW-880860 Cache statement parameter values for HTAP change #1492

Merged
merged 2 commits into from
Aug 17, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ public void addProperty(String propertyName, Object propertyValue) throws SFExce
}
}

public Map<String, Object> getStatementParameters() {
return statementParametersMap;
}

/**
* Describe a statement. This is invoked when prepareStatement() occurs. SFStatementMetadata
* should be returned by this action, which contains metadata such as the schema of the result.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,8 @@

package net.snowflake.client.jdbc;

import static net.snowflake.client.core.Constants.GB;
import static net.snowflake.client.core.Constants.MB;
import static net.snowflake.client.core.SessionUtil.*;

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.channels.ClosedByInterruptException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;
import net.snowflake.client.core.*;
import net.snowflake.client.jdbc.telemetry.NoOpTelemetryClient;
import net.snowflake.client.jdbc.telemetry.Telemetry;
Expand All @@ -29,6 +18,18 @@
import org.apache.arrow.vector.VectorSchemaRoot;
import org.apache.arrow.vector.ipc.ArrowStreamReader;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.Serializable;
import java.nio.channels.ClosedByInterruptException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.*;

import static net.snowflake.client.core.Constants.GB;
import static net.snowflake.client.core.Constants.MB;
import static net.snowflake.client.core.SessionUtil.*;

/**
* This object is an intermediate object between result JSON from GS and ResultSet. Originally, it
* is created from result JSON. And it can also be serializable. Logically, it stands for a part of
Expand Down Expand Up @@ -572,6 +573,7 @@ public static SnowflakeResultSetSerializableV1 create(
SessionUtil.getCommonParams(rootNode.path("data").path("parameters"));
if (resultSetSerializable.parameters.isEmpty()) {
resultSetSerializable.parameters = sfSession.getCommonParameters();
resultSetSerializable.setStatemementLevelParameters(sfStatement.getStatementParameters());
}

// initialize column metadata
Expand Down Expand Up @@ -887,6 +889,18 @@ private static long initMemoryLimit(Map<String, Object> parameters) {
return memoryLimit;
}

/**
* If statement parameter values are available, set those values in the resultset list of
* parameters so they overwrite the session-level cached parameter values.
*
* @param stmtParamsMap
*/
private void setStatemementLevelParameters(Map<String, Object> stmtParamsMap) {
for (Map.Entry<String, Object> entry : stmtParamsMap.entrySet()) {
this.parameters.put(entry.getKey(), entry.getValue());
}
}

/**
* Setup all transient fields based on serialized fields and System Runtime.
*
Expand Down