diff --git a/coordination/pom.xml b/coordination/pom.xml
index 2c5613698..f4f510274 100644
--- a/coordination/pom.xml
+++ b/coordination/pom.xml
@@ -41,19 +41,4 @@
test
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- cr.yandex/yc/yandex-docker-local-ydb:trunk
- true
-
-
-
-
-
diff --git a/query/pom.xml b/query/pom.xml
index 123194c54..e59820cd9 100644
--- a/query/pom.xml
+++ b/query/pom.xml
@@ -36,19 +36,4 @@
test
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- cr.yandex/yc/yandex-docker-local-ydb:trunk
- true
-
-
-
-
-
diff --git a/query/src/test/java/tech/ydb/query/QueryExampleTest.java b/query/src/test/java/tech/ydb/query/QueryExampleTest.java
index 363baa4d3..b6f0aaa20 100644
--- a/query/src/test/java/tech/ydb/query/QueryExampleTest.java
+++ b/query/src/test/java/tech/ydb/query/QueryExampleTest.java
@@ -116,8 +116,14 @@ public void step02_upsertTablesData() {
);
// Upsert list of series to table
- retryCtx.supplyResult(session -> session.createQuery(
- "UPSERT INTO series SELECT * FROM AS_TABLE($values)",
+ retryCtx.supplyResult(session -> session.createQuery(""
+ + "DECLARE $values AS List>;"
+ + "UPSERT INTO series SELECT * FROM AS_TABLE($values)",
TxMode.SERIALIZABLE_RW,
Params.of("$values", seriesData)
).execute()).join().getStatus().expectSuccess("upsert problem");
@@ -143,8 +149,15 @@ public void step02_upsertTablesData() {
);
// Upsert list of seasons to table
- retryCtx.supplyResult(session -> session.createQuery(
- "UPSERT INTO seasons SELECT * FROM AS_TABLE($values)",
+ retryCtx.supplyResult(session -> session.createQuery(""
+ + "DECLARE $values AS List>;"
+ + "UPSERT INTO seasons SELECT * FROM AS_TABLE($values)",
TxMode.SERIALIZABLE_RW,
Params.of("$values", seasonsData)
).execute()).join().getStatus().expectSuccess("upsert problem");
@@ -170,8 +183,15 @@ public void step02_upsertTablesData() {
);
// Upsert list of series to episodes
- retryCtx.supplyResult(session -> session.createQuery(
- "UPSERT INTO episodes SELECT * FROM AS_TABLE($values)",
+ retryCtx.supplyResult(session -> session.createQuery(""
+ + "DECLARE $values AS List>;"
+ + "UPSERT INTO episodes SELECT * FROM AS_TABLE($values)",
TxMode.SERIALIZABLE_RW,
Params.of("$values", episodesData)
).execute()).join().getStatus().expectSuccess("upsert problem");
diff --git a/query/src/test/java/tech/ydb/query/impl/QueryIntegrationTest.java b/query/src/test/java/tech/ydb/query/impl/QueryIntegrationTest.java
index 24b05402a..b3f863afe 100644
--- a/query/src/test/java/tech/ydb/query/impl/QueryIntegrationTest.java
+++ b/query/src/test/java/tech/ydb/query/impl/QueryIntegrationTest.java
@@ -252,7 +252,11 @@ public void testSimpleCRUD() {
try (QueryClient client = QueryClient.newClient(ydbTransport).build()) {
for (Entity entity: entities) {
- String query = "UPSERT INTO `" + TEST_TABLE + "` (id, name, payload, is_valid) "
+ String query = "DECLARE $id AS Int32;"
+ + "DECLARE $name AS Text;"
+ + "DECLARE $payload AS Bytes;"
+ + "DECLARE $is_valid AS Bool;"
+ + "UPSERT INTO `" + TEST_TABLE + "` (id, name, payload, is_valid) "
+ "VALUES ($id, $name, $payload, $is_valid)";
Params params = Params.of(
@@ -459,6 +463,12 @@ public void testMultiStatement() {
try (QueryClient client = QueryClient.newClient(ydbTransport).build()) {
try (QuerySession session = client.createSession(Duration.ofSeconds(5)).join().getValue()) {
String query = ""
+ + "DECLARE $s1 AS Int32;"
+ + "DECLARE $s2 AS Int32;"
+ + "DECLARE $id1 AS Int32;"
+ + "DECLARE $id2 AS Int32;"
+ + "DECLARE $name1 AS Text;"
+ + "DECLARE $name2 AS Text;"
+ "SELECT * FROM `" + TEST_TABLE + "` WHERE id = $s1;"
+ "INSERT INTO `" + TEST_TABLE + "` (id, name) VALUES ($id1, $name1);"
+ "SELECT * FROM `" + TEST_TABLE + "` WHERE id = $s2;"
diff --git a/table/pom.xml b/table/pom.xml
index aa7c18352..57fd6f973 100644
--- a/table/pom.xml
+++ b/table/pom.xml
@@ -41,19 +41,4 @@
test
-
-
-
-
- org.apache.maven.plugins
- maven-surefire-plugin
-
-
- cr.yandex/yc/yandex-docker-local-ydb:trunk
- true
-
-
-
-
-
diff --git a/table/src/main/java/tech/ydb/table/values/PrimitiveValue.java b/table/src/main/java/tech/ydb/table/values/PrimitiveValue.java
index c92882b35..cfa629a76 100644
--- a/table/src/main/java/tech/ydb/table/values/PrimitiveValue.java
+++ b/table/src/main/java/tech/ydb/table/values/PrimitiveValue.java
@@ -291,14 +291,29 @@ public static PrimitiveValue newDatetime(LocalDateTime value) {
public static PrimitiveValue newTimestamp(long microsSinceEpoch) {
if (microsSinceEpoch < 0) {
- throw new IllegalArgumentException("negative microsSinceEpoch: " + microsSinceEpoch);
+ throw new IllegalArgumentException("microsSinceEpoch value is before "
+ + "minimum timestamp(1970-01-01 00:00:00.000000): " + microsSinceEpoch);
+ }
+ if (microsSinceEpoch >= 4291747200000000L) {
+ throw new IllegalArgumentException("microsSinceEpoch value is after "
+ + "maximum timestamp(2105-12-31 23:59:59.999999): " + microsSinceEpoch);
}
return new InstantValue(PrimitiveType.Timestamp, microsSinceEpoch);
}
public static PrimitiveValue newTimestamp(Instant value) {
- long micros = TimeUnit.SECONDS.toMicros(value.getEpochSecond()) +
- TimeUnit.NANOSECONDS.toMicros(value.getNano());
+ long seconds = value.getEpochSecond();
+ if (seconds < 0) {
+ throw new IllegalArgumentException("Instant value is before "
+ + "minimum timestamp(1970-01-01 00:00:00.000000): " + value);
+ }
+ int nanos = value.getNano();
+ long micros = seconds * 1000000L + nanos / 1000;
+ if (micros >= 4291747200000000L) {
+ throw new IllegalArgumentException("Instant value is after "
+ + "maximum timestamp(2105-12-31 23:59:59.999999): " + value
+ );
+ }
return new InstantValue(PrimitiveType.Timestamp, micros);
}
diff --git a/table/src/test/java/tech/ydb/table/integration/TtlTableTest.java b/table/src/test/java/tech/ydb/table/integration/TtlTableTest.java
index 673885970..9ba6a4a31 100644
--- a/table/src/test/java/tech/ydb/table/integration/TtlTableTest.java
+++ b/table/src/test/java/tech/ydb/table/integration/TtlTableTest.java
@@ -112,4 +112,33 @@ public void alterTableTest() {
Assert.assertEquals(TableTtl.TtlUnit.UNSPECIFIED, ttl.getTtlUnit());
Assert.assertNull(ttl.getRunIntervaelSeconds());
}
+
+ @Test
+ public void noTtlTableTest() {
+ // --------------------- create table -----------------------------
+ TableDescription createTableDesc = TableDescription.newBuilder()
+ .addNonnullColumn("id", PrimitiveType.Uint64)
+ .addNullableColumn("date", PrimitiveType.Datetime)
+ .addNullableColumn("value", PrimitiveType.Uint64)
+ .setPrimaryKey("id")
+ .build();
+
+ Status createStatus = ctx.supplyStatus(
+ session -> session.createTable(tablePath, createTableDesc, new CreateTableSettings())
+ ).join();
+ Assert.assertTrue("Create table ttl " + createStatus, createStatus.isSuccess());
+
+ // --------------------- describe table after creating -----------------------------
+ Result describeResult = ctx.supplyResult(session ->session.describeTable(tablePath)).join();
+ Assert.assertTrue("Describe table with ttl " + describeResult.getStatus(), describeResult.isSuccess());
+
+ TableTtl ttl = describeResult.getValue().getTableTtl();
+
+ Assert.assertNotNull(ttl);
+ Assert.assertEquals(TableTtl.TtlMode.NOT_SET, ttl.getTtlMode());
+ Assert.assertEquals("", ttl.getDateTimeColumn());
+ Assert.assertEquals(Integer.valueOf(0), ttl.getExpireAfterSeconds());
+ Assert.assertEquals(TableTtl.TtlUnit.UNSPECIFIED, ttl.getTtlUnit());
+ Assert.assertNull(ttl.getRunIntervaelSeconds());
+ }
}
diff --git a/table/src/test/java/tech/ydb/table/integration/ValuesReadTest.java b/table/src/test/java/tech/ydb/table/integration/ValuesReadTest.java
index 08a13ccf7..a5e8400bb 100644
--- a/table/src/test/java/tech/ydb/table/integration/ValuesReadTest.java
+++ b/table/src/test/java/tech/ydb/table/integration/ValuesReadTest.java
@@ -1,11 +1,15 @@
package tech.ydb.table.integration;
+import java.time.Instant;
import java.util.UUID;
import org.junit.Assert;
import org.junit.ClassRule;
import org.junit.Test;
+import tech.ydb.core.Issue;
+import tech.ydb.core.Status;
+import tech.ydb.core.StatusCode;
import tech.ydb.table.SessionRetryContext;
import tech.ydb.table.impl.SimpleTableClient;
import tech.ydb.table.query.DataQueryResult;
@@ -101,4 +105,56 @@ public void uuidReadTest() {
Assert.assertEquals(0x9cfbb7462d9e498bL, v2.getUuidLow());
Assert.assertEquals(0x6e73b41c4ede4d08L, v2.getUuidHigh());
}
+
+ private void assertTimestamp(ValueReader vr, boolean optional, Instant expected) {
+ Assert.assertNotNull(vr);
+ if (optional) {
+ Assert.assertSame(Type.Kind.OPTIONAL, vr.getType().getKind());
+ Assert.assertSame(PrimitiveType.Timestamp, vr.getType().unwrapOptional());
+ } else {
+ Assert.assertSame(PrimitiveType.Timestamp, vr.getType());
+ }
+
+ Assert.assertEquals(expected, vr.getTimestamp());
+ }
+
+ @Test
+ public void timestampReadTest() {
+ DataQueryResult result = CTX.supplyResult(
+ s -> s.executeDataQuery("SELECT "
+ + "DateTime::MakeTimestamp(DateTime::FromMilliseconds(0ul)) as t1,"
+ + "DateTime::MakeTimestamp(DateTime::FromMicroseconds(1000ul)) as t2,"
+ + "DateTime::MakeTimestamp(DateTime::FromMicroseconds(4291747199999999ul)) as t3,"
+ + "Timestamp('1970-01-01T00:00:00.000000Z') as t4,"
+ + "Timestamp('2105-12-31T23:59:59.999999Z') as t5;",
+ TxControl.serializableRw()
+ )
+ ).join().getValue();
+
+ Assert.assertEquals(1, result.getResultSetCount());
+
+ ResultSetReader rs = result.getResultSet(0);
+ Assert.assertTrue(rs.next());
+
+ assertTimestamp(rs.getColumn("t1"), true, Instant.EPOCH);
+ assertTimestamp(rs.getColumn("t2"), true, Instant.EPOCH.plusMillis(1));
+ assertTimestamp(rs.getColumn("t3"), true, Instant.parse("2105-12-31T23:59:59.999999Z"));
+ assertTimestamp(rs.getColumn("t4"), false, Instant.ofEpochSecond(0, 0));
+ assertTimestamp(rs.getColumn("t5"), false, Instant.ofEpochSecond(4291747199l, 999999000l));
+
+ Status invalid = CTX.supplyResult(
+ s -> s.executeDataQuery("SELECT "
+ + "Timestamp('1969-12-31T23:59:59.999999Z') as t6,"
+ + "Timestamp('2106-01-01T00:00:00.000000Z') as t7;",
+ TxControl.serializableRw()
+ )
+ ).join().getStatus();
+
+ Assert.assertEquals(StatusCode.GENERIC_ERROR, invalid.getCode());
+ Issue[] issues = invalid.getIssues();
+ Assert.assertEquals(2, issues.length);
+ Assert.assertEquals("Invalid value \"1969-12-31T23:59:59.999999Z\" for type Timestamp", issues[0].getMessage());
+ Assert.assertEquals("Invalid value \"2106-01-01T00:00:00.000000Z\" for type Timestamp", issues[1].getMessage());
+
+ }
}
diff --git a/table/src/test/java/tech/ydb/table/types/DecimalTypeTest.java b/table/src/test/java/tech/ydb/table/types/DecimalTypeTest.java
deleted file mode 100644
index c08ddbd9f..000000000
--- a/table/src/test/java/tech/ydb/table/types/DecimalTypeTest.java
+++ /dev/null
@@ -1,65 +0,0 @@
-package tech.ydb.table.types;
-
-import java.math.BigDecimal;
-
-import org.junit.Assert;
-import org.junit.Test;
-
-import tech.ydb.proto.ValueProtos;
-import tech.ydb.table.values.DecimalType;
-import tech.ydb.table.values.Type;
-import tech.ydb.table.values.proto.ProtoType;
-
-
-/**
- * @author Sergey Polovko
- */
-public class DecimalTypeTest {
-
- @Test
- public void contract() {
- DecimalType t = DecimalType.of(13, 2);
-
- Assert.assertEquals(Type.Kind.DECIMAL, t.getKind());
- Assert.assertEquals(13, t.getPrecision());
- Assert.assertEquals(2, t.getScale());
-
- Assert.assertEquals(DecimalType.of(13, 2), t);
- Assert.assertNotEquals(DecimalType.of(11, 2), t);
- Assert.assertNotEquals(DecimalType.of(13, 1), t);
-
- Assert.assertEquals(DecimalType.of(13, 2).hashCode(), t.hashCode());
- Assert.assertNotEquals(DecimalType.of(11, 2).hashCode(), t.hashCode());
- Assert.assertNotEquals(DecimalType.of(13, 1).hashCode(), t.hashCode());
-
- Assert.assertEquals("Decimal(13, 2)", t.toString());
- }
-
- @Test
- public void protobuf() {
- DecimalType type = DecimalType.of(10, 5);
- ValueProtos.Type typePb = type.toPb();
-
- Assert.assertEquals(ProtoType.getDecimal(10, 5), typePb);
-
- Type typeX = ProtoType.fromPb(typePb);
- Assert.assertEquals(typeX, type);
- }
-
- @Test
- public void bigDecimalConv() {
- BigDecimal orig, dest;
-
- orig = new BigDecimal("-1.0");
- dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
- Assert.assertEquals(0, orig.compareTo(dest));
-
- orig = new BigDecimal("0.023");
- dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
- Assert.assertEquals(0, orig.compareTo(dest));
-
- orig = new BigDecimal("10000.52");
- dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
- Assert.assertEquals(0, orig.compareTo(dest));
- }
-}
diff --git a/table/src/test/java/tech/ydb/table/types/StructTypeTest.java b/table/src/test/java/tech/ydb/table/types/StructTypeTest.java
deleted file mode 100644
index c58074c51..000000000
--- a/table/src/test/java/tech/ydb/table/types/StructTypeTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package tech.ydb.table.types;
-
-import tech.ydb.table.values.PrimitiveType;
-import tech.ydb.table.values.StructType;
-import org.junit.Assert;
-import org.junit.Test;
-
-
-/**
- * @author Sergey Polovko
- */
-public class StructTypeTest {
-
- @Test
- public void oneMember() {
- StructType s = StructType.of("a", PrimitiveType.Text);
-
- Assert.assertEquals(1, s.getMembersCount());
- Assert.assertEquals("Struct<'a': Text>", s.toString());
-
- Assert.assertEquals("a", s.getMemberName(0));
- Assert.assertEquals(PrimitiveType.Text, s.getMemberType(0));
- Assert.assertEquals(0, s.getMemberIndex("a"));
- }
-
- @Test
- public void manyMembers() {
- // not ordered names
- StructType s = StructType.of(
- "b", PrimitiveType.Int32,
- "a", PrimitiveType.Text);
-
- Assert.assertEquals(2, s.getMembersCount());
- Assert.assertEquals("Struct<'a': Text, 'b': Int32>", s.toString());
-
- // member 'a'
- Assert.assertEquals("a", s.getMemberName(0));
- Assert.assertEquals(PrimitiveType.Text, s.getMemberType(0));
- Assert.assertEquals(0, s.getMemberIndex("a"));
-
- // member 'b'
- Assert.assertEquals("b", s.getMemberName(1));
- Assert.assertEquals(PrimitiveType.Int32, s.getMemberType(1));
- Assert.assertEquals(1, s.getMemberIndex("b"));
- }
-}
diff --git a/table/src/test/java/tech/ydb/table/values/DecimalValueTest.java b/table/src/test/java/tech/ydb/table/values/DecimalValueTest.java
index a11fbe0bb..0768d790b 100644
--- a/table/src/test/java/tech/ydb/table/values/DecimalValueTest.java
+++ b/table/src/test/java/tech/ydb/table/values/DecimalValueTest.java
@@ -8,6 +8,7 @@
import org.junit.Test;
import tech.ydb.proto.ValueProtos;
+import tech.ydb.table.values.proto.ProtoType;
import tech.ydb.table.values.proto.ProtoValue;
@@ -17,6 +18,53 @@
*/
public class DecimalValueTest {
+ @Test
+ public void contractType() {
+ DecimalType t = DecimalType.of(13, 2);
+
+ Assert.assertEquals(Type.Kind.DECIMAL, t.getKind());
+ Assert.assertEquals(13, t.getPrecision());
+ Assert.assertEquals(2, t.getScale());
+
+ Assert.assertEquals(DecimalType.of(13, 2), t);
+ Assert.assertNotEquals(DecimalType.of(11, 2), t);
+ Assert.assertNotEquals(DecimalType.of(13, 1), t);
+
+ Assert.assertEquals(DecimalType.of(13, 2).hashCode(), t.hashCode());
+ Assert.assertNotEquals(DecimalType.of(11, 2).hashCode(), t.hashCode());
+ Assert.assertNotEquals(DecimalType.of(13, 1).hashCode(), t.hashCode());
+
+ Assert.assertEquals("Decimal(13, 2)", t.toString());
+ }
+
+ @Test
+ public void protobufType() {
+ DecimalType type = DecimalType.of(10, 5);
+ ValueProtos.Type typePb = type.toPb();
+
+ Assert.assertEquals(ProtoType.getDecimal(10, 5), typePb);
+
+ Type typeX = ProtoType.fromPb(typePb);
+ Assert.assertEquals(typeX, type);
+ }
+
+ @Test
+ public void bigDecimalConv() {
+ BigDecimal orig, dest;
+
+ orig = new BigDecimal("-1.0");
+ dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
+ Assert.assertEquals(0, orig.compareTo(dest));
+
+ orig = new BigDecimal("0.023");
+ dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
+ Assert.assertEquals(0, orig.compareTo(dest));
+
+ orig = new BigDecimal("10000.52");
+ dest = DecimalType.of(22, 9).newValue(orig).toBigDecimal();
+ Assert.assertEquals(0, orig.compareTo(dest));
+ }
+
@Test
public void contract() {
DecimalType type = DecimalType.of(13, 2);
diff --git a/table/src/test/java/tech/ydb/table/values/PrimitiveValueTest.java b/table/src/test/java/tech/ydb/table/values/PrimitiveValueTest.java
index d435f0e95..8d47a0a2b 100644
--- a/table/src/test/java/tech/ydb/table/values/PrimitiveValueTest.java
+++ b/table/src/test/java/tech/ydb/table/values/PrimitiveValueTest.java
@@ -517,26 +517,52 @@ public void datetime() {
@Test
public void timestamp() {
- long seconds = 1534728225678901L;
- Instant instant = Instant.parse("2018-08-20T01:23:45.678901Z");
-
- Consumer doTest = (v) -> {
- Assert.assertEquals(PrimitiveValue.newTimestamp(seconds), v);
- Assert.assertEquals(PrimitiveValue.newTimestamp(instant), v);
- Assert.assertNotEquals(PrimitiveValue.newTimestamp(0), v);
-
- Assert.assertEquals("2018-08-20T01:23:45.678901Z", v.toString());
- Assert.assertEquals(v.getTimestamp(), instant);
-
- ValueProtos.Value vPb = v.toPb();
- Assert.assertEquals(vPb, ProtoValue.fromTimestamp(seconds));
- Assert.assertEquals(vPb, ProtoValue.fromTimestamp(instant));
-
- Assert.assertTrue(ProtoValue.fromPb(PrimitiveType.Timestamp, vPb).equals(v));
- };
-
- doTest.accept(PrimitiveValue.newTimestamp(seconds));
- doTest.accept(PrimitiveValue.newTimestamp(instant));
+ PrimitiveValue min = PrimitiveValue.newTimestamp(Instant.EPOCH);
+ Assert.assertEquals(min, PrimitiveValue.newTimestamp(0));
+ ValueProtos.Value minValue = min.toPb();
+
+ Assert.assertEquals(0, minValue.getUint32Value());
+ Assert.assertEquals(0, minValue.getUint64Value());
+ Assert.assertEquals(0, minValue.getInt32Value());
+ Assert.assertEquals(0, minValue.getInt64Value());
+ Assert.assertEquals(0, minValue.getLow128());
+ Assert.assertEquals(0, minValue.getHigh128());
+
+ PrimitiveValue max = PrimitiveValue.newTimestamp(Instant.parse("2105-12-31T23:59:59.999999Z"));
+ Assert.assertEquals(max, PrimitiveValue.newTimestamp(4291747199999999l));
+ ValueProtos.Value maxValue = max.toPb();
+
+ Assert.assertEquals(0, maxValue.getUint32Value());
+ Assert.assertEquals(4291747199999999l, maxValue.getUint64Value());
+ Assert.assertEquals(0, maxValue.getInt32Value());
+ Assert.assertEquals(0, maxValue.getInt64Value());
+ Assert.assertEquals(0, maxValue.getLow128());
+ Assert.assertEquals(0, maxValue.getHigh128());
+
+ Assert.assertEquals(
+ "microsSinceEpoch value is before minimum timestamp(1970-01-01 00:00:00.000000): -1",
+ Assert.assertThrows(IllegalArgumentException.class,
+ () -> PrimitiveValue.newTimestamp(-1)
+ ).getMessage()
+ );
+ Assert.assertEquals(
+ "Instant value is before minimum timestamp(1970-01-01 00:00:00.000000): 1969-12-31T23:59:59.999999999Z",
+ Assert.assertThrows(IllegalArgumentException.class,
+ () -> PrimitiveValue.newTimestamp(Instant.EPOCH.minusNanos(1))
+ ).getMessage()
+ );
+ Assert.assertEquals(
+ "microsSinceEpoch value is after maximum timestamp(2105-12-31 23:59:59.999999): 4291747200000000",
+ Assert.assertThrows(IllegalArgumentException.class,
+ () -> PrimitiveValue.newTimestamp(4291747200000000l)
+ ).getMessage()
+ );
+ Assert.assertEquals(
+ "Instant value is after maximum timestamp(2105-12-31 23:59:59.999999): 2106-01-01T00:00:00Z",
+ Assert.assertThrows(IllegalArgumentException.class,
+ () -> PrimitiveValue.newTimestamp(Instant.parse("2106-01-01T00:00:00.000000Z"))
+ ).getMessage()
+ );
}
@Test
diff --git a/table/src/test/java/tech/ydb/table/values/StructValueTest.java b/table/src/test/java/tech/ydb/table/values/StructValueTest.java
index 8485d5de4..862efe7dd 100644
--- a/table/src/test/java/tech/ydb/table/values/StructValueTest.java
+++ b/table/src/test/java/tech/ydb/table/values/StructValueTest.java
@@ -99,4 +99,37 @@ public void toStr() {
"c", PrimitiveValue.newText("yes"));
Assert.assertEquals("Struct[1, true, \"yes\"]", value2.toString());
}
+
+ @Test
+ public void oneMember() {
+ StructType s = StructType.of("a", PrimitiveType.Text);
+
+ Assert.assertEquals(1, s.getMembersCount());
+ Assert.assertEquals("Struct<'a': Text>", s.toString());
+
+ Assert.assertEquals("a", s.getMemberName(0));
+ Assert.assertEquals(PrimitiveType.Text, s.getMemberType(0));
+ Assert.assertEquals(0, s.getMemberIndex("a"));
+ }
+
+ @Test
+ public void manyMembers() {
+ // not ordered names
+ StructType s = StructType.of(
+ "b", PrimitiveType.Int32,
+ "a", PrimitiveType.Text);
+
+ Assert.assertEquals(2, s.getMembersCount());
+ Assert.assertEquals("Struct<'a': Text, 'b': Int32>", s.toString());
+
+ // member 'a'
+ Assert.assertEquals("a", s.getMemberName(0));
+ Assert.assertEquals(PrimitiveType.Text, s.getMemberType(0));
+ Assert.assertEquals(0, s.getMemberIndex("a"));
+
+ // member 'b'
+ Assert.assertEquals("b", s.getMemberName(1));
+ Assert.assertEquals(PrimitiveType.Int32, s.getMemberType(1));
+ Assert.assertEquals(1, s.getMemberIndex("b"));
+ }
}
diff --git a/tests/common/src/main/java/tech/ydb/test/integration/YdbEnvironment.java b/tests/common/src/main/java/tech/ydb/test/integration/YdbEnvironment.java
index 580a03767..a2b493875 100644
--- a/tests/common/src/main/java/tech/ydb/test/integration/YdbEnvironment.java
+++ b/tests/common/src/main/java/tech/ydb/test/integration/YdbEnvironment.java
@@ -9,7 +9,7 @@
* @author Aleksandr Gorshenin
*/
public class YdbEnvironment {
- private static final String YDB_DEFAULT_IMAGE = "cr.yandex/yc/yandex-docker-local-ydb:latest";
+ private static final String YDB_DEFAULT_IMAGE = "ydbplatform/local-ydb:latest";
private final Supplier ydbEndpoint = createParam("YDB_ENDPOINT", null);
private final Supplier ydbDatabase = createParam("YDB_DATABASE", null);