Skip to content

Commit 446bd2d

Browse files
feat: supported date32, datetime64, timestamp64, interval64 (#345)
1 parent 93a87b0 commit 446bd2d

File tree

10 files changed

+584
-172
lines changed

10 files changed

+584
-172
lines changed

core/src/main/java/tech/ydb/core/impl/pool/EndpointPool.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public void pessimizeEndpoint(EndpointRecord endpoint) {
148148
long bestPriority = records.get(0).priority;
149149
int newBestCount = 0;
150150
int newPessimizedCount = 0;
151-
for (PriorityEndpoint record: records) {
151+
for (PriorityEndpoint record : records) {
152152
if (record.getPriority() == bestPriority) {
153153
newBestCount++;
154154
}

table/pom.xml

+16
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,20 @@
4141
<scope>test</scope>
4242
</dependency>
4343
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<groupId>org.apache.maven.plugins</groupId>
49+
<artifactId>maven-surefire-plugin</artifactId>
50+
<version>3.1.0</version>
51+
<configuration>
52+
<environmentVariables>
53+
<TESTCONTAINERS_REUSE_ENABLE>true</TESTCONTAINERS_REUSE_ENABLE>
54+
<YDB_DOCKER_IMAGE>ydbplatform/local-ydb:trunk</YDB_DOCKER_IMAGE>
55+
</environmentVariables>
56+
</configuration>
57+
</plugin>
58+
</plugins>
59+
</build>
4460
</project>

table/src/main/java/tech/ydb/table/result/PrimitiveReader.java

+8
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public interface PrimitiveReader {
4646

4747
Duration getInterval();
4848

49+
LocalDate getDate32();
50+
51+
LocalDateTime getDatetime64();
52+
53+
Instant getTimestamp64();
54+
55+
Duration getInterval64();
56+
4957
ZonedDateTime getTzDate();
5058

5159
ZonedDateTime getTzDatetime();

table/src/main/java/tech/ydb/table/result/impl/AbstractValueReader.java

+18
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,24 @@ public Duration getInterval() {
116116
throw error("getInterval");
117117
}
118118

119+
@Override
120+
public LocalDate getDate32() {
121+
throw error("getDate32");
122+
}
123+
124+
public LocalDateTime getDatetime64() {
125+
throw error("getDatetime64");
126+
}
127+
128+
@Override
129+
public Instant getTimestamp64() {
130+
throw error("getTimestamp64");
131+
}
132+
133+
public Duration getInterval64() {
134+
throw error("getInterval64");
135+
}
136+
119137
@Override
120138
public ZonedDateTime getTzDate() {
121139
throw error("getTzDate");

table/src/main/java/tech/ydb/table/result/impl/ProtoPrimitiveValueReader.java

+24
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,30 @@ public Duration getInterval() {
139139
return ProtoValue.toInterval(value);
140140
}
141141

142+
@Override
143+
public LocalDate getDate32() {
144+
checkPrimitive(PrimitiveTypeId.DATE32);
145+
return ProtoValue.toDate32(value);
146+
}
147+
148+
@Override
149+
public LocalDateTime getDatetime64() {
150+
checkPrimitive(PrimitiveTypeId.DATETIME64);
151+
return ProtoValue.toDatetime64(value);
152+
}
153+
154+
@Override
155+
public Instant getTimestamp64() {
156+
checkPrimitive(PrimitiveTypeId.TIMESTAMP64);
157+
return ProtoValue.toTimestamp64(value);
158+
}
159+
160+
@Override
161+
public Duration getInterval64() {
162+
checkPrimitive(PrimitiveTypeId.INTERVAL64);
163+
return ProtoValue.toInterval64(value);
164+
}
165+
142166
@Override
143167
public ZonedDateTime getTzDate() {
144168
checkPrimitive(PrimitiveTypeId.TZ_DATE);

table/src/main/java/tech/ydb/table/values/PrimitiveType.java

+14-6
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,20 @@ public enum PrimitiveType implements Type {
5858
/** JSON in an indexed binary representation. Doesn't support matching, can't be used in the primary key */
5959
JsonDocument(ProtoType.getJsonDocument()),
6060
/** A binary representation of a real number with an accuracy of up to 38 digits.
61-
* Acceptable values: positive numbers from 1×10-130 up to 1×10126–1,
62-
* negative numbers from -1×10126–1 to -1×10-130, and 0.
63-
* Compatible with the Number type in AWS DynamoDB.
64-
* It's not recommended for ydb-native applications.
65-
*/
66-
DyNumber(ProtoType.getDyNumber());
61+
* Acceptable values: positive numbers from 1×10-130 up to 1×10126–1,
62+
* negative numbers from -1×10126–1 to -1×10-130, and 0.
63+
* Compatible with the Number type in AWS DynamoDB.
64+
* It's not recommended for ydb-native applications.
65+
*/
66+
DyNumber(ProtoType.getDyNumber()),
67+
68+
Date32(ProtoType.getDate32()),
69+
70+
Datetime64(ProtoType.getDatetime64()),
71+
72+
Timestamp64(ProtoType.getTimestamp64()),
73+
74+
Interval64(ProtoType.getInterval64());
6775

6876
private final ValueProtos.Type pbType;
6977

0 commit comments

Comments
 (0)