Skip to content

Commit

Permalink
Conflicts resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-dheyman committed Mar 29, 2024
2 parents 11af0d4 + 3b948af commit 6e0a26a
Show file tree
Hide file tree
Showing 18 changed files with 194 additions and 177 deletions.
7 changes: 1 addition & 6 deletions src/main/java/net/snowflake/client/core/ArrowSqlInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.List;
import java.util.Map;
import java.util.TimeZone;

import net.snowflake.client.core.structs.SQLDataCreationHelper;
import net.snowflake.client.jdbc.FieldMetadata;
import net.snowflake.client.util.ThrowingBiFunction;
Expand Down Expand Up @@ -187,11 +186,7 @@ public Timestamp readTimestamp(TimeZone tz) throws SQLException {
converters
.getStructuredTypeDateTimeConverter()
.getTimestamp(
(Map<String, Object>) value,
columnType,
columnSubType,
tz,
scale));
(Map<String, Object>) value, columnType, columnSubType, tz, scale));
});
}

Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/snowflake/client/core/BaseSqlInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.sql.SQLXML;
import java.sql.Timestamp;
import java.util.List;

import net.snowflake.client.jdbc.FieldMetadata;
import net.snowflake.client.jdbc.SnowflakeLoggedFeatureNotSupportedException;

Expand Down
14 changes: 10 additions & 4 deletions src/main/java/net/snowflake/client/core/Converters.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import java.util.Arrays;
import java.util.Map;
import java.util.TimeZone;

import net.snowflake.client.core.arrow.StructuredTypeDateTimeConverter;
import net.snowflake.client.core.json.*;
import net.snowflake.client.core.json.BooleanConverter;
import net.snowflake.client.core.json.BytesConverter;
import net.snowflake.client.core.json.DateTimeConverter;
import net.snowflake.client.core.json.NumberConverter;
import net.snowflake.client.core.json.StringConverter;
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1;
import net.snowflake.client.util.Converter;
Expand Down Expand Up @@ -232,8 +235,11 @@ public Converter timestampFromStringConverter(
};
}

public Converter timestampFromStructConverter(int columnType, int columnSubType, TimeZone tz, int scale) {
return value -> structuredTypeDateTimeConverter.getTimestamp((Map<String, Object>) value, columnType, columnSubType, tz, scale);
public Converter timestampFromStructConverter(
int columnType, int columnSubType, TimeZone tz, int scale) {
return value ->
structuredTypeDateTimeConverter.getTimestamp(
(Map<String, Object>) value, columnType, columnSubType, tz, scale);
}

@SnowflakeJdbcInternalApi
Expand Down
1 change: 0 additions & 1 deletion src/main/java/net/snowflake/client/core/JsonSqlInput.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.TimeZone;

import net.snowflake.client.core.structs.SQLDataCreationHelper;
import net.snowflake.client.jdbc.FieldMetadata;
import net.snowflake.client.jdbc.SnowflakeLoggedFeatureNotSupportedException;
Expand Down
113 changes: 61 additions & 52 deletions src/main/java/net/snowflake/client/core/SFArrowResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,29 @@
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.*;
import java.sql.Array;
import java.sql.Date;
import java.util.*;
import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.Time;
import java.sql.Timestamp;
import java.sql.Types;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import java.util.stream.Stream;
import net.snowflake.client.core.arrow.ArrowVectorConverter;
import net.snowflake.client.core.arrow.StructConverter;
import net.snowflake.client.core.arrow.VarCharConverter;
import net.snowflake.client.core.structs.StructureTypeHelper;
import net.snowflake.client.jdbc.*;
import net.snowflake.client.jdbc.ArrowResultChunk;
import net.snowflake.client.jdbc.ArrowResultChunk.ArrowChunkIterator;
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.FieldMetadata;
import net.snowflake.client.jdbc.SnowflakeColumnMetadata;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1;
import net.snowflake.client.jdbc.SnowflakeSQLException;
import net.snowflake.client.jdbc.SnowflakeSQLLoggedException;
import net.snowflake.client.jdbc.telemetry.Telemetry;
import net.snowflake.client.jdbc.telemetry.TelemetryData;
import net.snowflake.client.jdbc.telemetry.TelemetryField;
Expand Down Expand Up @@ -361,13 +372,10 @@ public Converters getConverters() {
@SnowflakeJdbcInternalApi
public SQLInput createSqlInputForColumn(Object input, int columnIndex, SFBaseSession session) {
return new ArrowSqlInput(
(Map<String, Object>) input,
session,
converters,
resultSetMetaData
.getColumnMetadata()
.get(columnIndex - 1)
.getFields());
(Map<String, Object>) input,
session,
converters,
resultSetMetaData.getColumnMetadata().get(columnIndex - 1).getFields());
}

@Override
Expand Down Expand Up @@ -596,79 +604,80 @@ private SfSqlArray getArrayInternal(List<Object> elements, int columnIndex) thro
switch (columnSubType) {
case Types.INTEGER:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.integerConverter(columnType))
.toArray(Integer[]::new));
columnSubType,
mapAndConvert(elements, converters.integerConverter(columnType))
.toArray(Integer[]::new));
case Types.SMALLINT:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.smallIntConverter(columnType))
.toArray(Short[]::new));
columnSubType,
mapAndConvert(elements, converters.smallIntConverter(columnType))
.toArray(Short[]::new));
case Types.TINYINT:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.tinyIntConverter(columnType))
.toArray(Byte[]::new));
columnSubType,
mapAndConvert(elements, converters.tinyIntConverter(columnType))
.toArray(Byte[]::new));
case Types.BIGINT:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.bigIntConverter(columnType)).toArray(Long[]::new));
columnSubType,
mapAndConvert(elements, converters.bigIntConverter(columnType)).toArray(Long[]::new));
case Types.DECIMAL:
case Types.NUMERIC:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.bigDecimalConverter(columnType)).toArray(BigDecimal[]::new));
columnSubType,
mapAndConvert(elements, converters.bigDecimalConverter(columnType))
.toArray(BigDecimal[]::new));
case Types.CHAR:
case Types.VARCHAR:
case Types.LONGNVARCHAR:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.varcharConverter(columnType, columnSubType, scale))
.toArray(String[]::new));
columnSubType,
mapAndConvert(elements, converters.varcharConverter(columnType, columnSubType, scale))
.toArray(String[]::new));
case Types.BINARY:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.bytesConverter(columnType, scale))
.toArray(Byte[][]::new));
columnSubType,
mapAndConvert(elements, converters.bytesConverter(columnType, scale))
.toArray(Byte[][]::new));
case Types.FLOAT:
case Types.REAL:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.floatConverter(columnType)).toArray(Float[]::new));
columnSubType,
mapAndConvert(elements, converters.floatConverter(columnType)).toArray(Float[]::new));
case Types.DOUBLE:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.doubleConverter(columnType))
.toArray(Double[]::new));
columnSubType,
mapAndConvert(elements, converters.doubleConverter(columnType))
.toArray(Double[]::new));
case Types.DATE:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.dateFromIntConverter(sessionTimezone)).toArray(Date[]::new));
columnSubType,
mapAndConvert(elements, converters.dateFromIntConverter(sessionTimezone))
.toArray(Date[]::new));
case Types.TIME:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.timeFromIntConverter(scale)).toArray(Time[]::new));
columnSubType,
mapAndConvert(elements, converters.timeFromIntConverter(scale)).toArray(Time[]::new));
case Types.TIMESTAMP:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements,
converters.timestampFromStructConverter(columnType, columnSubType, sessionTimezone, scale))
.toArray(Timestamp[]::new));
columnSubType,
mapAndConvert(
elements,
converters.timestampFromStructConverter(
columnType, columnSubType, sessionTimezone, scale))
.toArray(Timestamp[]::new));
case Types.BOOLEAN:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, converters.booleanConverter(columnType))
.toArray(Boolean[]::new));
columnSubType,
mapAndConvert(elements, converters.booleanConverter(columnType))
.toArray(Boolean[]::new));
case Types.STRUCT:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, e -> e)
.toArray(Map[]::new));
return new SfSqlArray(columnSubType, mapAndConvert(elements, e -> e).toArray(Map[]::new));
case Types.ARRAY:
return new SfSqlArray(
columnSubType,
mapAndConvert(elements, e -> ((List) e).stream().toArray(Map[]::new))
.toArray(Map[][]::new));
columnSubType,
mapAndConvert(elements, e -> ((List) e).stream().toArray(Map[]::new))
.toArray(Map[][]::new));
default:
throw new SFException(
ErrorCode.FEATURE_UNSUPPORTED,
Expand Down
16 changes: 12 additions & 4 deletions src/main/java/net/snowflake/client/core/SFBaseResultSet.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
package net.snowflake.client.core;

import java.math.BigDecimal;
import java.sql.*;
import java.sql.Array;
import java.sql.Date;
import java.util.*;

import java.sql.SQLException;
import java.sql.SQLInput;
import java.sql.Time;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TimeZone;
import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializable;
import net.snowflake.client.jdbc.SnowflakeResultSetSerializableV1;
Expand Down Expand Up @@ -208,7 +215,8 @@ public TimeZone getSessionTimeZone() {
}

@SnowflakeJdbcInternalApi
public abstract SQLInput createSqlInputForColumn(Object input, int columnIndex, SFBaseSession session);
public abstract SQLInput createSqlInputForColumn(
Object input, int columnIndex, SFBaseSession session);

@SnowflakeJdbcInternalApi
public abstract Date convertToDate(Object object, TimeZone tz) throws SFException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import java.sql.SQLException;
import java.util.List;

import net.snowflake.client.jdbc.ErrorCode;
import net.snowflake.client.jdbc.SFBaseFileTransferAgent;
import net.snowflake.client.jdbc.SFBaseFileTransferAgent.CommandType;
Expand Down
Loading

0 comments on commit 6e0a26a

Please sign in to comment.