Skip to content

Commit 20d679f

Browse files
committed
QQL: make timestamp as timestamp(ns) by default
1 parent 9397e55 commit 20d679f

File tree

7 files changed

+44
-45
lines changed

7 files changed

+44
-45
lines changed

java/timebase/qql/src/main/java/com/epam/deltix/qsrv/hf/tickdb/lang/compiler/cg/EvalGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ private void genSymbolSelectorEval (
16211621
private void genTimestampSelectorEval(TimestampSelector e, QValue outValue) {
16221622
addTo.add(outValue.write(
16231623
e.hasNanosecondPrecision() ?
1624-
inMsg.call("getTimeStampNs") :
1624+
inMsg.call("getNanoTime") :
16251625
inMsg.call("getTimeStampMs")
16261626
));
16271627
}

java/timebase/qql/src/main/java/com/epam/deltix/qsrv/hf/tickdb/lang/compiler/sem/QQLExpressionCompiler.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ private CompiledExpression compileNamedExpression(NamedExpression e, DataType ex
498498

499499
switch (name) {
500500
case KEYWORD_TIMESTAMP:
501-
expectedType = intersectTypes(e, expectedType, StandardTypes.NULLABLE_TIMESTAMP);
501+
expectedType = intersectTypes(e, expectedType, StandardTypes.NULLABLE_TIMESTAMP_NS);
502502
break;
503503

504504
case KEYWORD_TIMESTAMPNS:
@@ -536,7 +536,7 @@ private CompiledExpression compileNamedFieldExpression(NamedFieldExpression e, D
536536

537537
switch (fieldName) {
538538
case KEYWORD_TIMESTAMP:
539-
expectedType = intersectTypes(e, expectedType, StandardTypes.NULLABLE_TIMESTAMP);
539+
expectedType = intersectTypes(e, expectedType, StandardTypes.NULLABLE_TIMESTAMP_NS);
540540
break;
541541

542542
case KEYWORD_TIMESTAMPNS:
@@ -1348,6 +1348,11 @@ private TupleConstructor createAnonymousTuple(
13481348
if (tsInit != null)
13491349
throw new DuplicateNameException(oe, name);
13501350

1351+
tsInit = e;
1352+
} else if (KEYWORD_TIMESTAMPNS.equals(name)) {
1353+
if (tsInit != null)
1354+
throw new DuplicateNameException(oe, name);
1355+
13511356
tsInit = e;
13521357
} else if (KEYWORD_SYMBOL.equals(name)) {
13531358
if (symbolInit != null)
@@ -1947,7 +1952,7 @@ private CompiledExpression compileIdentifier(Identifier id) {
19471952
return (new SymbolSelector());
19481953

19491954
if (text.equals(KEYWORD_TIMESTAMP))
1950-
return (new TimestampSelector());
1955+
return (new TimestampSelector(true));
19511956

19521957
if (text.equals(KEYWORD_TIMESTAMPNS)) {
19531958
return (new TimestampSelector(true));

java/timebase/qql/src/main/java/com/epam/deltix/qsrv/hf/tickdb/lang/compiler/sx/TimestampSelector.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public TimestampSelector() {
3636
public TimestampSelector(boolean nanosecondPrecision) {
3737
super(nanosecondPrecision ? StandardTypes.CLEAN_TIMESTAMP_NS : StandardTypes.CLEAN_TIMESTAMP);
3838
this.nanosecondPrecision = nanosecondPrecision;
39-
name = "$" + (nanosecondPrecision ? QQLCompiler.KEYWORD_TIMESTAMPNS : QQLCompiler.KEYWORD_TIMESTAMP);
39+
name = "$" + QQLCompiler.KEYWORD_TIMESTAMP;
4040
}
4141

4242
public boolean hasNanosecondPrecision() {

java/timebase/test/src/main/resources/com/epam/deltix/qqltest/1min-1h-1h-3.qsmsg.gz

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/timebase/test/src/main/resources/com/epam/deltix/qqltest/1min-1h-1h-3_v2.qsmsg.gz

Lines changed: 0 additions & 3 deletions
This file was deleted.

java/timebase/test/src/test/resources/qql/computations/111-timestamp-arithmetic.q.txt

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,16 @@ test select ['2022-08-27 23:32:00.007'd, '2022-08-27 23:33:00.007'd] + [5, 10]
6464
0: {"$type":"","symbol":"","$1":["2022-08-27T23:32:00.012Z","2022-08-27T23:33:00.017Z"]}
6565
!end
6666
test select timestamp as int64 from "1min-1h-1h-3"
67-
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1618794796646}
68-
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1618794856646}
69-
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":1618794916646}
70-
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":1618794976646}
71-
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":1618795036646}
72-
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":1618795096646}
73-
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1618795156646}
74-
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1618795216646}
75-
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":1618795276646}
76-
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1618795336646}
67+
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1618794796646000000}
68+
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1618794856646000000}
69+
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":1618794916646000000}
70+
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":1618794976646000000}
71+
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":1618795036646000000}
72+
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":1618795096646000000}
73+
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1618795156646000000}
74+
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1618795216646000000}
75+
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":1618795276646000000}
76+
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1618795336646000000}
7777
!end
7878
test select timestampField as int64 from "1min-1h-1h-3"
7979
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1617719194460}
@@ -88,28 +88,28 @@ test select timestampField as int64 from "1min-1h-1h-3"
8888
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1617580507774}
8989
!end
9090
test select timestamp - timestampField from "1min-1h-1h-3"
91-
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1075602186}
92-
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1052692663}
93-
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":468741553}
94-
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":483843079}
95-
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":131064496}
96-
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":812967685}
97-
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1416247777}
98-
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1346898466}
99-
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":211680842}
100-
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1214828872}
91+
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1075602186000000}
92+
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1052692663000000}
93+
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":468741553000000}
94+
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":483843079000000}
95+
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":131064496000000}
96+
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":812967685000000}
97+
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1416247777000000}
98+
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1346898466000000}
99+
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":211680842000000}
100+
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1214828872000000}
101101
!end
102102
test select timestamp - timestampField as int64 from "1min-1h-1h-3"
103-
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1075602186}
104-
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1052692663}
105-
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":468741553}
106-
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":483843079}
107-
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":131064496}
108-
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":812967685}
109-
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1416247777}
110-
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1346898466}
111-
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":211680842}
112-
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1214828872}
103+
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":1075602186000000}
104+
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":1052692663000000}
105+
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":468741553000000}
106+
3: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:16:16.646Z","$1":483843079000000}
107+
4: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:17:16.646Z","$1":131064496000000}
108+
5: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:18:16.646Z","$1":812967685000000}
109+
6: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:19:16.646Z","$1":1416247777000000}
110+
7: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:20:16.646Z","$1":1346898466000000}
111+
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":211680842000000}
112+
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":1214828872000000}
113113
!end
114114
test select timestampList + 10 from "1min-1h-1h-3"
115115
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":["2021-04-16T02:05:17.829Z","2021-04-15T21:29:23.737Z","2021-04-10T16:06:17.183Z","2021-04-04T17:24:27.967Z","2021-03-30T15:57:51.368Z","2021-04-04T22:55:41.560Z","2021-04-12T11:25:20.011Z","2021-04-18T13:01:06.710Z","2021-04-13T20:37:18.807Z","2021-03-31T05:53:49.283Z"]}
@@ -207,7 +207,7 @@ test select longList as array(timestamp) from "1min-1h-1h-3"
207207
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":["201496151-10-17T17:59:36.424Z","54997685-08-11T12:37:27.987Z","221283572-04-26T17:21:14.045Z","225493824-08-31T20:07:46.516Z","182182211-08-27T09:46:05.321Z","274687739-12-20T11:17:55.976Z","122133040-05-30T14:01:38.471Z","47974346-11-10T07:12:06.916Z","16910957-09-01T00:43:17.800Z","139590224-10-13T19:02:17.084Z"]}
208208
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":["22231408-02-26T18:49:05.132Z","89749862-06-30T12:45:53.714Z","39976651-03-08T06:16:28.056Z","50962470-04-09T19:39:48.674Z","267833695-02-20T16:43:53.029Z","285857472-05-30T05:23:59.844Z","254833053-12-29T10:32:42.305Z","207557890-12-19T08:36:43.666Z","284881605-12-22T15:05:24.441Z","288246588-09-19T14:39:52.507Z"]}
209209
!end
210-
test select timestamp - timestampField > 483843079 from "1min-1h-1h-3"
210+
test select timestamp - timestampField > 483843079000000 from "1min-1h-1h-3"
211211
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","$1":true}
212212
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","$1":true}
213213
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","$1":false}
@@ -219,7 +219,7 @@ test select timestamp - timestampField > 483843079 from "1min-1h-1h-3"
219219
8: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:21:16.646Z","$1":false}
220220
9: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:22:16.646Z","$1":true}
221221
!end
222-
test select intField, timestamp - timestampField as int64, timestamp - timestampField <= intField from "1min-1h-1h-3"
222+
test select intField, ((timestamp - timestampField) as int64) / 1000000, ((timestamp - timestampField) as int64) / 1000000 <= intField from "1min-1h-1h-3"
223223
0: {"$type":"","symbol":"S1","timestamp":"2021-04-19T01:13:16.646Z","intField":1187042131,"$1":1075602186,"$2":true}
224224
1: {"$type":"","symbol":"S2","timestamp":"2021-04-19T01:14:16.646Z","intField":-826078049,"$1":1052692663,"$2":false}
225225
2: {"$type":"","symbol":"S3","timestamp":"2021-04-19T01:15:16.646Z","intField":583793597,"$1":468741553,"$2":true}

java/timebase/test/src/test/resources/qql/select/102-names.q.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ test select sequence as "field-Name" from alltypes
1818
#
1919
# Just timestamp
2020
#
21-
test select timestamp from alltypes
21+
test select timestamp as timestamp(ms) from alltypes
2222
!shellmatch
23-
>_,TIMESTAMP,SYMBOL,TYPE,$TIMESTAMP
23+
>_,TIMESTAMP,SYMBOL,TYPE,$1
2424
0,2011-01-01 00:00:00,S0,2011-01-01
2525
1,2011-01-01 00:00:00.001,S1,2011-01-01 00:00:00.001
2626
!end

0 commit comments

Comments
 (0)