diff --git a/jdbc/src/main/java/tech/ydb/jdbc/common/ColumnInfo.java b/jdbc/src/main/java/tech/ydb/jdbc/common/ColumnInfo.java index 8c914de..1cb6c2b 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/common/ColumnInfo.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/common/ColumnInfo.java @@ -28,7 +28,7 @@ public ColumnInfo(String name, Type type) { this.isOptional = desc.isOptional(); this.ydbType = desc.ydbType(); - this.isTimestamp = ydbType == PrimitiveType.Timestamp; + this.isTimestamp = ydbType == PrimitiveType.Timestamp || ydbType == PrimitiveType.Timestamp64; this.isNumber = ydbType == PrimitiveType.Int8 || ydbType == PrimitiveType.Uint8 || ydbType == PrimitiveType.Int16 || ydbType == PrimitiveType.Uint16 || ydbType == PrimitiveType.Int32 || ydbType == PrimitiveType.Uint32 diff --git a/jdbc/src/main/java/tech/ydb/jdbc/common/MappingGetters.java b/jdbc/src/main/java/tech/ydb/jdbc/common/MappingGetters.java index 261d0ce..768b930 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/common/MappingGetters.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/common/MappingGetters.java @@ -31,7 +31,8 @@ import tech.ydb.table.values.Value; public class MappingGetters { - private MappingGetters() { } + private MappingGetters() { + } @SuppressWarnings("Convert2Lambda") static Getters buildGetters(Type type) { @@ -168,6 +169,14 @@ private static ValueToString valueToString(PrimitiveType id) { return value -> String.valueOf(value.getTimestamp()); case Interval: return value -> String.valueOf(value.getInterval()); + case Date32: + return value -> String.valueOf(value.getDate32()); + case Datetime64: + return value -> String.valueOf(value.getDatetime64()); + case Timestamp64: + return value -> String.valueOf(value.getTimestamp64()); + case Interval64: + return value -> String.valueOf(value.getInterval64()); case TzDate: return value -> String.valueOf(value.getTzDate()); case TzDatetime: @@ -376,6 +385,8 @@ private static ValueToInt valueToInt(PrimitiveType id) { return value -> checkIntValue(id, value.getUint64()); case Date: return value -> checkIntValue(id, value.getDate().toEpochDay()); + case Date32: + return value -> checkIntValue(id, value.getDate32().toEpochDay()); default: return castToIntNotSupported(id.name()); } @@ -403,10 +414,16 @@ private static ValueToLong valueToLong(PrimitiveType id) { return PrimitiveReader::getUint64; case Date: return value -> value.getDate().toEpochDay(); + case Date32: + return value -> value.getDate32().toEpochDay(); case Datetime: return value -> value.getDatetime().toEpochSecond(ZoneOffset.UTC); + case Datetime64: + return value -> value.getDatetime64().toEpochSecond(ZoneOffset.UTC); case Timestamp: return value -> value.getTimestamp().toEpochMilli(); + case Timestamp64: + return value -> value.getTimestamp64().toEpochMilli(); case TzDate: case TzDatetime: case TzTimestamp: @@ -414,6 +431,8 @@ private static ValueToLong valueToLong(PrimitiveType id) { return value -> delegate.fromValue(value).toEpochMilli(); case Interval: return value -> TimeUnit.NANOSECONDS.toMicros(value.getInterval().toNanos()); + case Interval64: + return value -> TimeUnit.NANOSECONDS.toMicros(value.getInterval64().toNanos()); default: return castToLongNotSupported(id.name()); } @@ -515,6 +534,12 @@ private static ValueToInstant valueToInstant(PrimitiveType id) { return ValueReader::getTimestamp; case TzTimestamp: return v -> v.getTzTimestamp().toInstant(); + case Date32: + return v -> Instant.ofEpochSecond(v.getDate32().toEpochDay() * 24 * 60 * 60); + case Datetime64: + return v -> Instant.ofEpochSecond(v.getDatetime64().toEpochSecond(ZoneOffset.UTC)); + case Timestamp64: + return ValueReader::getTimestamp64; default: return castToInstantNotSupported(id.name()); } @@ -628,12 +653,16 @@ private static SqlType buildPrimitiveType(int sqlType, PrimitiveType id) { case Double: return new SqlType(sqlType, Double.class); case Date: + case Date32: return new SqlType(sqlType, LocalDate.class); case Datetime: + case Datetime64: return new SqlType(sqlType, LocalDateTime.class); case Timestamp: + case Timestamp64: return new SqlType(sqlType, Instant.class); case Interval: + case Interval64: return new SqlType(sqlType, Duration.class); case TzDate: case TzDatetime: @@ -708,6 +737,14 @@ private static ValueToObject valueToObject(PrimitiveType id) { return PrimitiveReader::getTzDatetime; case TzTimestamp: return PrimitiveReader::getTzTimestamp; + case Date32: + return PrimitiveReader::getDate32; + case Datetime64: + return PrimitiveReader::getDatetime64; + case Timestamp64: + return PrimitiveReader::getTimestamp64; + case Interval64: + return PrimitiveReader::getInterval64; default: // DyNumber return value -> { @@ -745,7 +782,7 @@ public T fromValue(ValueReader reader, Class clazz) throws SQLException { } } - + @SuppressWarnings("MethodLength") private static ValueToClass valueToClass(PrimitiveType id) { ValueToClassBuilder builder = new ValueToClassBuilder(id); switch (id) { @@ -870,6 +907,49 @@ private static ValueToClass valueToClass(PrimitiveType id) { return builder .register(Duration.class, ValueReader::getInterval) .build(); + case Date32: + return builder + .register(long.class, v -> v.getDate32().toEpochDay()) + .register(Long.class, v -> v.getDate32().toEpochDay()) + .register(LocalDate.class, ValueReader::getDate32) + .register(LocalDateTime.class, v -> v.getDate32().atStartOfDay()) + .register(java.sql.Date.class, v -> java.sql.Date.valueOf(v.getDate32())) + .register(java.sql.Timestamp.class, + v -> java.sql.Timestamp.valueOf(v.getDate32().atStartOfDay())) + .register(Instant.class, v -> v.getDate32().atStartOfDay(ZoneId.systemDefault()).toInstant()) + .register(java.util.Date.class, v -> java.util.Date.from( + v.getDate32().atStartOfDay(ZoneId.systemDefault()).toInstant())) + .build(); + case Datetime64: + return builder + .register(long.class, v -> v.getDatetime64().toEpochSecond(ZoneOffset.UTC)) + .register(Long.class, v -> v.getDatetime64().toEpochSecond(ZoneOffset.UTC)) + .register(LocalDate.class, v -> v.getDatetime64().toLocalDate()) + .register(LocalDateTime.class, ValueReader::getDatetime64) + .register(java.sql.Date.class, v -> java.sql.Date.valueOf(v.getDatetime64().toLocalDate())) + .register(java.sql.Timestamp.class, v -> java.sql.Timestamp.valueOf(v.getDatetime64())) + .register(Instant.class, v -> v.getDatetime64().atZone(ZoneId.systemDefault()).toInstant()) + .register(java.util.Date.class, v -> java.util.Date.from( + v.getDatetime64().atZone(ZoneId.systemDefault()).toInstant())) + .build(); + case Timestamp64: + return builder + .register(long.class, v -> v.getTimestamp64().toEpochMilli()) + .register(Long.class, v -> v.getTimestamp64().toEpochMilli()) + .register(LocalDate.class, v -> v.getTimestamp64().atZone(ZoneId.systemDefault()).toLocalDate()) + .register(LocalDateTime.class, v -> v.getTimestamp64() + .atZone(ZoneId.systemDefault()).toLocalDateTime()) + .register(java.sql.Date.class, v -> java.sql.Date + .valueOf(v.getTimestamp64().atZone(ZoneId.systemDefault()).toLocalDate())) + .register(java.sql.Timestamp.class, v -> java.sql.Timestamp + .valueOf(v.getTimestamp64().atZone(ZoneId.systemDefault()).toLocalDateTime())) + .register(Instant.class, ValueReader::getTimestamp64) + .register(java.util.Date.class, v -> java.util.Date.from(v.getTimestamp64())) + .build(); + case Interval64: + return builder + .register(Duration.class, ValueReader::getInterval64) + .build(); case TzDate: return builder .register(ZonedDateTime.class, ValueReader::getTzDate) diff --git a/jdbc/src/main/java/tech/ydb/jdbc/common/MappingSetters.java b/jdbc/src/main/java/tech/ydb/jdbc/common/MappingSetters.java index 1eaa7b9..acd5a15 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/common/MappingSetters.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/common/MappingSetters.java @@ -37,7 +37,8 @@ public class MappingSetters { private static final int DEFAULT_BUF_SIZE = 0x800; - private MappingSetters() { } + private MappingSetters() { + } static Setters buildSetters(Type type) { return buildToValueImpl(type); @@ -97,6 +98,14 @@ private static Setters buildToValueImpl(Type type) { return x -> PrimitiveValue.newTzDatetime(castAsZonedDateTime(id, x)); case TzTimestamp: return x -> PrimitiveValue.newTzTimestamp(castAsZonedDateTime(id, x)); + case Date32: + return x -> castToDate32(id, x); + case Datetime64: + return x -> castToDateTime64(id, x); + case Timestamp64: + return x -> castToTimestamp64(id, x); + case Interval64: + return x -> castToInterval64(id, x); default: return x -> { throw castNotSupported(id, x); @@ -502,6 +511,108 @@ private static PrimitiveValue castToTimestamp(PrimitiveType type, Object x) thro throw castNotSupported(type, x); } + private static PrimitiveValue castToInterval64(PrimitiveType type, Object x) throws SQLException { + if (x instanceof Duration) { + return PrimitiveValue.newInterval64((Duration) x); + } else if (x instanceof Long) { + return PrimitiveValue.newInterval64((Long) x); + } else if (x instanceof String) { + Duration parsed; + try { + parsed = Duration.parse((String) x); + } catch (DateTimeParseException e) { + throw castNotSupported(type, x, e); + } + return PrimitiveValue.newInterval64(parsed); + } + throw castNotSupported(type, x); + } + + private static PrimitiveValue castToDate32(PrimitiveType type, Object x) throws SQLException { + if (x instanceof Instant) { + return PrimitiveValue.newDate32(((Instant) x).atZone(ZoneId.systemDefault()).toLocalDate()); + } else if (x instanceof LocalDateTime) { + return PrimitiveValue.newDate32(((LocalDateTime) x).toLocalDate()); + } else if (x instanceof LocalDate) { + return PrimitiveValue.newDate32((LocalDate) x); + } else if (x instanceof Integer) { + return PrimitiveValue.newDate32(LocalDate.ofEpochDay((Integer) x)); + } else if (x instanceof Long) { + return PrimitiveValue.newDate32(LocalDate.ofEpochDay((Long) x)); + } else if (x instanceof Timestamp) { + // Normalize date - use system timezone to detect correct date + Instant instant = Instant.ofEpochMilli(((Timestamp) x).getTime()); + LocalDate ld = instant.atZone(ZoneId.systemDefault()).toLocalDate(); + return PrimitiveValue.newDate32(ld); + } else if (x instanceof Date) { + // Normalize date - use system timezone to detect correct date + Instant instant = Instant.ofEpochMilli(((Date) x).getTime()); + LocalDate ld = instant.atZone(ZoneId.systemDefault()).toLocalDate(); + return PrimitiveValue.newDate32(ld); + } else if (x instanceof String) { + try { + return PrimitiveValue.newDate32(LocalDate.parse((String) x)); + } catch (DateTimeParseException e) { + throw castNotSupported(type, x, e); + } + } + throw castNotSupported(type, x); + } + + private static PrimitiveValue castToDateTime64(PrimitiveType type, Object x) throws SQLException { + if (x instanceof Instant) { + return PrimitiveValue.newDatetime64(((Instant) x).atZone(ZoneId.systemDefault()).toLocalDateTime()); + } else if (x instanceof LocalDateTime) { + return PrimitiveValue.newDatetime64(((LocalDateTime) x)); + } else if (x instanceof LocalDate) { + return PrimitiveValue.newDatetime64(((LocalDate) x).atStartOfDay()); + } else if (x instanceof Long) { + return PrimitiveValue.newDatetime64(LocalDateTime.ofEpochSecond((Long) x, 0, ZoneOffset.UTC)); + } else if (x instanceof Timestamp) { + // Normalize date - use system timezone to detect correct date + Instant instant = Instant.ofEpochMilli(((Timestamp) x).getTime()); + LocalDateTime ldt = instant.atZone(ZoneId.systemDefault()).toLocalDateTime(); + return PrimitiveValue.newDatetime64(ldt); + } else if (x instanceof Date) { + // Normalize date - use system timezone to detect correct date + Instant instant = Instant.ofEpochMilli(((Date) x).getTime()); + LocalDate ld = instant.atZone(ZoneId.systemDefault()).toLocalDate(); + return PrimitiveValue.newDatetime64(ld.atStartOfDay()); + } else if (x instanceof String) { + try { + return PrimitiveValue.newDatetime64(LocalDateTime.parse((String) x)); + } catch (DateTimeParseException e) { + throw castNotSupported(type, x, e); + } + } + throw castNotSupported(type, x); + } + + private static PrimitiveValue castToTimestamp64(PrimitiveType type, Object x) throws SQLException { + if (x instanceof Instant) { + return PrimitiveValue.newTimestamp64((Instant) x); + } else if (x instanceof Long) { + return PrimitiveValue.newTimestamp64(Instant.ofEpochMilli((Long) x)); + } else if (x instanceof LocalDate) { + return PrimitiveValue.newTimestamp64(((LocalDate) x).atStartOfDay().toInstant(ZoneOffset.UTC)); + } else if (x instanceof LocalDateTime) { + long epochSeconds = ((LocalDateTime) x).toEpochSecond(ZoneOffset.UTC); + return PrimitiveValue.newTimestamp64(Instant.ofEpochSecond(epochSeconds)); + } else if (x instanceof Timestamp) { + return PrimitiveValue.newTimestamp64(((Timestamp) x).toInstant()); + } else if (x instanceof Date) { + Instant instant = ((Date) x).toLocalDate().atStartOfDay().toInstant(ZoneOffset.UTC); + return PrimitiveValue.newTimestamp64(instant); + } else if (x instanceof String) { + try { + return PrimitiveValue.newTimestamp64(Instant.parse((String) x)); + } catch (DateTimeParseException e) { + throw castNotSupported(type, x, e); + } + } + throw castNotSupported(type, x); + } + private static DecimalValue validateValue(DecimalType type, DecimalValue value, Object x) throws SQLException { if (value.isNan()) { throw new SQLException(String.format(YdbConst.UNABLE_TO_CAST_TO_DECIMAL, type, toString(x), "NaN")); diff --git a/jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java b/jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java index 6751122..ea4bb4b 100644 --- a/jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java +++ b/jdbc/src/main/java/tech/ydb/jdbc/impl/YdbTypes.java @@ -64,6 +64,12 @@ private YdbTypes() { typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 22, PrimitiveType.TzTimestamp); typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 23, PrimitiveType.JsonDocument); + typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 24, PrimitiveType.DyNumber); + + typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 25, PrimitiveType.Date32); + typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 26, PrimitiveType.Datetime64); + typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 27, PrimitiveType.Timestamp64); + typeBySqlType.put(YdbConst.SQL_KIND_PRIMITIVE + 28, PrimitiveType.Interval64); typeBySqlType.put(Types.VARCHAR, PrimitiveType.Text); typeBySqlType.put(Types.BIGINT, PrimitiveType.Int64); @@ -192,16 +198,19 @@ private int toSqlTypeImpl(Type type) { case Int64: case Uint64: case Interval: + case Interval64: return Types.BIGINT; case Float: return Types.FLOAT; case Double: return Types.DOUBLE; case Date: + case Date32: return Types.DATE; case Datetime: - return Types.TIMESTAMP; case Timestamp: + case Datetime64: + case Timestamp64: return Types.TIMESTAMP; case TzDate: case TzDatetime: @@ -294,7 +303,11 @@ private List getAllDatabaseTypesImpl() { PrimitiveType.Datetime, PrimitiveType.Timestamp, PrimitiveType.Interval, - DecimalType.getDefault()); + DecimalType.getDefault(), + PrimitiveType.Date32, + PrimitiveType.Datetime64, + PrimitiveType.Timestamp64, + PrimitiveType.Interval64); } private int getSqlPrecisionImpl(PrimitiveType type) { @@ -314,6 +327,7 @@ private int getSqlPrecisionImpl(PrimitiveType type) { case Uint64: case Double: case Interval: + case Interval64: return 8; case Bytes: case Text: @@ -324,10 +338,13 @@ private int getSqlPrecisionImpl(PrimitiveType type) { case Uuid: return 8 + 8; case Date: + case Date32: return "0000-00-00".length(); case Datetime: + case Datetime64: return "0000-00-00 00:00:00".length(); case Timestamp: + case Timestamp64: return "0000-00-00T00:00:00.000000".length(); case TzDate: return "0000-00-00+00:00".length(); diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbDatabaseMetaDataImplTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbDatabaseMetaDataImplTest.java index 210c049..44d89c3 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbDatabaseMetaDataImplTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbDatabaseMetaDataImplTest.java @@ -61,10 +61,10 @@ public static void createTables() throws SQLException { + "create table `dir2/t1` (id Int32, value Int32, primary key (id));\n" + "create table `dir2/dir1/t1` (id Int32, value Int32, primary key (id));\n" + "create table " + INDEXES_TABLE + "(" - + "key1 Int32, key2 Text, value1 Int32, value2 Text, value3 Int32, " - + "primary key(key1, key2), " - + "index idx_2 global on (value1, value2)," - + "index idx_1 global on (value3))\n;" + + "key1 Int32, key2 Text, value1 Int32, value2 Text, value3 Int32, " + + "primary key(key1, key2), " + + "index idx_2 global on (value1, value2)," + + "index idx_1 global on (value3))\n;" ); } } @@ -364,9 +364,9 @@ public void getTableTypes() throws SQLException { @Test public void getTypeInfo() throws SQLException { - short searchNone = (short)DatabaseMetaData.typePredNone; - short searchBasic = (short)DatabaseMetaData.typePredBasic; - short searchFull = (short)DatabaseMetaData.typeSearchable; + short searchNone = (short) DatabaseMetaData.typePredNone; + short searchBasic = (short) DatabaseMetaData.typePredBasic; + short searchFull = (short) DatabaseMetaData.typeSearchable; TableAssert types = new TableAssert(); TableAssert.TextColumn name = types.addTextColumn("TYPE_NAME", "Text"); @@ -374,19 +374,27 @@ public void getTypeInfo() throws SQLException { TableAssert.IntColumn precision = types.addIntColumn("PRECISION", "Int32"); TableAssert.TextColumn prefix = types.addTextColumn("LITERAL_PREFIX", "Text").defaultNull(); TableAssert.TextColumn suffix = types.addTextColumn("LITERAL_SUFFIX", "Text").defaultNull(); - /* createParams = */types.addTextColumn("CREATE_PARAMS", "Text").defaultNull(); - /* nullable = */types.addShortColumn("NULLABLE", "Int16").defaultValue((short) DatabaseMetaData.typeNullable); - /* caseSensitive = */types.addBoolColumn("CASE_SENSITIVE", "Bool").defaultValue(true); + /* createParams = */ + types.addTextColumn("CREATE_PARAMS", "Text").defaultNull(); + /* nullable = */ + types.addShortColumn("NULLABLE", "Int16").defaultValue((short) DatabaseMetaData.typeNullable); + /* caseSensitive = */ + types.addBoolColumn("CASE_SENSITIVE", "Bool").defaultValue(true); TableAssert.ShortColumn searchable = types.addShortColumn("SEARCHABLE", "Int16").defaultValue(searchBasic); TableAssert.BoolColumn unsigned = types.addBoolColumn("UNSIGNED_ATTRIBUTE", "Bool"); TableAssert.BoolColumn fixedPrec = types.addBoolColumn("FIXED_PREC_SCALE", "Bool").defaultValue(false); - /* autoIncrement = */types.addBoolColumn("AUTO_INCREMENT", "Bool").defaultValue(false); - /* localName = */types.addTextColumn("LOCAL_TYPE_NAME", "Text").defaultNull(); + /* autoIncrement = */ + types.addBoolColumn("AUTO_INCREMENT", "Bool").defaultValue(false); + /* localName = */ + types.addTextColumn("LOCAL_TYPE_NAME", "Text").defaultNull(); TableAssert.ShortColumn minScale = types.addShortColumn("MINIMUM_SCALE", "Int16").defaultValue((short) 0); TableAssert.ShortColumn maxScale = types.addShortColumn("MAXIMUM_SCALE", "Int16").defaultValue((short) 0); - /* sqlDataType = */types.addIntColumn("SQL_DATA_TYPE", "Int32").defaultValue(0); - /* sqlDatetimeSub = */types.addIntColumn("SQL_DATETIME_SUB", "Int32").defaultValue(0); - /* numPrecRadix = */types.addIntColumn("NUM_PREC_RADIX", "Int32").defaultValue(10); + /* sqlDataType = */ + types.addIntColumn("SQL_DATA_TYPE", "Int32").defaultValue(0); + /* sqlDatetimeSub = */ + types.addIntColumn("SQL_DATETIME_SUB", "Int32").defaultValue(0); + /* numPrecRadix = */ + types.addIntColumn("NUM_PREC_RADIX", "Int32").defaultValue(10); TableAssert.ResultSetAssert rs = types.check(metaData.getTypeInfo()) .assertMetaColumns(); @@ -427,6 +435,11 @@ public void getTypeInfo() throws SQLException { rs.nextRow(name.eq("Decimal(22, 9)"), type.eq(Types.DECIMAL), precision.eq(22), unsigned.eq(false), fixedPrec.eq(true), minScale.eq(9), maxScale.eq(9)).assertAll(); + rs.nextRow(name.eq("Date32"), type.eq(Types.DATE), precision.eq(10), unsigned.eq(false)).assertAll(); + rs.nextRow(name.eq("Datetime64"), type.eq(Types.TIMESTAMP), precision.eq(19), unsigned.eq(false)).assertAll(); + rs.nextRow(name.eq("Timestamp64"), type.eq(Types.TIMESTAMP), precision.eq(26), unsigned.eq(false)).assertAll(); + rs.nextRow(name.eq("Interval64"), type.eq(Types.BIGINT), precision.eq(8), unsigned.eq(false)).assertAll(); + rs.assertNoRows(); } @@ -442,17 +455,25 @@ public void getTables() throws SQLException { "all_types" ); - TableAssert tables = new TableAssert(); - /* tableCatalog = */ tables.addTextColumn("TABLE_CAT", "Text").defaultNull(); - /* tableSchema = */ tables.addTextColumn("TABLE_SCHEM", "Text").defaultNull(); + TableAssert tables = new TableAssert(); + /* tableCatalog = */ + tables.addTextColumn("TABLE_CAT", "Text").defaultNull(); + /* tableSchema = */ + tables.addTextColumn("TABLE_SCHEM", "Text").defaultNull(); TableAssert.TextColumn tableName = tables.addTextColumn("TABLE_NAME", "Text"); TableAssert.TextColumn tableType = tables.addTextColumn("TABLE_TYPE", "Text"); - /* remarks = */ tables.addTextColumn("REMARKS", "Text").defaultNull(); - /* typeCatalog = */ tables.addTextColumn("TYPE_CAT", "Text").defaultNull(); - /* typeSchema = */ tables.addTextColumn("TYPE_SCHEM", "Text").defaultNull(); - /* typeName = */ tables.addTextColumn("TYPE_NAME", "Text").defaultNull(); - /* selfRefColName = */ tables.addTextColumn("SELF_REFERENCING_COL_NAME", "Text").defaultNull(); - /* refGeneration = */ tables.addTextColumn("REF_GENERATION", "Text").defaultNull(); + /* remarks = */ + tables.addTextColumn("REMARKS", "Text").defaultNull(); + /* typeCatalog = */ + tables.addTextColumn("TYPE_CAT", "Text").defaultNull(); + /* typeSchema = */ + tables.addTextColumn("TYPE_SCHEM", "Text").defaultNull(); + /* typeName = */ + tables.addTextColumn("TYPE_NAME", "Text").defaultNull(); + /* selfRefColName = */ + tables.addTextColumn("SELF_REFERENCING_COL_NAME", "Text").defaultNull(); + /* refGeneration = */ + tables.addTextColumn("REF_GENERATION", "Text").defaultNull(); // wrong filters tables.check(metaData.getTables("-", null, null, null)).assertMetaColumns().assertNoRows(); @@ -474,10 +495,10 @@ public void getTables() throws SQLException { TableAssert.ResultSetAssert rs = tables.check(metaData.getTables(null, null, null, null)) .assertMetaColumns(); // system tables are first - for (String name: systemTables) { + for (String name : systemTables) { rs.nextRow(tableName.eq(name), tableType.eq(SYSTEM_TABLE_TYPE)); } - for (String name: simpleTables) { + for (String name : simpleTables) { rs.nextRow(tableName.eq(name), tableType.eq(TABLE_TYPE)); } // TODO: fix @@ -486,7 +507,7 @@ public void getTables() throws SQLException { // read only non system tables rs = tables.check(metaData.getTables(null, null, null, asArray(TABLE_TYPE))) .assertMetaColumns(); - for (String name: simpleTables) { + for (String name : simpleTables) { rs.nextRow(tableName.eq(name), tableType.eq(TABLE_TYPE)); } // TODO: fix @@ -496,10 +517,10 @@ public void getTables() throws SQLException { rs = tables.check(metaData.getTables(null, null, null, asArray(TABLE_TYPE, "some string", SYSTEM_TABLE_TYPE))) .assertMetaColumns(); // system tables are first - for (String name: systemTables) { + for (String name : systemTables) { rs.nextRow(tableName.eq(name), tableType.eq(SYSTEM_TABLE_TYPE)); } - for (String name: simpleTables) { + for (String name : simpleTables) { rs.nextRow(tableName.eq(name), tableType.eq(TABLE_TYPE)); } // TODO: fix @@ -553,7 +574,7 @@ public void getColumns() throws SQLException { columns.addTextColumn("SCOPE_CATALOG", "Text").defaultNull(); columns.addTextColumn("SCOPE_SCHEMA", "Text").defaultNull(); columns.addTextColumn("SCOPE_TABLE", "Text").defaultNull(); - columns.addShortColumn("SOURCE_DATA_TYPE", "Int16").defaultValue((short)0); + columns.addShortColumn("SOURCE_DATA_TYPE", "Int16").defaultValue((short) 0); columns.addTextColumn("IS_AUTOINCREMENT", "Text").defaultValue("NO"); columns.addTextColumn("IS_GENERATEDCOLUMN", "Text").defaultValue("NO"); @@ -566,72 +587,81 @@ public void getColumns() throws SQLException { TableAssert.ResultSetAssert rs = columns.check(metaData.getColumns(null, null, ALL_TYPES_TABLE, null)) .assertMetaColumns(); + rs.nextRow(columnName.eq("c_Interval64"), dataType.eq(Types.BIGINT), typeName.eq("Interval64"), + columnSize.eq(8), ordinal.eq(1)).assertAll(); rs.nextRow(columnName.eq("key"), dataType.eq(Types.INTEGER), typeName.eq("Int32"), - columnSize.eq(4), ordinal.eq(1)).assertAll(); + columnSize.eq(4), ordinal.eq(2)).assertAll(); rs.nextRow(columnName.eq("c_Bool"), dataType.eq(Types.BOOLEAN), typeName.eq("Bool"), - columnSize.eq(1), ordinal.eq(2)).assertAll(); + columnSize.eq(1), ordinal.eq(3)).assertAll(); rs.nextRow(columnName.eq("c_Int8"), dataType.eq(Types.SMALLINT), typeName.eq("Int8"), - columnSize.eq(1), ordinal.eq(3)).assertAll(); + columnSize.eq(1), ordinal.eq(4)).assertAll(); rs.nextRow(columnName.eq("c_Int16"), dataType.eq(Types.SMALLINT), typeName.eq("Int16"), - columnSize.eq(2), ordinal.eq(4)).assertAll(); + columnSize.eq(2), ordinal.eq(5)).assertAll(); rs.nextRow(columnName.eq("c_Int32"), dataType.eq(Types.INTEGER), typeName.eq("Int32"), - columnSize.eq(4), ordinal.eq(5)).assertAll(); + columnSize.eq(4), ordinal.eq(6)).assertAll(); rs.nextRow(columnName.eq("c_Int64"), dataType.eq(Types.BIGINT), typeName.eq("Int64"), - columnSize.eq(8), ordinal.eq(6)).assertAll(); + columnSize.eq(8), ordinal.eq(7)).assertAll(); rs.nextRow(columnName.eq("c_Uint8"), dataType.eq(Types.INTEGER), typeName.eq("Uint8"), - columnSize.eq(1), ordinal.eq(7)).assertAll(); + columnSize.eq(1), ordinal.eq(8)).assertAll(); rs.nextRow(columnName.eq("c_Uint16"), dataType.eq(Types.INTEGER), typeName.eq("Uint16"), - columnSize.eq(2), ordinal.eq(8)).assertAll(); + columnSize.eq(2), ordinal.eq(9)).assertAll(); rs.nextRow(columnName.eq("c_Uint32"), dataType.eq(Types.BIGINT), typeName.eq("Uint32"), - columnSize.eq(4), ordinal.eq(9)).assertAll(); + columnSize.eq(4), ordinal.eq(10)).assertAll(); rs.nextRow(columnName.eq("c_Uint64"), dataType.eq(Types.BIGINT), typeName.eq("Uint64"), - columnSize.eq(8), ordinal.eq(10)).assertAll(); + columnSize.eq(8), ordinal.eq(11)).assertAll(); rs.nextRow(columnName.eq("c_Float"), dataType.eq(Types.FLOAT), typeName.eq("Float"), - columnSize.eq(4), ordinal.eq(11)).assertAll(); + columnSize.eq(4), ordinal.eq(12)).assertAll(); rs.nextRow(columnName.eq("c_Double"), dataType.eq(Types.DOUBLE), typeName.eq("Double"), - columnSize.eq(8), ordinal.eq(12)).assertAll(); + columnSize.eq(8), ordinal.eq(13)).assertAll(); rs.nextRow(columnName.eq("c_Bytes"), dataType.eq(Types.BINARY), typeName.eq("Bytes"), - columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(13)).assertAll(); - rs.nextRow(columnName.eq("c_Text"), dataType.eq(Types.VARCHAR), typeName.eq("Text"), columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(14)).assertAll(); - rs.nextRow(columnName.eq("c_Json"), dataType.eq(Types.VARCHAR), typeName.eq("Json"), + rs.nextRow(columnName.eq("c_Text"), dataType.eq(Types.VARCHAR), typeName.eq("Text"), columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(15)).assertAll(); - rs.nextRow(columnName.eq("c_JsonDocument"), dataType.eq(Types.VARCHAR), typeName.eq("JsonDocument"), + rs.nextRow(columnName.eq("c_Json"), dataType.eq(Types.VARCHAR), typeName.eq("Json"), columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(16)).assertAll(); - rs.nextRow(columnName.eq("c_Yson"), dataType.eq(Types.BINARY), typeName.eq("Yson"), + rs.nextRow(columnName.eq("c_JsonDocument"), dataType.eq(Types.VARCHAR), typeName.eq("JsonDocument"), columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(17)).assertAll(); + rs.nextRow(columnName.eq("c_Yson"), dataType.eq(Types.BINARY), typeName.eq("Yson"), + columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(18)).assertAll(); rs.nextRow(columnName.eq("c_Uuid"), dataType.eq(Types.VARCHAR), typeName.eq("Uuid"), - columnSize.eq(16), ordinal.eq(18)).assertAll(); + columnSize.eq(16), ordinal.eq(19)).assertAll(); rs.nextRow(columnName.eq("c_Date"), dataType.eq(Types.DATE), typeName.eq("Date"), - columnSize.eq(10), ordinal.eq(19)).assertAll(); + columnSize.eq(10), ordinal.eq(20)).assertAll(); rs.nextRow(columnName.eq("c_Datetime"), dataType.eq(Types.TIMESTAMP), typeName.eq("Datetime"), - columnSize.eq(19), ordinal.eq(20)).assertAll(); + columnSize.eq(19), ordinal.eq(21)).assertAll(); rs.nextRow(columnName.eq("c_Timestamp"), dataType.eq(Types.TIMESTAMP), typeName.eq("Timestamp"), - columnSize.eq(26), ordinal.eq(21)).assertAll(); + columnSize.eq(26), ordinal.eq(22)).assertAll(); rs.nextRow(columnName.eq("c_Interval"), dataType.eq(Types.BIGINT), typeName.eq("Interval"), - columnSize.eq(8), ordinal.eq(22)).assertAll(); + columnSize.eq(8), ordinal.eq(23)).assertAll(); rs.nextRow(columnName.eq("c_Decimal"), dataType.eq(Types.DECIMAL), typeName.eq("Decimal(22, 9)"), - columnSize.eq(22), ordinal.eq(23), decimalDigits.eq(22)).assertAll(); + columnSize.eq(22), ordinal.eq(24), decimalDigits.eq(22)).assertAll(); rs.nextRow(columnName.eq("c_BigDecimal"), dataType.eq(Types.DECIMAL), typeName.eq("Decimal(35, 0)"), - columnSize.eq(35), ordinal.eq(24), decimalDigits.eq(35)).assertAll(); + columnSize.eq(35), ordinal.eq(25), decimalDigits.eq(35)).assertAll(); rs.nextRow(columnName.eq("c_BankDecimal"), dataType.eq(Types.DECIMAL), typeName.eq("Decimal(31, 9)"), - columnSize.eq(31), ordinal.eq(25), decimalDigits.eq(31)).assertAll(); + columnSize.eq(31), ordinal.eq(26), decimalDigits.eq(31)).assertAll(); + + rs.nextRow(columnName.eq("c_Date32"), dataType.eq(Types.DATE), typeName.eq("Date32"), + columnSize.eq(10), ordinal.eq(27)).assertAll(); + rs.nextRow(columnName.eq("c_Datetime64"), dataType.eq(Types.TIMESTAMP), typeName.eq("Datetime64"), + columnSize.eq(19), ordinal.eq(28)).assertAll(); + rs.nextRow(columnName.eq("c_Timestamp64"), dataType.eq(Types.TIMESTAMP), typeName.eq("Timestamp64"), + columnSize.eq(26), ordinal.eq(29)).assertAll(); rs.assertNoRows(); // find only one column rs = columns.check(metaData.getColumns(null, null, ALL_TYPES_TABLE, "c_JsonDocument")) - .assertMetaColumns(); + .assertMetaColumns(); rs.nextRow(columnName.eq("c_JsonDocument"), dataType.eq(Types.VARCHAR), typeName.eq("JsonDocument"), - columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(16)).assertAll(); + columnSize.eq(YdbConst.MAX_COLUMN_SIZE), ordinal.eq(17)).assertAll(); rs.assertNoRows(); } @@ -730,8 +760,8 @@ public void getBestRowIdentifier() throws SQLException { TableAssert.TextColumn typeName = rowIdentifiers.addTextColumn("TYPE_NAME", "Text"); rowIdentifiers.addIntColumn("COLUMN_SIZE", "Int32").defaultValue(0); rowIdentifiers.addIntColumn("BUFFER_LENGTH", "Int32").defaultValue(0); - rowIdentifiers.addShortColumn("DECIMAL_DIGITS", "Int16").defaultValue((short)0); - rowIdentifiers.addShortColumn("PSEUDO_COLUMN", "Int16").defaultValue((short)DatabaseMetaData.bestRowNotPseudo); + rowIdentifiers.addShortColumn("DECIMAL_DIGITS", "Int16").defaultValue((short) 0); + rowIdentifiers.addShortColumn("PSEUDO_COLUMN", "Int16").defaultValue((short) DatabaseMetaData.bestRowNotPseudo); rowIdentifiers.check(metaData.getBestRowIdentifier("-", null, null, DatabaseMetaData.bestRowSession, true)) @@ -750,21 +780,21 @@ public void getBestRowIdentifier() throws SQLException { .getBestRowIdentifier(null, null, ALL_TYPES_TABLE, DatabaseMetaData.bestRowSession, false)); rowIdentifiers.check(metaData - .getBestRowIdentifier(null, null, ALL_TYPES_TABLE, DatabaseMetaData.bestRowSession, true)) + .getBestRowIdentifier(null, null, ALL_TYPES_TABLE, DatabaseMetaData.bestRowSession, true)) .assertMetaColumns() .nextRow(name.eq("key"), dataType.eq(Types.INTEGER), typeName.eq("Int32"), scope.eq(DatabaseMetaData.bestRowSession)).assertAll() .assertNoRows(); rowIdentifiers.check(metaData - .getBestRowIdentifier(null, null, ALL_TYPES_TABLE, DatabaseMetaData.bestRowTransaction, true)) + .getBestRowIdentifier(null, null, ALL_TYPES_TABLE, DatabaseMetaData.bestRowTransaction, true)) .assertMetaColumns() .nextRow(name.eq("key"), dataType.eq(Types.INTEGER), typeName.eq("Int32"), scope.eq(DatabaseMetaData.bestRowTransaction)).assertAll() .assertNoRows(); rowIdentifiers.check(metaData - .getBestRowIdentifier(null, null, INDEXES_TABLE, DatabaseMetaData.bestRowTemporary, true)) + .getBestRowIdentifier(null, null, INDEXES_TABLE, DatabaseMetaData.bestRowTemporary, true)) .assertMetaColumns() .nextRow(name.eq("key1"), dataType.eq(Types.INTEGER), typeName.eq("Int32"), scope.eq(DatabaseMetaData.bestRowTemporary)).assertAll() diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbLazyResultSetImplTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbLazyResultSetImplTest.java index caee5e6..9c7e8bf 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbLazyResultSetImplTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbLazyResultSetImplTest.java @@ -181,7 +181,7 @@ public void getMetaData() throws SQLException { ExceptionAssert.sqlException("Column is out of range: 995", () -> metadata.getColumnName(995)); - Assertions.assertEquals(25, metadata.getColumnCount()); + Assertions.assertEquals(29, metadata.getColumnCount()); for (int index = 0; index < metadata.getColumnCount(); index++) { int column = index + 1; diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementImplTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementImplTest.java index 7bd65b7..78ec5f6 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementImplTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementImplTest.java @@ -136,7 +136,9 @@ public void executeWithoutBatch(SqlQueries.YqlQuery mode) throws SQLException { .nextRow(3, "value-3") .noNextRows(); } - }; + } + + ; @ParameterizedTest(name = "with {0}") @EnumSource(SqlQueries.YqlQuery.class) @@ -183,7 +185,7 @@ public void addBatch(SqlQueries.YqlQuery mode) throws SQLException { statement.setInt("key", 3); statement.setString("c_Text", "value-3"); - Assertions.assertArrayEquals(new int[]{ Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO }, + Assertions.assertArrayEquals(new int[]{Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO}, statement.executeBatch()); // does nothing @@ -426,6 +428,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", Types.DECIMAL); ps.setNull("c_BigDecimal", Types.DECIMAL); ps.setNull("c_BankDecimal", Types.DECIMAL); + ps.setNull("c_Date32", Types.DATE); + ps.setNull("c_Datetime64", Types.TIMESTAMP); + ps.setNull("c_Timestamp64", Types.TIMESTAMP); + ps.setNull("c_Interval64", Types.JAVA_OBJECT); ps.executeUpdate(); } @@ -456,6 +462,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", -1, "Decimal(22, 9)"); ps.setNull("c_BigDecimal", -1, "Decimal(35, 0)"); ps.setNull("c_BankDecimal", -1, "Decimal(31, 9)"); + ps.setNull("c_Date32", -1, "Date32"); + ps.setNull("c_Datetime64", -1, "Datetime64"); + ps.setNull("c_Timestamp64", -1, "Timestamp64"); + ps.setNull("c_Interval64", -1, "Interval64"); ps.executeUpdate(); } @@ -486,6 +496,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", -1); ps.setNull("c_BigDecimal", -1); ps.setNull("c_BankDecimal", -1); + ps.setNull("c_Date32", -1); + ps.setNull("c_Datetime64", -1); + ps.setNull("c_Timestamp64", -1); + ps.setNull("c_Interval64", -1); ps.executeUpdate(); } @@ -497,7 +511,7 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { Assertions.assertTrue(rs.next()); ResultSetMetaData metaData = rs.getMetaData(); - Assertions.assertEquals(25, metaData.getColumnCount()); + Assertions.assertEquals(29, metaData.getColumnCount()); Assertions.assertEquals(key, rs.getInt("key")); // key for (int i = 2; i <= metaData.getColumnCount(); i++) { @@ -521,7 +535,7 @@ public void testParametersMeta(SqlQueries.YqlQuery mode) throws SQLException { () -> meta.getParameterType(335) ); - Assertions.assertEquals(25, meta.getParameterCount()); + Assertions.assertEquals(29, meta.getParameterCount()); for (int param = 1; param <= meta.getParameterCount(); param++) { String name = ydbMeta.getParameterName(param); boolean isKey = "key".equals(name); @@ -600,15 +614,19 @@ public void testParametersMeta(SqlQueries.YqlQuery mode) throws SQLException { expectClassName = UUID.class.getName(); break; case "c_Date": + case "c_Date32": expectClassName = LocalDate.class.getName(); break; case "c_Datetime": + case "c_Datetime64": expectClassName = LocalDateTime.class.getName(); break; case "c_Timestamp": + case "c_Timestamp64": expectClassName = Instant.class.getName(); break; case "c_Interval": + case "c_Interval64": expectClassName = Duration.class.getName(); break; case "c_Decimal": diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementTest.java index eff26af..3614b18 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbPreparedStatementTest.java @@ -45,7 +45,6 @@ import tech.ydb.test.junit5.YdbHelperExtension; /** - * * @author Aleksandr Gorshenin */ public class YdbPreparedStatementTest { @@ -158,7 +157,7 @@ public void executeWithMissingParameter() throws SQLException { } @ParameterizedTest(name = "with {0}") - @EnumSource(value=SqlQueries.JdbcQuery.class, names = { "BATCHED", "TYPED" }) + @EnumSource(value = SqlQueries.JdbcQuery.class, names = {"BATCHED", "TYPED"}) public void executeWithWrongType(SqlQueries.JdbcQuery query) throws SQLException { String sql = TEST_TABLE.upsertOne(query, "c_Text", "Text"); @@ -171,7 +170,7 @@ public void executeWithWrongType(SqlQueries.JdbcQuery query) throws SQLException } @ParameterizedTest(name = "with {0}") - @ValueSource(strings = { "c_NotText" , "C_TEXT", "c_text" }) + @ValueSource(strings = {"c_NotText", "C_TEXT", "c_text"}) public void executeWithWrongColumnName(String columnName) throws SQLException { String errorMessage = "No such column: " + columnName; @@ -197,10 +196,10 @@ public void executeWithWrongColumnName(String columnName) throws SQLException { ExceptionAssert.ydbException(errorMessage, () -> jdbc.connection().prepareStatement(batched)); ExceptionAssert.sqlException("Cannot parse BULK upsert: column " + columnName + " not found", () -> jdbc.connection().prepareStatement(bulk)); - }; + } @ParameterizedTest(name = "with {0}") - @ValueSource(strings = { "unknown_table"/*, "YDB_PREPARED_TEST", "ydD_prepared_test"*/ }) + @ValueSource(strings = {"unknown_table"/*, "YDB_PREPARED_TEST", "ydD_prepared_test"*/}) public void executeWithWrongTableName(String tableName) throws SQLException { String errorMessage = "Cannot find table 'db.[" + jdbc.database() + "/" + tableName + "]"; SqlQueries queries = new SqlQueries(tableName); @@ -227,7 +226,7 @@ public void executeWithWrongTableName(String tableName) throws SQLException { ExceptionAssert.ydbException(errorMessage, () -> jdbc.connection().prepareStatement(batched)); ExceptionAssert.sqlException("Cannot parse BULK upsert: Status{code = SCHEME_ERROR(code=400070)}", () -> jdbc.connection().prepareStatement(bulk)); - }; + } @ParameterizedTest(name = "with {0}") @EnumSource(SqlQueries.JdbcQuery.class) @@ -251,7 +250,7 @@ public void simpleUpsertTest(SqlQueries.JdbcQuery query) throws SQLException { .nextRow(2, "value-2") .noNextRows(); } - }; + } @ParameterizedTest(name = "with {0}") @EnumSource(SqlQueries.JdbcQuery.class) @@ -300,7 +299,7 @@ public void batchUpsertTest(SqlQueries.JdbcQuery query) throws SQLException { .nextRow(6, "value-6") .noNextRows(); } - }; + } private int ydbType(PrimitiveType type) { return YdbConst.SQL_KIND_PRIMITIVE + type.ordinal(); @@ -315,14 +314,14 @@ private void fillRowValues(PreparedStatement statement, int id, boolean castingS statement.setBoolean(2, id % 2 == 0); // c_Bool - statement.setByte(3, (byte)(id + 1)); // c_Int8 - statement.setShort(4, (short)(id + 2)); // c_Int16 + statement.setByte(3, (byte) (id + 1)); // c_Int8 + statement.setShort(4, (short) (id + 2)); // c_Int16 statement.setInt(5, id + 3); // c_Int32 statement.setLong(6, id + 4); // c_Int64 if (castingSupported) { - statement.setByte(7, (byte)(id + 5)); // c_Uint8 - statement.setShort(8, (short)(id + 6)); // c_Uint16 + statement.setByte(7, (byte) (id + 5)); // c_Uint8 + statement.setShort(8, (short) (id + 6)); // c_Uint16 statement.setInt(9, id + 7); // c_Uint32 statement.setLong(10, id + 8); // c_Uint64 } else { @@ -345,16 +344,17 @@ private void fillRowValues(PreparedStatement statement, int id, boolean castingS statement.setString(17, "{yson=" + id + "}"); // c_Yson statement.setString(18, uuid.toString()); // c_Uuid } else { - statement.setObject(15, "{\"json\": " + id + "}", ydbType(PrimitiveType.Json)); // c_Json + statement.setObject(15, "{\"json\": " + id + "}", ydbType(PrimitiveType.Json)); // c_Json statement.setObject(16, "{\"jsonDoc\": " + id + "}", ydbType(PrimitiveType.JsonDocument)); // c_JsonDocument - statement.setObject(17, "{yson=" + id + "}", ydbType(PrimitiveType.Yson)); // c_Yson - statement.setObject(18, uuid, ydbType(PrimitiveType.Uuid)); // c_Uuid + statement.setObject(17, "{yson=" + id + "}", ydbType(PrimitiveType.Yson)); // c_Yson + statement.setObject(18, uuid, ydbType(PrimitiveType.Uuid)); // c_Uuid } Date sqlDate = new Date(TEST_TS.toEpochMilli()); LocalDateTime dateTime = LocalDateTime.ofInstant(TEST_TS, ZoneOffset.UTC).plusMinutes(id); Timestamp timestamp = Timestamp.from(TEST_TS.plusSeconds(id)); Duration duration = Duration.ofMinutes(id); + Duration negativeDuration = Duration.ofMinutes(-id); statement.setDate(19, sqlDate); // c_Date statement.setObject(20, dateTime); // c_Datetime @@ -365,9 +365,19 @@ private void fillRowValues(PreparedStatement statement, int id, boolean castingS if (castingSupported) { statement.setBigDecimal(24, BigDecimal.valueOf(20000 + id, 0)); // c_BigDecimal statement.setBigDecimal(25, BigDecimal.valueOf(30000 + id, 6)); // c_BankDecimal + + statement.setDate(26, sqlDate); // c_Date32 + statement.setObject(27, dateTime); // c_Datetime64 + statement.setTimestamp(28, timestamp); // c_Timestamp64 + statement.setObject(29, negativeDuration); // c_Interval64 } else { statement.setObject(24, BigDecimal.valueOf(20000 + id, 0), ydbType(DecimalType.of(35, 0))); // c_BigDecimal statement.setObject(25, BigDecimal.valueOf(30000 + id, 6), ydbType(DecimalType.of(31, 9))); // c_BankDecimal + + statement.setObject(26, sqlDate, ydbType(PrimitiveType.Date32)); // c_Date32 + statement.setObject(27, dateTime, ydbType(PrimitiveType.Datetime64)); // c_Datetime64 + statement.setObject(28, timestamp, ydbType(PrimitiveType.Timestamp64)); // c_Timestamp64 + statement.setObject(29, negativeDuration, ydbType(PrimitiveType.Interval64)); // c_Interval64 } } @@ -411,6 +421,11 @@ private void assertRowValues(ResultSet rs, int id) throws SQLException { Assertions.assertEquals(BigDecimal.valueOf(1000000l * (10000 + id), 9), rs.getBigDecimal("c_Decimal")); Assertions.assertEquals(BigDecimal.valueOf(20000 + id), rs.getBigDecimal("c_BigDecimal")); Assertions.assertEquals(BigDecimal.valueOf(1000l * (30000 + id), 9), rs.getBigDecimal("c_BankDecimal")); + + Assertions.assertEquals(sqlDate.toLocalDate(), rs.getDate("c_Date32").toLocalDate()); + Assertions.assertEquals(dateTime, rs.getObject("c_Datetime64")); + Assertions.assertEquals(timestamp, rs.getTimestamp("c_Timestamp64")); + Assertions.assertEquals(Duration.ofMinutes(-id), rs.getObject("c_Interval64")); } private void assertStructMember(Value value, StructValue sv, String name) { @@ -446,13 +461,13 @@ private void assertTableRow(ResultSet rs, int id) throws SQLException { Assertions.assertTrue(obj instanceof StructValue); StructValue sv = (StructValue) obj; - Assertions.assertEquals(25, sv.getType().getMembersCount()); + Assertions.assertEquals(29, sv.getType().getMembersCount()); assertStructMember(PrimitiveValue.newInt32(id), sv, "key"); assertStructMember(PrimitiveValue.newBool(id % 2 == 0), sv, "c_Bool"); - assertStructMember(PrimitiveValue.newInt8((byte)(id + 1)), sv, "c_Int8"); - assertStructMember(PrimitiveValue.newInt16((short)(id + 2)), sv, "c_Int16"); + assertStructMember(PrimitiveValue.newInt8((byte) (id + 1)), sv, "c_Int8"); + assertStructMember(PrimitiveValue.newInt16((short) (id + 2)), sv, "c_Int16"); assertStructMember(PrimitiveValue.newInt32(id + 3), sv, "c_Int32"); assertStructMember(PrimitiveValue.newInt64(id + 4), sv, "c_Int64"); @@ -527,7 +542,7 @@ public void batchUpsertAllTest(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } @Test public void setStringTest() throws SQLException { @@ -566,6 +581,12 @@ public void setStringTest() throws SQLException { statement.setString(23, BigDecimal.valueOf(10000 + id, 3).toString()); // c_Decimal statement.setString(24, BigDecimal.valueOf(20000 + id, 0).toString()); // c_BigDecimal statement.setString(25, BigDecimal.valueOf(30000 + id, 6).toString()); // c_BankDecimal + + statement.setString(26, sqlDate.toString()); // c_Date + statement.setString(27, dateTime.toString()); // c_Datetime + statement.setString(28, TEST_TS.plusSeconds(id).toString()); // c_Timestamp + statement.setString(29, Duration.ofMinutes(-id).toString()); // c_Interval + statement.execute(); } @@ -575,7 +596,7 @@ public void setStringTest() throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } @Test public void tableRowTest() throws SQLException { @@ -597,7 +618,7 @@ public void tableRowTest() throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertResultSetCount(ResultSet rs, int count) throws SQLException { Assertions.assertTrue(rs.next()); @@ -607,7 +628,7 @@ private void assertResultSetCount(ResultSet rs, int count) throws SQLException { } @ParameterizedTest - @ValueSource(strings = { "true", "false" }) + @ValueSource(strings = {"true", "false"}) public void inListTest(boolean convertInToList) throws SQLException { String option = String.valueOf(convertInToList); String arg2Name = convertInToList ? "$jp1[1]" : "$jp2"; @@ -850,7 +871,7 @@ public void int32Test(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextInt32(ResultSet rs, int key, Integer value) throws SQLException { Assertions.assertTrue(rs.next()); @@ -972,7 +993,7 @@ public void int64Test(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextInt64(ResultSet rs, int key, Long value) throws SQLException { Assertions.assertTrue(rs.next()); @@ -1082,7 +1103,7 @@ public void timestampTest(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextTimestamp(ResultSet rs, int key, Instant ts) throws SQLException { Assertions.assertTrue(rs.next()); @@ -1177,7 +1198,7 @@ public void datetimeTest(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextDatetime(ResultSet rs, int key, LocalDateTime ldt) throws SQLException { Assertions.assertTrue(rs.next()); @@ -1334,20 +1355,20 @@ public void decimalTest(SqlQueries.JdbcQuery query) throws SQLException { ps.setInt(1, 5); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(22, 9): " - + "[class java.math.BigDecimal: " + inf + "] is Infinite", + + "Cannot cast to decimal type Decimal(22, 9): " + + "[class java.math.BigDecimal: " + inf + "] is Infinite", () -> ps.setBigDecimal(2, inf) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(22, 9): " - + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", + + "Cannot cast to decimal type Decimal(22, 9): " + + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", () -> ps.setBigDecimal(2, negInf) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(22, 9): " - + "[class java.math.BigDecimal: " + nan + "] is NaN", + + "Cannot cast to decimal type Decimal(22, 9): " + + "[class java.math.BigDecimal: " + nan + "] is NaN", () -> ps.setBigDecimal(2, nan) ); } @@ -1362,7 +1383,7 @@ public void decimalTest(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextDecimal(ResultSet rs, int key, BigDecimal bg) throws SQLException { Assertions.assertTrue(rs.next()); @@ -1409,20 +1430,20 @@ public void bankDecimalTest(SqlQueries.JdbcQuery query) throws SQLException { ps.setInt(1, 5); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + inf + "] is Infinite", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + inf + "] is Infinite", () -> ps.setBigDecimal(2, inf) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", () -> ps.setBigDecimal(2, negInf) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + nan + "] is NaN", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + nan + "] is NaN", () -> ps.setBigDecimal(2, nan) ); } else { @@ -1445,20 +1466,20 @@ public void bankDecimalTest(SqlQueries.JdbcQuery query) throws SQLException { ps.setInt(1, 5); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + inf + "] is Infinite", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + inf + "] is Infinite", () -> ps.setObject(2, inf, sqlType) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + negInf + "] is -Infinite", () -> ps.setObject(2, negInf, sqlType) ); ExceptionAssert.sqlException("" - + "Cannot cast to decimal type Decimal(31, 9): " - + "[class java.math.BigDecimal: " + nan + "] is NaN", + + "Cannot cast to decimal type Decimal(31, 9): " + + "[class java.math.BigDecimal: " + nan + "] is NaN", () -> ps.setObject(2, nan, sqlType) ); } @@ -1474,7 +1495,7 @@ public void bankDecimalTest(SqlQueries.JdbcQuery query) throws SQLException { Assertions.assertFalse(rs.next()); } } - }; + } private void assertNextBankDecimal(ResultSet rs, int key, BigDecimal bg) throws SQLException { Assertions.assertTrue(rs.next()); diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbResultSetImplTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbResultSetImplTest.java index 4f10290..66a9336 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbResultSetImplTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbResultSetImplTest.java @@ -58,8 +58,6 @@ import tech.ydb.table.values.Value; import tech.ydb.test.junit5.YdbHelperExtension; - - public class YdbResultSetImplTest { @RegisterExtension private static final YdbHelperExtension ydb = new YdbHelperExtension(); @@ -120,7 +118,7 @@ public void resultSetType() throws SQLException { } @Test - public void close() throws SQLException { + public void close() throws SQLException { Assertions.assertFalse(resultSet.isClosed()); resultSet.close(); Assertions.assertTrue(resultSet.isClosed()); @@ -139,16 +137,16 @@ public void unwrap() throws SQLException { @Test public void invalidColumnsTest() { // invalid location - ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString(2)); - ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString("c_Text")); + ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString(2)); + ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString("c_Text")); // invalid case ExceptionAssert.sqlException("Column not found: c_text", () -> resultSet.getString("c_text")); - ExceptionAssert.sqlException("Column not found: C_TEXT", () -> resultSet.getString("C_TEXT")); - ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString("c_Text")); + ExceptionAssert.sqlException("Column not found: C_TEXT", () -> resultSet.getString("C_TEXT")); + ExceptionAssert.sqlException("Current row index is out of bounds: 0", () -> resultSet.getString("c_Text")); // invalid name - ExceptionAssert.sqlException("Column not found: value0", () -> resultSet.getString("value0")); + ExceptionAssert.sqlException("Column not found: value0", () -> resultSet.getString("value0")); } @Test @@ -181,7 +179,7 @@ public void getMetaData() throws SQLException { ExceptionAssert.sqlException("Column is out of range: 995", () -> metadata.getColumnName(995)); - Assertions.assertEquals(25, metadata.getColumnCount()); + Assertions.assertEquals(29, metadata.getColumnCount()); for (int index = 0; index < metadata.getColumnCount(); index++) { int column = index + 1; @@ -619,8 +617,8 @@ public void cursorUpdatesIsNotSupportedTest() { assertCursorUpdates(() -> resultSet.updateString("value", "value")); // updateBytes - assertCursorUpdates(() -> resultSet.updateBytes(1, new byte[] { })); - assertCursorUpdates(() -> resultSet.updateBytes("value", new byte[] { })); + assertCursorUpdates(() -> resultSet.updateBytes(1, new byte[]{})); + assertCursorUpdates(() -> resultSet.updateBytes("value", new byte[]{})); // updateDate assertCursorUpdates(() -> resultSet.updateDate(1, new Date(0))); @@ -748,7 +746,11 @@ public void getString() throws SQLException { .value(22, "c_Interval", "PT3.111113S") .value(23, "c_Decimal", "3.335000000") .value(24, "c_BigDecimal", "12345678901234567890123456789012345") - .value(25, "c_BankDecimal", "9999999999999999999999.999999999"); + .value(25, "c_BankDecimal", "9999999999999999999999.999999999") + .value(26, "c_Date32", "1961-06-26") + .value(27, "c_Datetime64", "1960-02-22T04:14:04") + .value(28, "c_Timestamp64", "1969-12-28T09:34:48.776658Z") + .value(29, "c_Interval64", "PT-3.111113S"); checker.nextRow() .value(1, "key", "2") @@ -775,7 +777,11 @@ public void getString() throws SQLException { .value(22, "c_Interval", "PT3.112113S") .value(23, "c_Decimal", "-3.335000000") .value(24, "c_BigDecimal", "-98765432109876543210987654321098765") - .value(25, "c_BankDecimal", "-9999999999999999999999.999999999"); + .value(25, "c_BankDecimal", "-9999999999999999999999.999999999") + .value(26, "c_Date32", "1978-07-10") + .value(27, "c_Datetime64", "1976-09-10T13:45") + .value(28, "c_Timestamp64", "1970-01-02T06:51:51.223342Z") + .value(29, "c_Interval64", "PT3.112113S"); checker.nextRow() .value(1, "key", "3") @@ -802,7 +808,11 @@ public void getString() throws SQLException { .value(22, "c_Interval", "PT0S") .value(23, "c_Decimal", "0") // Zero always converts without scale .value(24, "c_BigDecimal", "0") // Zero always converts without scale - .value(25, "c_BankDecimal", "0"); // Zero always converts without scale + .value(25, "c_BankDecimal", "0") // Zero always converts without scale + .value(26, "c_Date32", "1970-01-01") + .value(27, "c_Datetime64", "1970-01-01T00:00") + .value(28, "c_Timestamp64", "1970-01-01T00:00:00Z") + .value(29, "c_Interval64", "PT0S"); checker.nextRow() .value(1, "key", "4") @@ -829,7 +839,11 @@ public void getString() throws SQLException { .value(22, "c_Interval", "PT0.000001S") .value(23, "c_Decimal", "1.000000000") .value(24, "c_BigDecimal", "1") - .value(25, "c_BankDecimal", "1.000000000"); + .value(25, "c_BankDecimal", "1.000000000") + .value(26, "c_Date", "1970-01-02") + .value(27, "c_Datetime", "1970-01-01T00:00:01") + .value(28, "c_Timestamp", "1970-01-01T00:00:00.000001Z") + .value(29, "c_Interval", "PT0.000001S"); checker.nextRow() .value(1, "key", "5") @@ -856,7 +870,11 @@ public void getString() throws SQLException { .value(22, "c_Interval", null) .value(23, "c_Decimal", null) .value(24, "c_BigDecimal", null) - .value(25, "c_BankDecimal", null); + .value(25, "c_BankDecimal", null) + .value(26, "c_Date", null) + .value(27, "c_Datetime", null) + .value(28, "c_Timestamp", null) + .value(29, "c_Interval", null); checker.assertNoRows(); } @@ -918,13 +936,13 @@ public void getByte() throws SQLException { ResultSetChecker checker = check(resultSet, ResultSet::getByte, ResultSet::getByte); checker.nextRow() - .value(1, "key", (byte)1) - .value(2, "c_Bool", (byte)1) - .value(3, "c_Int8", (byte)101) + .value(1, "key", (byte) 1) + .value(2, "c_Bool", (byte) 1) + .value(3, "c_Int8", (byte) 101) .exceptionValue(4, "c_Int16", "Cannot cast [Int16] with value [20001] to [byte]") .exceptionValue(5, "c_Int32", "Cannot cast [Int32] with value [2000000001] to [byte]") .exceptionValue(6, "c_Int64", "Cannot cast [Int64] with value [2000000000001] to [byte]") - .value(7, "c_Uint8", (byte)100) + .value(7, "c_Uint8", (byte) 100) .exceptionValue(8, "c_Uint16", "Cannot cast [Uint16] with value [20002] to [byte]") .exceptionValue(9, "c_Uint32", "Cannot cast [Uint32] with value [2000000002] to [byte]") .exceptionValue(10, "c_Uint64", "Cannot cast [Uint64] with value [2000000000002] to [byte]") @@ -933,9 +951,9 @@ public void getByte() throws SQLException { .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [byte]"); checker.nextRow() - .value(1, "key", (byte)2) - .value(2, "c_Bool", (byte)0) - .value(3, "c_Int8", (byte)(-101)) + .value(1, "key", (byte) 2) + .value(2, "c_Bool", (byte) 0) + .value(3, "c_Int8", (byte) (-101)) .exceptionValue(4, "c_Int16", "Cannot cast [Int16] with value [-20001] to [byte]") .exceptionValue(5, "c_Int32", "Cannot cast [Int32] with value [-2000000001] to [byte]") .exceptionValue(6, "c_Int64", "Cannot cast [Int64] with value [-2000000000001] to [byte]") @@ -948,61 +966,65 @@ public void getByte() throws SQLException { .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [byte]"); checker.nextRow() - .value(1, "key", (byte)3) - .value(2, "c_Bool", (byte)0) - .value(3, "c_Int8", (byte)0) - .value(4, "c_Int16", (byte)0) - .value(5, "c_Int32", (byte)0) - .value(6, "c_Int64", (byte)0) - .value(7, "c_Uint8", (byte)0) - .value(8, "c_Uint16", (byte)0) - .value(9, "c_Uint32", (byte)0) - .value(10, "c_Uint64", (byte)0) + .value(1, "key", (byte) 3) + .value(2, "c_Bool", (byte) 0) + .value(3, "c_Int8", (byte) 0) + .value(4, "c_Int16", (byte) 0) + .value(5, "c_Int32", (byte) 0) + .value(6, "c_Int64", (byte) 0) + .value(7, "c_Uint8", (byte) 0) + .value(8, "c_Uint16", (byte) 0) + .value(9, "c_Uint32", (byte) 0) + .value(10, "c_Uint64", (byte) 0) .exceptionValue(23, "c_Decimal", "Cannot cast [DECIMAL] to [byte]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [DECIMAL] to [byte]") .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [byte]"); checker.nextRow() - .value(1, "key", (byte)4) - .value(2, "c_Bool", (byte)1) - .value(3, "c_Int8", (byte)1) - .value(4, "c_Int16", (byte)1) - .value(5, "c_Int32", (byte)1) - .value(6, "c_Int64", (byte)1) - .value(7, "c_Uint8", (byte)1) - .value(8, "c_Uint16", (byte)1) - .value(9, "c_Uint32", (byte)1) - .value(10, "c_Uint64", (byte)1) + .value(1, "key", (byte) 4) + .value(2, "c_Bool", (byte) 1) + .value(3, "c_Int8", (byte) 1) + .value(4, "c_Int16", (byte) 1) + .value(5, "c_Int32", (byte) 1) + .value(6, "c_Int64", (byte) 1) + .value(7, "c_Uint8", (byte) 1) + .value(8, "c_Uint16", (byte) 1) + .value(9, "c_Uint32", (byte) 1) + .value(10, "c_Uint64", (byte) 1) .exceptionValue(23, "c_Decimal", "Cannot cast [DECIMAL] to [byte]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [DECIMAL] to [byte]") .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [byte]"); checker.nextRow() - .value(1, "key", (byte)5) - .nullValue(2, "c_Bool", (byte)0) - .nullValue(3, "c_Int8", (byte)0) - .nullValue(4, "c_Int16", (byte)0) - .nullValue(5, "c_Int32", (byte)0) - .nullValue(6, "c_Int64", (byte)0) - .nullValue(7, "c_Uint8", (byte)0) - .nullValue(8, "c_Uint16", (byte)0) - .nullValue(9, "c_Uint32", (byte)0) - .nullValue(10, "c_Uint64", (byte)0) - .nullValue(11, "c_Float", (byte)0) - .nullValue(12, "c_Double", (byte)0) - .nullValue(13, "c_Bytes", (byte)0) - .nullValue(14, "c_Text", (byte)0) - .nullValue(15, "c_Json", (byte)0) - .nullValue(16, "c_JsonDocument", (byte)0) - .nullValue(17, "c_Yson", (byte)0) - .nullValue(18, "c_Uuid", (byte)0) - .nullValue(19, "c_Date", (byte)0) - .nullValue(20, "c_Datetime", (byte)0) - .nullValue(21, "c_Timestamp", (byte)0) - .nullValue(22, "c_Interval", (byte)0) - .nullValue(23, "c_Decimal", (byte)0) - .nullValue(24, "c_BigDecimal", (byte)0) - .nullValue(25, "c_BankDecimal", (byte)0); + .value(1, "key", (byte) 5) + .nullValue(2, "c_Bool", (byte) 0) + .nullValue(3, "c_Int8", (byte) 0) + .nullValue(4, "c_Int16", (byte) 0) + .nullValue(5, "c_Int32", (byte) 0) + .nullValue(6, "c_Int64", (byte) 0) + .nullValue(7, "c_Uint8", (byte) 0) + .nullValue(8, "c_Uint16", (byte) 0) + .nullValue(9, "c_Uint32", (byte) 0) + .nullValue(10, "c_Uint64", (byte) 0) + .nullValue(11, "c_Float", (byte) 0) + .nullValue(12, "c_Double", (byte) 0) + .nullValue(13, "c_Bytes", (byte) 0) + .nullValue(14, "c_Text", (byte) 0) + .nullValue(15, "c_Json", (byte) 0) + .nullValue(16, "c_JsonDocument", (byte) 0) + .nullValue(17, "c_Yson", (byte) 0) + .nullValue(18, "c_Uuid", (byte) 0) + .nullValue(19, "c_Date", (byte) 0) + .nullValue(20, "c_Datetime", (byte) 0) + .nullValue(21, "c_Timestamp", (byte) 0) + .nullValue(22, "c_Interval", (byte) 0) + .nullValue(23, "c_Decimal", (byte) 0) + .nullValue(24, "c_BigDecimal", (byte) 0) + .nullValue(25, "c_BankDecimal", (byte) 0) + .nullValue(26, "c_Date32", (byte) 0) + .nullValue(27, "c_Datetime64", (byte) 0) + .nullValue(28, "c_Timestamp64", (byte) 0) + .nullValue(29, "c_Interval64", (byte) 0); checker.assertNoRows(); } @@ -1012,14 +1034,14 @@ public void getShort() throws SQLException { ResultSetChecker checker = check(resultSet, ResultSet::getShort, ResultSet::getShort); checker.nextRow() - .value(1, "key", (short)1) - .value(2, "c_Bool", (short)1) - .value(3, "c_Int8", (short)101) - .value(4, "c_Int16", (short)20001) + .value(1, "key", (short) 1) + .value(2, "c_Bool", (short) 1) + .value(3, "c_Int8", (short) 101) + .value(4, "c_Int16", (short) 20001) .exceptionValue(5, "c_Int32", "Cannot cast [Int32] with value [2000000001] to [short]") .exceptionValue(6, "c_Int64", "Cannot cast [Int64] with value [2000000000001] to [short]") - .value(7, "c_Uint8", (short)100) - .value(8, "c_Uint16", (short)20002) + .value(7, "c_Uint8", (short) 100) + .value(8, "c_Uint16", (short) 20002) .exceptionValue(9, "c_Uint32", "Cannot cast [Uint32] with value [2000000002] to [short]") .exceptionValue(10, "c_Uint64", "Cannot cast [Uint64] with value [2000000000002] to [short]") .exceptionValue(23, "c_Decimal", "Cannot cast [DECIMAL] to [short]") @@ -1027,13 +1049,13 @@ public void getShort() throws SQLException { .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [short]"); checker.nextRow() - .value(1, "key", (short)2) - .value(2, "c_Bool", (short)0) - .value(3, "c_Int8", (short)(-101)) - .value(4, "c_Int16", (short)-20001) + .value(1, "key", (short) 2) + .value(2, "c_Bool", (short) 0) + .value(3, "c_Int8", (short) (-101)) + .value(4, "c_Int16", (short) -20001) .exceptionValue(5, "c_Int32", "Cannot cast [Int32] with value [-2000000001] to [short]") .exceptionValue(6, "c_Int64", "Cannot cast [Int64] with value [-2000000000001] to [short]") - .value(7, "c_Uint8", (short)200) + .value(7, "c_Uint8", (short) 200) .exceptionValue(8, "c_Uint16", "Cannot cast [Uint16] with value [40002] to [short]") .exceptionValue(9, "c_Uint32", "Cannot cast [Uint32] with value [4000000002] to [short]") .exceptionValue(10, "c_Uint64", "Cannot cast [Uint64] with value [4000000000002] to [short]") @@ -1043,61 +1065,65 @@ public void getShort() throws SQLException { checker.nextRow() - .value(1, "key", (short)3) - .value(2, "c_Bool", (short)0) - .value(3, "c_Int8", (short)0) - .value(4, "c_Int16", (short)0) - .value(5, "c_Int32", (short)0) - .value(6, "c_Int64", (short)0) - .value(7, "c_Uint8", (short)0) - .value(8, "c_Uint16", (short)0) - .value(9, "c_Uint32", (short)0) - .value(10, "c_Uint64", (short)0) + .value(1, "key", (short) 3) + .value(2, "c_Bool", (short) 0) + .value(3, "c_Int8", (short) 0) + .value(4, "c_Int16", (short) 0) + .value(5, "c_Int32", (short) 0) + .value(6, "c_Int64", (short) 0) + .value(7, "c_Uint8", (short) 0) + .value(8, "c_Uint16", (short) 0) + .value(9, "c_Uint32", (short) 0) + .value(10, "c_Uint64", (short) 0) .exceptionValue(23, "c_Decimal", "Cannot cast [DECIMAL] to [short]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [DECIMAL] to [short]") .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [short]"); checker.nextRow() - .value(1, "key", (short)4) - .value(2, "c_Bool", (short)1) - .value(3, "c_Int8", (short)1) - .value(4, "c_Int16", (short)1) - .value(5, "c_Int32", (short)1) - .value(6, "c_Int64", (short)1) - .value(7, "c_Uint8", (short)1) - .value(8, "c_Uint16", (short)1) - .value(9, "c_Uint32", (short)1) - .value(10, "c_Uint64", (short)1) + .value(1, "key", (short) 4) + .value(2, "c_Bool", (short) 1) + .value(3, "c_Int8", (short) 1) + .value(4, "c_Int16", (short) 1) + .value(5, "c_Int32", (short) 1) + .value(6, "c_Int64", (short) 1) + .value(7, "c_Uint8", (short) 1) + .value(8, "c_Uint16", (short) 1) + .value(9, "c_Uint32", (short) 1) + .value(10, "c_Uint64", (short) 1) .exceptionValue(23, "c_Decimal", "Cannot cast [DECIMAL] to [short]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [DECIMAL] to [short]") .exceptionValue(25, "c_BankDecimal", "Cannot cast [DECIMAL] to [short]"); checker.nextRow() - .value(1, "key", (short)5) - .nullValue(2, "c_Bool", (short)0) - .nullValue(3, "c_Int8", (short)0) - .nullValue(4, "c_Int16", (short)0) - .nullValue(5, "c_Int32", (short)0) - .nullValue(6, "c_Int64", (short)0) - .nullValue(7, "c_Uint8", (short)0) - .nullValue(8, "c_Uint16", (short)0) - .nullValue(9, "c_Uint32", (short)0) - .nullValue(10, "c_Uint64", (short)0) - .nullValue(11, "c_Float", (short)0) - .nullValue(12, "c_Double", (short)0) - .nullValue(13, "c_Bytes", (short)0) - .nullValue(14, "c_Text", (short)0) - .nullValue(15, "c_Json", (short)0) - .nullValue(16, "c_JsonDocument", (short)0) - .nullValue(17, "c_Yson", (short)0) - .nullValue(18, "c_Uuid", (short)0) - .nullValue(19, "c_Date", (short)0) - .nullValue(20, "c_Datetime", (short)0) - .nullValue(21, "c_Timestamp", (short)0) - .nullValue(22, "c_Interval", (short)0) - .nullValue(23, "c_Decimal", (short)0) - .nullValue(24, "c_BigDecimal", (short)0) - .nullValue(25, "c_BankDecimal", (short)0); + .value(1, "key", (short) 5) + .nullValue(2, "c_Bool", (short) 0) + .nullValue(3, "c_Int8", (short) 0) + .nullValue(4, "c_Int16", (short) 0) + .nullValue(5, "c_Int32", (short) 0) + .nullValue(6, "c_Int64", (short) 0) + .nullValue(7, "c_Uint8", (short) 0) + .nullValue(8, "c_Uint16", (short) 0) + .nullValue(9, "c_Uint32", (short) 0) + .nullValue(10, "c_Uint64", (short) 0) + .nullValue(11, "c_Float", (short) 0) + .nullValue(12, "c_Double", (short) 0) + .nullValue(13, "c_Bytes", (short) 0) + .nullValue(14, "c_Text", (short) 0) + .nullValue(15, "c_Json", (short) 0) + .nullValue(16, "c_JsonDocument", (short) 0) + .nullValue(17, "c_Yson", (short) 0) + .nullValue(18, "c_Uuid", (short) 0) + .nullValue(19, "c_Date", (short) 0) + .nullValue(20, "c_Datetime", (short) 0) + .nullValue(21, "c_Timestamp", (short) 0) + .nullValue(22, "c_Interval", (short) 0) + .nullValue(23, "c_Decimal", (short) 0) + .nullValue(24, "c_BigDecimal", (short) 0) + .nullValue(25, "c_BankDecimal", (short) 0) + .nullValue(26, "c_Date32", (short) 0) + .nullValue(27, "c_Datetime64", (short) 0) + .nullValue(28, "c_Timestamp64", (short) 0) + .nullValue(29, "c_Interval64", (short) 0); checker.assertNoRows(); } @@ -1131,7 +1157,11 @@ public void getInt() throws SQLException { .exceptionValue(22, "c_Interval", "Cannot cast [Interval] to [int]") .exceptionValue(23, "c_Decimal", "Cannot cast [Decimal(22, 9)] with value [3.335000000] to [int]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [Decimal(35, 0)] with value [12345678901234567890123456789012345] to [int]") - .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [9999999999999999999999.999999999] to [int]"); + .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [9999999999999999999999.999999999] to [int]") + .value(26, "c_Date32", -3111) + .exceptionValue(27, "c_Datetime64", "Cannot cast [Datetime64] to [int]") + .exceptionValue(28, "c_Timestamp64", "Cannot cast [Timestamp64] to [int]") + .exceptionValue(29, "c_Interval64", "Cannot cast [Interval64] to [int]"); checker.nextRow() .value(1, "key", 2) @@ -1158,7 +1188,11 @@ public void getInt() throws SQLException { .exceptionValue(22, "c_Interval", "Cannot cast [Interval] to [int]") .exceptionValue(23, "c_Decimal", "Cannot cast [Decimal(22, 9)] with value [-3.335000000] to [int]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [Decimal(35, 0)] with value [-98765432109876543210987654321098765] to [int]") - .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [-9999999999999999999999.999999999] to [int]"); + .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [-9999999999999999999999.999999999] to [int]") + .value(26, "c_Date32", 3112) + .exceptionValue(27, "c_Datetime64", "Cannot cast [Datetime64] to [int]") + .exceptionValue(28, "c_Timestamp64", "Cannot cast [Timestamp64] to [int]") + .exceptionValue(29, "c_Interval64", "Cannot cast [Interval64] to [int]"); checker.nextRow() @@ -1186,7 +1220,11 @@ public void getInt() throws SQLException { .exceptionValue(22, "c_Interval", "Cannot cast [Interval] to [int]") .value(23, "c_Decimal", 0) .value(24, "c_BigDecimal", 0) - .value(25, "c_BankDecimal", 0); + .value(25, "c_BankDecimal", 0) + .value(26, "c_Date32", 0) + .exceptionValue(27, "c_Datetime64", "Cannot cast [Datetime64] to [int]") + .exceptionValue(28, "c_Timestamp64", "Cannot cast [Timestamp64] to [int]") + .exceptionValue(29, "c_Interval64", "Cannot cast [Interval64] to [int]"); checker.nextRow() .value(1, "key", 4) @@ -1213,7 +1251,11 @@ public void getInt() throws SQLException { .exceptionValue(22, "c_Interval", "Cannot cast [Interval] to [int]") .value(23, "c_Decimal", 1) .value(24, "c_BigDecimal", 1) - .value(25, "c_BankDecimal", 1); + .value(25, "c_BankDecimal", 1) + .value(26, "c_Date32", 1) + .exceptionValue(27, "c_Datetime64", "Cannot cast [Datetime64] to [int]") + .exceptionValue(28, "c_Timestamp64", "Cannot cast [Timestamp64] to [int]") + .exceptionValue(29, "c_Interval64", "Cannot cast [Interval64] to [int]"); checker.nextRow() .value(1, "key", 5) @@ -1240,7 +1282,11 @@ public void getInt() throws SQLException { .nullValue(22, "c_Interval", 0) .nullValue(23, "c_Decimal", 0) .nullValue(24, "c_BigDecimal", 0) - .nullValue(25, "c_BankDecimal", 0); + .nullValue(25, "c_BankDecimal", 0) + .nullValue(26, "c_Date32", 0) + .nullValue(27, "c_Datetime64", 0) + .nullValue(28, "c_Timestamp64", 0) + .nullValue(29, "c_Interval64", 0); checker.assertNoRows(); } @@ -1274,7 +1320,11 @@ public void getLong() throws SQLException { .value(22, "c_Interval", 3111113L) .exceptionValue(23, "c_Decimal", "Cannot cast [Decimal(22, 9)] with value [3.335000000] to [long]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [Decimal(35, 0)] with value [12345678901234567890123456789012345] to [long]") - .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [9999999999999999999999.999999999] to [long]"); + .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [9999999999999999999999.999999999] to [long]") + .value(26, "c_Date32", -3111l) + .value(27, "c_Datetime64", -311111156L) + .value(28, "c_Timestamp64", -311111224342L / 1000) + .value(29, "c_Interval64", -3111113L); checker.nextRow() .value(1, "key", 2L) @@ -1301,7 +1351,11 @@ public void getLong() throws SQLException { .value(22, "c_Interval", 3112113L) .exceptionValue(23, "c_Decimal", "Cannot cast [Decimal(22, 9)] with value [-3.335000000] to [long]") .exceptionValue(24, "c_BigDecimal", "Cannot cast [Decimal(35, 0)] with value [-98765432109876543210987654321098765] to [long]") - .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [-9999999999999999999999.999999999] to [long]"); + .exceptionValue(25, "c_BankDecimal", "Cannot cast [Decimal(31, 9)] with value [-9999999999999999999999.999999999] to [long]") + .value(26, "c_Date32", 3112l) + .value(27, "c_Datetime64", 211211100L) + .value(28, "c_Timestamp64", 111111223342L / 1000) + .value(29, "c_Interval64", 3112113L); checker.nextRow() .value(1, "key", 3l) @@ -1328,7 +1382,11 @@ public void getLong() throws SQLException { .value(22, "c_Interval", 0l) .value(23, "c_Decimal", 0l) .value(24, "c_BigDecimal", 0l) - .value(25, "c_BankDecimal", 0l); + .value(25, "c_BankDecimal", 0l) + .value(26, "c_Date32", 0l) + .value(27, "c_Datetime64", 0l) + .value(28, "c_Timestamp64", 0l) + .value(29, "c_Interval64", 0l); checker.nextRow() .value(1, "key", 4L) @@ -1355,7 +1413,11 @@ public void getLong() throws SQLException { .value(22, "c_Interval", 1l) .value(23, "c_Decimal", 1l) .value(24, "c_BigDecimal", 1l) - .value(25, "c_BankDecimal", 1l); + .value(25, "c_BankDecimal", 1l) + .value(26, "c_Date32", 1l) + .value(27, "c_Datetime64", 1l) + .value(28, "c_Timestamp64", 1l / 1000) + .value(29, "c_Interval64", 1l); checker.nextRow() .value(1, "key", 5L) @@ -1382,7 +1444,11 @@ public void getLong() throws SQLException { .nullValue(22, "c_Interval", 0l) .nullValue(23, "c_Decimal", 0l) .nullValue(24, "c_BigDecimal", 0l) - .nullValue(25, "c_BankDecimal", 0l); + .nullValue(25, "c_BankDecimal", 0l) + .nullValue(26, "c_Date32", 0l) + .nullValue(27, "c_Datetime64", 0l) + .nullValue(28, "c_Timestamp64", 0l) + .nullValue(29, "c_Interval64", 0l); checker.assertNoRows(); } @@ -1725,11 +1791,17 @@ public void getDate() throws SQLException { .exceptionValue(10, "c_Uint64", "Cannot cast [Uint64] with value [2000000000002] to [class java.sql.Date]") // 3111 unix days = Sunday, July 9, 1978 0:00:00 UTC - .value(19, "c_Date", Date.valueOf(LocalDate.of(1978, Month.JULY, 9))) + .value(19, "c_Date", Date.valueOf(LocalDate.of(1978, Month.JULY, 9))) // 311111156 unix seconds = Sat Nov 10 1979 19:45:56 UTC - .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1979, Month.NOVEMBER, 10))) + .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1979, Month.NOVEMBER, 10))) // 311111223342 unix microseconds = Sun Jan 04 1970 14:25:11 UTC - .value(21, "c_Timestamp", new Date(311111223342l / 1000)); + .value(21, "c_Timestamp", new Date(311111223342L / 1000)) + // -3111 unix days + .value(26, "c_Date32", Date.valueOf(LocalDate.of(1961, Month.JUNE, 26))) + // -311111156 unix seconds + .value(27, "c_Datetime64", Date.valueOf(LocalDate.of(1960, Month.FEBRUARY, 22))) + // -311111223342 unix microseconds + .value(28, "c_Timestamp64", new Date(-311111224342L / 1000)); checker.nextRow() .value(3, "c_Int8", Date.valueOf(LocalDate.ofEpochDay(-101))) @@ -1742,11 +1814,14 @@ public void getDate() throws SQLException { .value(9, "c_Uint32", Date.valueOf(LocalDate.ofEpochDay(4000000002l))) .exceptionValue(10, "c_Uint64", "Cannot cast [Uint64] with value [4000000000002] to [class java.sql.Date]") - .value(19, "c_Date", Date.valueOf(LocalDate.of(1978, Month.JULY, 10))) + .value(19, "c_Date", Date.valueOf(LocalDate.of(1978, Month.JULY, 10))) // 211211100 unix seconds = Fri Sep 10 1976 13:45:00 UTC - .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1976, Month.SEPTEMBER, 10))) + .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1976, Month.SEPTEMBER, 10))) // 111111223342 unix microseconds = Fri Jan 02 1970 06:51:51 UTC - .value(21, "c_Timestamp", new Date(111111223342l / 1000)); + .value(21, "c_Timestamp", new Date(111111223342l / 1000)) + .value(26, "c_Date32", Date.valueOf(LocalDate.of(1978, Month.JULY, 10))) + .value(27, "c_Datetime64", Date.valueOf(LocalDate.of(1976, Month.SEPTEMBER, 10))) + .value(28, "c_Timestamp64", new Date(111111223342l / 1000)); checker.nextRow() .value(3, "c_Int8", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) @@ -1757,9 +1832,12 @@ public void getDate() throws SQLException { .value(8, "c_Uint16", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) .value(9, "c_Uint32", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) .value(10, "c_Uint64", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) - .value(19, "c_Date", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) - .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) - .value(21, "c_Timestamp", new Date(1 / 1000)); + .value(19, "c_Date", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(21, "c_Timestamp", new Date(1 / 1000)) + .value(26, "c_Date32", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(27, "c_Datetime64", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(28, "c_Timestamp64", new Date(1 / 1000)); checker.nextRow() .value(3, "c_Int8", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) @@ -1770,9 +1848,12 @@ public void getDate() throws SQLException { .value(8, "c_Uint16", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) .value(9, "c_Uint32", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) .value(10, "c_Uint64", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) - .value(19, "c_Date", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) - .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) - .value(21, "c_Timestamp", new Date(0)); + .value(19, "c_Date", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) + .value(20, "c_Datetime", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(21, "c_Timestamp", new Date(0)) + .value(26, "c_Date32", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 2))) + .value(27, "c_Datetime64", Date.valueOf(LocalDate.of(1970, Month.JANUARY, 1))) + .value(28, "c_Timestamp64", new Date(0)); checker.nextRow() .value(3, "c_Int8", null) @@ -1785,7 +1866,10 @@ public void getDate() throws SQLException { .value(10, "c_Uint64", null) .value(19, "c_Date", null) .value(20, "c_Datetime", null) - .value(21, "c_Timestamp", null); + .value(21, "c_Timestamp", null) + .value(26, "c_Date", null) + .value(27, "c_Datetime", null) + .value(28, "c_Timestamp", null); checker.assertNoRows(); } @@ -1808,7 +1892,13 @@ public void getTime() throws SQLException { // 311111156 unix seconds = Sat Nov 10 1979 19:45:56 UTC .value(20, "c_Datetime", Time.valueOf(LocalTime.of(19, 45, 56))) // 311111223342 unix microseconds = Sun Jan 04 1970 10:25:11 in UTC-04 - .value(21, "c_Timestamp", new Time(311111223342l / 1000)); + .value(21, "c_Timestamp", new Time(311111223342l / 1000)) + // Any value of Date doesn't have a time + .value(26, "c_Date32", Time.valueOf(LocalTime.MIN)) + // 311111156 unix seconds = Sat Nov 10 1979 19:45:56 UTC + .value(27, "c_Datetime64", Time.valueOf(LocalTime.of(4, 14, 4))) + // 311111223342 unix microseconds = Sun Jan 04 1970 10:25:11 in UTC-04 + .value(28, "c_Timestamp64", new Time(-311111224342l / 1000)); checker.nextRow() .exceptionValue(3, "c_Int8", "Cannot cast [Int8] with value [-101] to [class java.sql.Time]") @@ -1823,7 +1913,13 @@ public void getTime() throws SQLException { // 211211100 unix seconds = Fri Sep 10 1976 13:45:00 UTC .value(20, "c_Datetime", Time.valueOf(LocalTime.of(13, 45, 00))) // 111111223342 unix microseconds = Fri Jan 02 1970 06:51:51 in UTC-04 - .value(21, "c_Timestamp", new Time(111111223342l / 1000)); + .value(21, "c_Timestamp", new Time(111111223342l / 1000)) + // Any value of Date doesn't have a time + .value(26, "c_Date32", Time.valueOf(LocalTime.MIN)) + // 211211100 unix seconds = Fri Sep 10 1976 13:45:00 UTC + .value(27, "c_Datetime64", Time.valueOf(LocalTime.of(13, 45, 00))) + // 111111223342 unix microseconds = Fri Jan 02 1970 06:51:51 in UTC-04 + .value(28, "c_Timestamp64", new Time(111111223342l / 1000)); checker.nextRow() .value(3, "c_Int8", Time.valueOf(LocalTime.MIN)) @@ -1835,8 +1931,11 @@ public void getTime() throws SQLException { .value(9, "c_Uint32", Time.valueOf(LocalTime.MIN)) .value(10, "c_Uint64", Time.valueOf(LocalTime.MIN)) .value(19, "c_Date", Time.valueOf(LocalTime.MIN)) - .value(20, "c_Datetime", Time.valueOf(LocalTime.MIN)) - .value(21, "c_Timestamp", new Time(0)); + .value(20, "c_Datetime", Time.valueOf(LocalTime.MIN)) + .value(21, "c_Timestamp", new Time(0)) + .value(19, "c_Date32", Time.valueOf(LocalTime.MIN)) + .value(20, "c_Datetime64", Time.valueOf(LocalTime.MIN)) + .value(21, "c_Timestamp64", new Time(0)); checker.nextRow() .value(3, "c_Int8", Time.valueOf(LocalTime.ofSecondOfDay(1))) @@ -1848,8 +1947,11 @@ public void getTime() throws SQLException { .value(9, "c_Uint32", Time.valueOf(LocalTime.ofSecondOfDay(1))) .value(10, "c_Uint64", Time.valueOf(LocalTime.ofSecondOfDay(1))) .value(19, "c_Date", Time.valueOf(LocalTime.MIN)) - .value(20, "c_Datetime", Time.valueOf(LocalTime.ofSecondOfDay(1))) - .value(21, "c_Timestamp", new Time(1 / 1000)); + .value(20, "c_Datetime", Time.valueOf(LocalTime.ofSecondOfDay(1))) + .value(21, "c_Timestamp", new Time(1 / 1000)) + .value(19, "c_Date32", Time.valueOf(LocalTime.MIN)) + .value(20, "c_Datetime64", Time.valueOf(LocalTime.ofSecondOfDay(1))) + .value(21, "c_Timestamp64", new Time(1 / 1000)); checker.nextRow() .value(3, "c_Int8", null) @@ -1862,7 +1964,10 @@ public void getTime() throws SQLException { .value(10, "c_Uint64", null) .value(19, "c_Date", null) .value(20, "c_Datetime", null) - .value(21, "c_Timestamp", null); + .value(21, "c_Timestamp", null) + .value(26, "c_Date", null) + .value(27, "c_Datetime", null) + .value(28, "c_Timestamp", null); checker.assertNoRows(); } @@ -2045,8 +2150,8 @@ public void getObject() throws SQLException { checker.nextRow() .typedValue(1, "key", 1) .typedValue(2, "c_Bool", true) - .typedValue(3, "c_Int8", (byte)101) - .typedValue(4, "c_Int16", (short)20001) + .typedValue(3, "c_Int8", (byte) 101) + .typedValue(4, "c_Int16", (short) 20001) .typedValue(5, "c_Int32", 2000000001) .typedValue(6, "c_Int64", 2000000000001l) .typedValue(7, "c_Uint8", 100) @@ -2072,8 +2177,8 @@ public void getObject() throws SQLException { checker.nextRow() .typedValue(1, "key", 2) .typedValue(2, "c_Bool", false) - .typedValue(3, "c_Int8", (byte)-101) - .typedValue(4, "c_Int16", (short)-20001) + .typedValue(3, "c_Int8", (byte) -101) + .typedValue(4, "c_Int16", (short) -20001) .typedValue(5, "c_Int32", -2000000001) .typedValue(6, "c_Int64", -2000000000001l) .typedValue(7, "c_Uint8", 200) @@ -2099,8 +2204,8 @@ public void getObject() throws SQLException { checker.nextRow() .typedValue(1, "key", 3) .typedValue(2, "c_Bool", false) - .typedValue(3, "c_Int8", (byte)0) - .typedValue(4, "c_Int16", (short)0) + .typedValue(3, "c_Int8", (byte) 0) + .typedValue(4, "c_Int16", (short) 0) .typedValue(5, "c_Int32", 0) .typedValue(6, "c_Int64", 0l) .typedValue(7, "c_Uint8", 0) @@ -2126,8 +2231,8 @@ public void getObject() throws SQLException { checker.nextRow() .typedValue(1, "key", 4) .typedValue(2, "c_Bool", true) - .typedValue(3, "c_Int8", (byte)1) - .typedValue(4, "c_Int16", (short)1) + .typedValue(3, "c_Int8", (byte) 1) + .typedValue(4, "c_Int16", (short) 1) .typedValue(5, "c_Int32", 1) .typedValue(6, "c_Int64", 1l) .typedValue(7, "c_Uint8", 1) @@ -2169,13 +2274,17 @@ public void getObject() throws SQLException { .value(16, "c_JsonDocument", null) .value(17, "c_Yson", null) .value(18, "c_Uuid", null) - .value(18, "c_Date", null) - .value(19, "c_Datetime", null) - .value(20, "c_Timestamp", null) - .value(21, "c_Interval", null) - .value(22, "c_Decimal", null) - .value(22, "c_BigDecimal", null) - .value(22, "c_BankDecimal", null); + .value(19, "c_Date", null) + .value(20, "c_Datetime", null) + .value(21, "c_Timestamp", null) + .value(22, "c_Interval", null) + .value(23, "c_Decimal", null) + .value(24, "c_BigDecimal", null) + .value(25, "c_BankDecimal", null) + .value(26, "c_Date32", null) + .value(27, "c_Datetime64", null) + .value(28, "c_Timestamp64", null) + .value(29, "c_Interval64", null); checker.assertNoRows(); } @@ -2381,8 +2490,8 @@ public void getNativeColumn() throws SQLException { checker.nextRow() .typedValue(1, "key", PrimitiveValue.newInt32(1)) .typedValue(2, "c_Bool", PrimitiveValue.newBool(true)) - .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte)101)) - .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short)20001)) + .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte) 101)) + .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short) 20001)) .typedValue(5, "c_Int32", PrimitiveValue.newInt32(2000000001)) .typedValue(6, "c_Int64", PrimitiveValue.newInt64(2000000000001L)) .typedValue(7, "c_Uint8", PrimitiveValue.newUint8((short) 100)) @@ -2403,13 +2512,17 @@ public void getNativeColumn() throws SQLException { .typedValue(22, "c_Interval", PrimitiveValue.newInterval(Duration.parse("PT3.111113S"))) .typedValue(23, "c_Decimal", DecimalType.getDefault().newValue("3.335000000")) .typedValue(24, "c_BigDecimal", DecimalType.of(35, 0).newValue("12345678901234567890123456789012345")) - .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue("9999999999999999999999.999999999")); + .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue("9999999999999999999999.999999999")) + .typedValue(26, "c_Date32", PrimitiveValue.newDate32(LocalDate.ofEpochDay(-3111))) + .typedValue(27, "c_Datetime64", PrimitiveValue.newDatetime64(Instant.ofEpochSecond(-311111156))) + .typedValue(28, "c_Timestamp64", PrimitiveValue.newTimestamp64(Instant.ofEpochSecond(-311111, -223342000))) + .typedValue(29, "c_Interval64", PrimitiveValue.newInterval64(Duration.parse("-PT3.111113S"))); checker.nextRow() .typedValue(1, "key", PrimitiveValue.newInt32(2)) .typedValue(2, "c_Bool", PrimitiveValue.newBool(false)) - .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte)-101)) - .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short)-20001)) + .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte) -101)) + .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short) -20001)) .typedValue(5, "c_Int32", PrimitiveValue.newInt32(-2000000001)) .typedValue(6, "c_Int64", PrimitiveValue.newInt64(-2000000000001L)) .typedValue(7, "c_Uint8", PrimitiveValue.newUint8((short) 200)) @@ -2430,13 +2543,17 @@ public void getNativeColumn() throws SQLException { .typedValue(22, "c_Interval", PrimitiveValue.newInterval(Duration.parse("PT3.112113S"))) .typedValue(23, "c_Decimal", DecimalType.getDefault().newValue("-3.335000000")) .typedValue(24, "c_BigDecimal", DecimalType.of(35, 0).newValue("-98765432109876543210987654321098765")) - .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue("-9999999999999999999999.999999999")); + .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue("-9999999999999999999999.999999999")) + .typedValue(26, "c_Date32", PrimitiveValue.newDate32(LocalDate.ofEpochDay(3112))) + .typedValue(27, "c_Datetime64", PrimitiveValue.newDatetime64(Instant.ofEpochSecond(211211100))) + .typedValue(28, "c_Timestamp64", PrimitiveValue.newTimestamp64(Instant.ofEpochSecond(111111, 223342000))) + .typedValue(29, "c_Interval64", PrimitiveValue.newInterval64(Duration.parse("PT3.112113S"))); checker.nextRow() .typedValue(1, "key", PrimitiveValue.newInt32(3)) .typedValue(2, "c_Bool", PrimitiveValue.newBool(false)) - .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte)0)) - .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short)0)) + .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte) 0)) + .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short) 0)) .typedValue(5, "c_Int32", PrimitiveValue.newInt32(0)) .typedValue(6, "c_Int64", PrimitiveValue.newInt64(0)) .typedValue(7, "c_Uint8", PrimitiveValue.newUint8((short) 0)) @@ -2457,13 +2574,17 @@ public void getNativeColumn() throws SQLException { .typedValue(22, "c_Interval", PrimitiveValue.newInterval(Duration.parse("PT0S"))) .typedValue(23, "c_Decimal", DecimalType.getDefault().newValue(0)) .typedValue(24, "c_BigDecimal", DecimalType.of(35, 0).newValue(0)) - .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue(0)); + .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue(0)) + .typedValue(26, "c_Date32", PrimitiveValue.newDate32(LocalDate.parse("1970-01-01"))) + .typedValue(27, "c_Datetime64", PrimitiveValue.newDatetime64(Instant.parse("1970-01-01T00:00:00Z"))) + .typedValue(28, "c_Timestamp64", PrimitiveValue.newTimestamp64(Instant.ofEpochMilli(0))) + .typedValue(29, "c_Interval64", PrimitiveValue.newInterval64(Duration.parse("PT0S"))); checker.nextRow() .typedValue(1, "key", PrimitiveValue.newInt32(4)) .typedValue(2, "c_Bool", PrimitiveValue.newBool(true)) - .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte)1)) - .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short)1)) + .typedValue(3, "c_Int8", PrimitiveValue.newInt8((byte) 1)) + .typedValue(4, "c_Int16", PrimitiveValue.newInt16((short) 1)) .typedValue(5, "c_Int32", PrimitiveValue.newInt32(1)) .typedValue(6, "c_Int64", PrimitiveValue.newInt64(1)) .typedValue(7, "c_Uint8", PrimitiveValue.newUint8((short) 1)) @@ -2484,7 +2605,11 @@ public void getNativeColumn() throws SQLException { .typedValue(22, "c_Interval", PrimitiveValue.newInterval(Duration.parse("PT0.000001S"))) .typedValue(23, "c_Decimal", DecimalType.getDefault().newValue(1)) .typedValue(24, "c_BigDecimal", DecimalType.of(35, 0).newValue(1)) - .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue(1)); + .typedValue(25, "c_BankDecimal", DecimalType.of(31, 9).newValue(1)) + .typedValue(26, "c_Date32", PrimitiveValue.newDate32(LocalDate.parse("1970-01-02"))) + .typedValue(27, "c_Datetime64", PrimitiveValue.newDatetime64(Instant.parse("1970-01-01T00:00:01Z"))) + .typedValue(28, "c_Timestamp64", PrimitiveValue.newTimestamp64(1)) + .typedValue(29, "c_Interval64", PrimitiveValue.newInterval64(Duration.parse("PT0.000001S"))); checker.nextRow() .value(1, "key", PrimitiveValue.newInt32(5)) @@ -2511,7 +2636,11 @@ public void getNativeColumn() throws SQLException { .value(22, "c_Interval", null) .value(23, "c_Decimal", null) .value(24, "c_BigDecimal", null) - .value(25, "c_BankDecimal", null); + .value(25, "c_BankDecimal", null) + .value(26, "c_Date32", null) + .value(27, "c_Datetime64", null) + .value(28, "c_Timestamp64", null) + .value(29, "c_Interval64", null); checker.assertNoRows(); } @@ -2566,9 +2695,9 @@ public ResultSetChecker typedValue(int index, String column, T expected) thro T v1 = assertValue(expected, nameFunctor.apply(rs, column), false, "for column label " + column); T v2 = assertValue(expected, indexFunctor.apply(rs, index), false, "for column index " + index); - Assertions.assertEquals((Class) expected.getClass(), (Class) v1.getClass(), + Assertions.assertEquals(expected.getClass(), v1.getClass(), "Wrong Java class for column label " + column); - Assertions.assertEquals((Class) expected.getClass(), (Class) v2.getClass(), + Assertions.assertEquals(expected.getClass(), v2.getClass(), "Wrong Java class for column index " + index); return this; } @@ -2581,7 +2710,7 @@ private T assertValue(T expected, T value, boolean isNull, String message) throw } if (expected instanceof byte[]) { - Assertions.assertArrayEquals((byte[])expected, (byte[])value, "Wrong array value " + message); + Assertions.assertArrayEquals((byte[]) expected, (byte[]) value, "Wrong array value " + message); Assertions.assertEquals(isNull, rs.wasNull(), "Unexpected wasNull " + message); return value; } diff --git a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbTablePreparedStatementImplTest.java b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbTablePreparedStatementImplTest.java index b99f795..47c85a0 100644 --- a/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbTablePreparedStatementImplTest.java +++ b/jdbc/src/test/java/tech/ydb/jdbc/impl/YdbTablePreparedStatementImplTest.java @@ -154,7 +154,9 @@ public void executeWithoutBatch(SqlQueries.YqlQuery mode) throws SQLException { .nextRow(3, "value-3") .noNextRows(); } - }; + } + + ; @ParameterizedTest(name = "with {0}") @EnumSource(SqlQueries.YqlQuery.class) @@ -201,7 +203,7 @@ public void addBatch(SqlQueries.YqlQuery mode) throws SQLException { statement.setInt("key", 3); statement.setString("c_Text", "value-3"); - Assertions.assertArrayEquals(new int[]{ Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO }, + Assertions.assertArrayEquals(new int[]{Statement.SUCCESS_NO_INFO, Statement.SUCCESS_NO_INFO}, statement.executeBatch()); // does nothing @@ -487,6 +489,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", Types.DECIMAL); ps.setNull("c_BigDecimal", Types.DECIMAL); ps.setNull("c_BankDecimal", Types.DECIMAL); + ps.setNull("c_Date32", Types.DATE); + ps.setNull("c_Datetime64", Types.TIMESTAMP); + ps.setNull("c_Timestamp64", Types.TIMESTAMP); + ps.setNull("c_Interval64", Types.JAVA_OBJECT); ps.executeUpdate(); } @@ -517,6 +523,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", -1, "Decimal(22, 9)"); ps.setNull("c_BigDecimal", -1, "Decimal(35, 0)"); ps.setNull("c_BankDecimal", -1, "Decimal(31, 9)"); + ps.setNull("c_Date32", -1, "Date32"); + ps.setNull("c_Datetime64", -1, "Datetime64"); + ps.setNull("c_Timestamp64", -1, "Timestamp64"); + ps.setNull("c_Interval64", -1, "Interval64"); ps.executeUpdate(); } @@ -547,6 +557,10 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { ps.setNull("c_Decimal", -1); ps.setNull("c_BigDecimal", -1); ps.setNull("c_BankDecimal", -1); + ps.setNull("c_Date32", -1); + ps.setNull("c_Datetime64", -1); + ps.setNull("c_Timestamp64", -14); + ps.setNull("c_Interval64", -1); ps.executeUpdate(); } @@ -558,7 +572,7 @@ public void testSetNull(SqlQueries.YqlQuery mode) throws SQLException { Assertions.assertTrue(rs.next()); ResultSetMetaData metaData = rs.getMetaData(); - Assertions.assertEquals(25, metaData.getColumnCount()); + Assertions.assertEquals(29, metaData.getColumnCount()); Assertions.assertEquals(key, rs.getInt("key")); // key for (int i = 2; i <= metaData.getColumnCount(); i++) { @@ -582,7 +596,7 @@ public void testParametersMeta(SqlQueries.YqlQuery mode) throws SQLException { () -> meta.getParameterType(335) ); - Assertions.assertEquals(25, meta.getParameterCount()); + Assertions.assertEquals(29, meta.getParameterCount()); for (int param = 1; param <= meta.getParameterCount(); param++) { String name = ydbMeta.getParameterName(param); boolean isKey = "key".equals(name); @@ -661,15 +675,19 @@ public void testParametersMeta(SqlQueries.YqlQuery mode) throws SQLException { expectClassName = UUID.class.getName(); break; case "c_Date": + case "c_Date32": expectClassName = LocalDate.class.getName(); break; case "c_Datetime": + case "c_Datetime64": expectClassName = LocalDateTime.class.getName(); break; case "c_Timestamp": + case "c_Timestamp64": expectClassName = Instant.class.getName(); break; case "c_Interval": + case "c_Interval64": expectClassName = Duration.class.getName(); break; case "c_Decimal": diff --git a/jdbc/src/test/resources/sql/create.sql b/jdbc/src/test/resources/sql/create.sql index 6691d2c..ab013f4 100644 --- a/jdbc/src/test/resources/sql/create.sql +++ b/jdbc/src/test/resources/sql/create.sql @@ -40,6 +40,12 @@ create table #tableName c_BigDecimal Decimal(35, 0), c_BankDecimal Decimal(31, 9), + -- New Dates + c_Date32 Date32, + c_Datetime64 Datetime64, + c_Timestamp64 Timestamp64, + c_Interval64 Interval64, + -- unsupported c_TzDate TzDate, -- unsupported c_TzDatetime TzDatetime, -- unsupported c_TzTimestamp TzTimestamp, diff --git a/jdbc/src/test/resources/sql/init.sql b/jdbc/src/test/resources/sql/init.sql index 2ee996c..70441b5 100644 --- a/jdbc/src/test/resources/sql/init.sql +++ b/jdbc/src/test/resources/sql/init.sql @@ -30,7 +30,12 @@ upsert into #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) values (1, @@ -57,7 +62,11 @@ values cast (3111113 as Interval), Decimal('3.335', 22, 9), Decimal('12345678901234567890123456789012345', 35, 0), - Decimal('9999999999999999999999.999999999', 31, 9) + Decimal('9999999999999999999999.999999999', 31, 9), + cast (-3111 as Date32), + cast (-311111156 as DateTime64), + cast (-311111223342 as Timestamp64), + cast (-3111113 as Interval64) ), (2, false, @@ -83,7 +92,11 @@ values cast (3112113 as Interval), Decimal('-3.335', 22, 9), Decimal('-98765432109876543210987654321098765', 35, 0), - Decimal('-9999999999999999999999.999999999', 31, 9) + Decimal('-9999999999999999999999.999999999', 31, 9), + cast (3112 as Date32), + cast (211211100 as DateTime64), + cast (111111223342 as Timestamp64), + cast (3112113 as Interval64) ), (3, false, @@ -109,7 +122,11 @@ values cast (0 as Interval), Decimal('0', 22, 9), Decimal('0', 35, 0), - Decimal('0', 31, 9) + Decimal('0', 31, 9), + cast (0 as Date32), + cast (0 as DateTime64), + cast (0 as Timestamp64), + cast (0 as Interval64) ), (4, true, @@ -135,7 +152,11 @@ values cast (1 as Interval), Decimal('1', 22, 9), Decimal('1', 35, 0), - Decimal('1', 31, 9) + Decimal('1', 31, 9), + cast (1 as Date32), + cast (1 as DateTime64), + cast (1 as Timestamp64), + cast (1 as Interval64) ), (5, null, @@ -161,5 +182,9 @@ values null, null, null, + null, + null, + null, + null, null ) diff --git a/jdbc/src/test/resources/sql/select.sql b/jdbc/src/test/resources/sql/select.sql index 827d3c8..8396fbd 100644 --- a/jdbc/src/test/resources/sql/select.sql +++ b/jdbc/src/test/resources/sql/select.sql @@ -30,5 +30,10 @@ select c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 from #tableName order by key diff --git a/jdbc/src/test/resources/sql/upsert/bulk.sql b/jdbc/src/test/resources/sql/upsert/bulk.sql index 81af656..0e8d778 100644 --- a/jdbc/src/test/resources/sql/upsert/bulk.sql +++ b/jdbc/src/test/resources/sql/upsert/bulk.sql @@ -31,7 +31,12 @@ BULK UPSERT INTO #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) VALUES ( ?, -- key ?, -- c_Bool @@ -64,5 +69,10 @@ BULK UPSERT INTO #tableName ( ?, -- c_Decimal ?, -- c_BigDecimal - ? -- c_BankDecimal + ?, -- c_BankDecimal + + ?, -- c_Date32 + ?, -- c_Datetime64 + ?, -- c_Timestamp64 + ? -- c_Interval64 ) \ No newline at end of file diff --git a/jdbc/src/test/resources/sql/upsert/in_memory.sql b/jdbc/src/test/resources/sql/upsert/in_memory.sql index d4b8592..e840e1c 100644 --- a/jdbc/src/test/resources/sql/upsert/in_memory.sql +++ b/jdbc/src/test/resources/sql/upsert/in_memory.sql @@ -32,7 +32,12 @@ UPSERT INTO #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) VALUES ( ?, -- key ?, -- c_Bool @@ -65,5 +70,10 @@ UPSERT INTO #tableName ( ?, -- c_Decimal ?, -- c_BigDecimal - ? -- c_BankDecimal + ?, -- c_BankDecimal + + ?, -- c_Date32 + ?, -- c_Datetime64 + ?, -- c_Timestamp64 + ? -- c_Interval64 ) \ No newline at end of file diff --git a/jdbc/src/test/resources/sql/upsert/named.sql b/jdbc/src/test/resources/sql/upsert/named.sql index 3eef278..7434820 100644 --- a/jdbc/src/test/resources/sql/upsert/named.sql +++ b/jdbc/src/test/resources/sql/upsert/named.sql @@ -32,6 +32,11 @@ declare $c_Decimal as Optional; declare $c_BigDecimal as Optional; declare $c_BankDecimal as Optional; +declare $c_Date32 as Optional; +declare $c_Datetime64 as Optional; +declare $c_Timestamp64 as Optional; +declare $c_Interval64 as Optional; + upsert into #tableName ( key, @@ -65,7 +70,12 @@ upsert into #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) values ( $key, @@ -99,5 +109,10 @@ upsert into #tableName ( $c_Decimal, $c_BigDecimal, - $c_BankDecimal + $c_BankDecimal, + + $c_Date32, + $c_Datetime64, + $c_Timestamp64, + $c_Interval64 ) diff --git a/jdbc/src/test/resources/sql/upsert/named_batch.sql b/jdbc/src/test/resources/sql/upsert/named_batch.sql index a2985b6..6064e0e 100644 --- a/jdbc/src/test/resources/sql/upsert/named_batch.sql +++ b/jdbc/src/test/resources/sql/upsert/named_batch.sql @@ -31,7 +31,12 @@ declare $list as List, c_BigDecimal:Optional, - c_BankDecimal:Optional + c_BankDecimal:Optional, + + c_Date32:Optional, + c_Datetime64:Optional, + c_Timestamp64:Optional, + c_Interval64:Optional >>; upsert into #tableName select * from as_table($list) diff --git a/jdbc/src/test/resources/sql/upsert/simple.sql b/jdbc/src/test/resources/sql/upsert/simple.sql index 9f827a1..ae34098 100644 --- a/jdbc/src/test/resources/sql/upsert/simple.sql +++ b/jdbc/src/test/resources/sql/upsert/simple.sql @@ -31,7 +31,12 @@ UPSERT INTO #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) VALUES ( ?, -- key ?, -- c_Bool @@ -64,5 +69,10 @@ UPSERT INTO #tableName ( ?, -- c_Decimal ?, -- c_BigDecimal - ? -- c_BankDecimal + ?, -- c_BankDecimal + + ?, -- c_Date32 + ?, -- c_Datetime64 + ?, -- c_Timestamp64 + ? -- c_Interval64 ) \ No newline at end of file diff --git a/jdbc/src/test/resources/sql/upsert/typed.sql b/jdbc/src/test/resources/sql/upsert/typed.sql index a3f4b2c..de8d8e0 100644 --- a/jdbc/src/test/resources/sql/upsert/typed.sql +++ b/jdbc/src/test/resources/sql/upsert/typed.sql @@ -32,6 +32,11 @@ declare $p23 as Optional; declare $p24 as Optional; declare $p25 as Optional; +declare $p26 as Optional; +declare $p27 as Optional; +declare $p28 as Optional; +declare $p29 as Optional; + upsert into #tableName ( key, @@ -65,7 +70,12 @@ upsert into #tableName ( c_Decimal, c_BigDecimal, - c_BankDecimal + c_BankDecimal, + + c_Date32, + c_Datetime64, + c_Timestamp64, + c_Interval64 ) values ( $p1, $p2, @@ -91,5 +101,9 @@ upsert into #tableName ( $p22, $p23, $p24, - $p25 + $p25, + $p26, + $p27, + $p28, + $p29 ) \ No newline at end of file diff --git a/jdbc/src/test/resources/sql/upsert/typed_batch.sql b/jdbc/src/test/resources/sql/upsert/typed_batch.sql index 23a6f30..de6cf66 100644 --- a/jdbc/src/test/resources/sql/upsert/typed_batch.sql +++ b/jdbc/src/test/resources/sql/upsert/typed_batch.sql @@ -31,7 +31,12 @@ declare $list as List, p24:Optional, - p25:Optional + p25:Optional, + + p26:Optional, + p27:Optional, + p28:Optional, + p29:Optional >>; upsert into #tableName select @@ -67,5 +72,10 @@ upsert into #tableName select p23 as c_Decimal, p24 as c_BigDecimal, - p25 as c_BankDecimal + p25 as c_BankDecimal, + + p26 as c_Date32, + p27 as c_Datetime64, + p28 as c_Timestamp64, + p29 as c_Interval64 from as_table($list); diff --git a/pom.xml b/pom.xml index 6cad478..930dd86 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ 1.7.36 5.9.3 - 2.3.13 + 2.3.14