Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
6c53da29
Q
Questdb
项目概览
jobily
/
Questdb
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
Questdb
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
6c53da29
编写于
11月 05, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GRIFFIN: fixed timestamp(field) clause behaviour in sub-queries
上级
03e56745
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
242 addition
and
40 deletion
+242
-40
core/src/main/java/io/questdb/cutlass/text/CairoTextWriter.java
...rc/main/java/io/questdb/cutlass/text/CairoTextWriter.java
+7
-3
core/src/main/java/io/questdb/cutlass/text/TextLexer.java
core/src/main/java/io/questdb/cutlass/text/TextLexer.java
+12
-12
core/src/main/java/io/questdb/griffin/SqlCodeGenerator.java
core/src/main/java/io/questdb/griffin/SqlCodeGenerator.java
+16
-15
core/src/main/java/io/questdb/griffin/SqlParser.java
core/src/main/java/io/questdb/griffin/SqlParser.java
+1
-1
core/src/main/java/io/questdb/griffin/model/QueryModel.java
core/src/main/java/io/questdb/griffin/model/QueryModel.java
+3
-1
core/src/main/java/io/questdb/std/Numbers.java
core/src/main/java/io/questdb/std/Numbers.java
+11
-8
core/src/test/java/io/questdb/griffin/JoinTest.java
core/src/test/java/io/questdb/griffin/JoinTest.java
+192
-0
未找到文件。
core/src/main/java/io/questdb/cutlass/text/CairoTextWriter.java
浏览文件 @
6c53da29
...
...
@@ -135,9 +135,7 @@ public class CairoTextWriter implements TextLexer.Listener, Closeable, Mutable {
try
{
types
.
getQuick
(
i
).
write
(
w
,
i
,
dbcs
);
}
catch
(
Exception
ignore
)
{
LogRecord
logRecord
=
LOG
.
error
().
$
(
"type syntax [type="
).
$
(
ColumnType
.
nameOf
(
types
.
getQuick
(
i
).
getType
())).
$
(
"]\n\t"
);
logRecord
.
$
(
'['
).
$
(
line
).
$
(
':'
).
$
(
i
).
$
(
"] -> "
).
$
(
dbcs
).
$
();
columnErrorCounts
.
increment
(
i
);
logError
(
line
,
i
,
dbcs
);
switch
(
atomicity
)
{
case
Atomicity
.
SKIP_ALL
:
writer
.
rollback
();
...
...
@@ -154,6 +152,12 @@ public class CairoTextWriter implements TextLexer.Listener, Closeable, Mutable {
w
.
append
();
}
private
void
logError
(
long
line
,
int
i
,
DirectByteCharSequence
dbcs
)
{
LogRecord
logRecord
=
LOG
.
error
().
$
(
"type syntax [type="
).
$
(
ColumnType
.
nameOf
(
types
.
getQuick
(
i
).
getType
())).
$
(
"]\n\t"
);
logRecord
.
$
(
'['
).
$
(
line
).
$
(
':'
).
$
(
i
).
$
(
"] -> "
).
$
(
dbcs
).
$
();
columnErrorCounts
.
increment
(
i
);
}
private
void
createTable
(
ObjList
<
CharSequence
>
names
,
ObjList
<
TypeAdapter
>
detectedTypes
,
...
...
core/src/main/java/io/questdb/cutlass/text/TextLexer.java
浏览文件 @
6c53da29
...
...
@@ -41,18 +41,9 @@ public class TextLexer implements Closeable, Mutable {
private
final
ObjList
<
DirectByteCharSequence
>
fields
=
new
ObjList
<>();
private
final
ObjectPool
<
DirectByteCharSequence
>
csPool
;
private
final
TextMetadataDetector
metadataDetector
;
private
CharSequence
tableName
;
private
final
int
lineRollBufLimit
;
private
boolean
ignoreEolOnce
;
private
byte
columnDelimiter
;
private
boolean
inQuote
;
private
boolean
delayedOutQuote
;
private
boolean
eol
;
private
int
fieldIndex
;
private
int
fieldMax
=
-
1
;
private
long
fieldLo
;
private
long
fieldHi
;
private
long
lineCount
;
private
boolean
useLineRollBuf
=
false
;
private
long
lineRollBufCur
;
private
Listener
textLexerListener
;
private
long
lastLineStart
;
...
...
@@ -61,9 +52,18 @@ public class TextLexer implements Closeable, Mutable {
private
boolean
header
;
private
long
lastQuotePos
=
-
1
;
private
long
errorCount
=
0
;
private
boolean
rollBufferUnusable
=
false
;
private
CharSequence
tableName
;
private
int
lineCountLimit
;
private
int
fieldMax
=
-
1
;
private
int
fieldIndex
;
private
long
lineCount
;
private
boolean
eol
;
private
boolean
useLineRollBuf
=
false
;
private
boolean
rollBufferUnusable
=
false
;
private
byte
columnDelimiter
;
private
boolean
inQuote
;
private
boolean
delayedOutQuote
;
private
long
fieldLo
;
private
long
fieldHi
;
public
TextLexer
(
TextConfiguration
textConfiguration
,
TypeManager
typeManager
)
{
this
.
metadataDetector
=
new
TextMetadataDetector
(
typeManager
,
textConfiguration
);
...
...
core/src/main/java/io/questdb/griffin/SqlCodeGenerator.java
浏览文件 @
6c53da29
...
...
@@ -72,7 +72,7 @@ public class SqlCodeGenerator {
this
.
recordComparatorCompiler
=
new
RecordComparatorCompiler
(
asm
);
}
private
RecordMetadata
copyMetadata
(
RecordMetadata
that
)
{
private
Generic
RecordMetadata
copyMetadata
(
RecordMetadata
that
)
{
// todo: this metadata is immutable. Ideally we shouldn't be creating metadata for the same table over and over
return
GenericRecordMetadata
.
copyOf
(
that
);
}
...
...
@@ -1238,7 +1238,16 @@ public class SqlCodeGenerator {
model
.
getTableName
().
token
,
model
.
getTableVersion
())
)
{
final
RecordMetadata
metadata
=
reader
.
getMetadata
();
final
GenericRecordMetadata
metadata
=
copyMetadata
(
reader
.
getMetadata
());
final
int
timestampIndex
;
final
ExpressionNode
timestamp
=
model
.
getTimestamp
();
if
(
timestamp
!=
null
)
{
timestampIndex
=
metadata
.
getColumnIndexQuiet
(
timestamp
.
token
);
metadata
.
setTimestampIndex
(
timestampIndex
);
}
else
{
timestampIndex
=
-
1
;
}
final
int
latestByIndex
;
if
(
latestBy
!=
null
)
{
...
...
@@ -1256,19 +1265,11 @@ public class SqlCodeGenerator {
if
(
whereClause
!=
null
)
{
final
int
timestampIndex
;
final
ExpressionNode
timestamp
=
model
.
getTimestamp
();
if
(
timestamp
!=
null
)
{
timestampIndex
=
metadata
.
getColumnIndexQuiet
(
timestamp
.
token
);
}
else
{
timestampIndex
=
-
1
;
}
final
IntrinsicModel
intrinsicModel
=
filterAnalyser
.
extract
(
model
,
whereClause
,
metadata
,
latestBy
!=
null
?
latestBy
.
token
:
null
,
timestampIndex
);
if
(
intrinsicModel
.
intrinsicValue
==
IntrinsicModel
.
FALSE
)
{
return
new
EmptyTableRecordCursorFactory
(
copyMetadata
(
metadata
)
);
return
new
EmptyTableRecordCursorFactory
(
metadata
);
}
Function
filter
;
...
...
@@ -1286,7 +1287,7 @@ public class SqlCodeGenerator {
// filter is constant "true", do not evaluate for every row
filter
=
null
;
}
else
{
return
new
EmptyTableRecordCursorFactory
(
copyMetadata
(
metadata
)
);
return
new
EmptyTableRecordCursorFactory
(
metadata
);
}
}
}
else
{
...
...
@@ -1353,7 +1354,7 @@ public class SqlCodeGenerator {
rcf
=
new
SymbolIndexFilteredRowCursorFactory
(
keyColumnIndex
,
symbolKey
,
filter
,
true
);
}
}
return
new
DataFrameRecordCursorFactory
(
copyMetadata
(
metadata
)
,
dfcFactory
,
rcf
,
filter
);
return
new
DataFrameRecordCursorFactory
(
metadata
,
dfcFactory
,
rcf
,
filter
);
}
return
new
FilterOnValuesRecordCursorFactory
(
...
...
@@ -1368,9 +1369,9 @@ public class SqlCodeGenerator {
if
(
filter
!=
null
)
{
// filter lifecycle is managed by top level
return
new
FilteredRecordCursorFactory
(
new
DataFrameRecordCursorFactory
(
copyMetadata
(
metadata
)
,
dfcFactory
,
new
DataFrameRowCursorFactory
(),
null
),
filter
);
return
new
FilteredRecordCursorFactory
(
new
DataFrameRecordCursorFactory
(
metadata
,
dfcFactory
,
new
DataFrameRowCursorFactory
(),
null
),
filter
);
}
return
new
DataFrameRecordCursorFactory
(
copyMetadata
(
metadata
)
,
dfcFactory
,
new
DataFrameRowCursorFactory
(),
filter
);
return
new
DataFrameRecordCursorFactory
(
metadata
,
dfcFactory
,
new
DataFrameRowCursorFactory
(),
filter
);
}
// no where clause
...
...
core/src/main/java/io/questdb/griffin/SqlParser.java
浏览文件 @
6c53da29
...
...
@@ -1115,7 +1115,7 @@ public final class SqlParser {
if
(
Chars
.
equalsLowerCaseAsciiNc
(
tok
,
"timestamp"
))
{
expectTok
(
lexer
,
'('
);
final
ExpressionNode
result
=
expectLiteral
(
lexer
);
expectTok
(
lexer
,
')'
);
expectTok
(
SqlUtil
.
fetchNext
(
lexer
),
lexer
.
lastTokenPosition
()
,
')'
);
return
result
;
}
return
null
;
...
...
core/src/main/java/io/questdb/griffin/model/QueryModel.java
浏览文件 @
6c53da29
...
...
@@ -275,7 +275,9 @@ public class QueryModel implements Mutable, ExecutionModel, AliasTranslator, Sin
final
CharSequence
name
=
columnNames
.
getQuick
(
i
);
this
.
aliasToColumnMap
.
put
(
name
,
name
);
}
if
(
this
.
timestamp
==
null
&&
other
.
timestamp
!=
null
)
{
// do not copy timestamp from nested model to join models
// join type will determine timestamp
if
(
this
.
timestamp
==
null
&&
other
.
timestamp
!=
null
&&
joinModels
.
size
()
<
2
)
{
this
.
timestamp
=
other
.
timestamp
;
}
}
...
...
core/src/main/java/io/questdb/std/Numbers.java
浏览文件 @
6c53da29
...
...
@@ -36,11 +36,13 @@ public final class Numbers {
public
static
final
char
[]
hexDigits
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'a'
,
'b'
,
'c'
,
'd'
,
'e'
,
'f'
};
public
final
static
int
[]
hexNumbers
;
private
static
final
long
[]
pow10
;
private
static
final
long
LONG_OVERFLOW_MAX
=
Long
.
MAX_VALUE
/
10
;
private
static
final
long
LONG_OVERFLOW_MAX
=
Long
.
MAX_VALUE
/
10
+
1
;
private
static
final
long
INT_OVERFLOW_MAX
=
Integer
.
MAX_VALUE
/
10
;
private
final
static
String
NaN
=
"NaN"
;
private
static
final
String
INFINITY
=
"Infinity"
;
private
static
final
double
[]
pow10d
=
new
double
[]{
1
,
1
E1
,
1
E2
,
1
E3
,
1
E4
,
1
E5
,
1
E6
,
1
E7
,
1
E8
,
1
E9
,
1
E10
,
1
E11
,
1
E12
,
1
E13
,
1
E14
,
1
E15
,
1
E16
,
1
E17
,
1
E18
,
1
E19
,
1
E20
,
1
E21
,
1
E22
,
1
E23
,
1
E24
,
1
E25
,
1
E26
,
1
E27
,
1
E28
,
1
E29
,
1
E30
,
1
E31
,
1
E32
,
1
E33
,
1
E34
,
1
E35
,
1
E36
,
1
E37
,
1
E38
,
1
E39
,
1
E40
,
1
E41
,
1
E42
,
1
E43
,
1
E44
,
1
E45
,
1
E46
,
1
E47
,
1
E48
,
1
E49
,
1
E50
,
1
E51
,
1
E52
,
1
E53
,
1
E54
,
1
E55
,
1
E56
,
1
E57
,
1
E58
,
1
E59
,
1
E60
,
1
E61
,
1
E62
,
1
E63
,
1
E64
,
1
E65
,
1
E66
,
1
E67
,
1
E68
,
1
E69
,
1
E70
,
1
E71
,
1
E72
,
1
E73
,
1
E74
,
1
E75
,
1
E76
,
1
E77
,
1
E78
,
1
E79
,
1
E80
,
1
E81
,
1
E82
,
1
E83
,
1
E84
,
1
E85
,
1
E86
,
1
E87
,
1
E88
,
1
E89
,
1
E90
,
1
E91
,
1
E92
,
1
E93
,
1
E94
,
1
E95
,
1
E96
,
1
E97
,
1
E98
,
1
E99
,
1
E100
,
1
E101
,
1
E102
,
1
E103
,
1
E104
,
1
E105
,
1
E106
,
1
E107
,
1
E108
,
1
E109
,
1
E110
,
1
E111
,
1
E112
,
1
E113
,
1
E114
,
1
E115
,
1
E116
,
1
E117
,
1
E118
,
1
E119
,
1
E120
,
1
E121
,
1
E122
,
1
E123
,
1
E124
,
1
E125
,
1
E126
,
1
E127
,
1
E128
,
1
E129
,
1
E130
,
1
E131
,
1
E132
,
1
E133
,
1
E134
,
1
E135
,
1
E136
,
1
E137
,
1
E138
,
1
E139
,
1
E140
,
1
E141
,
1
E142
,
1
E143
,
1
E144
,
1
E145
,
1
E146
,
1
E147
,
1
E148
,
1
E149
,
1
E150
,
1
E151
,
1
E152
,
1
E153
,
1
E154
,
1
E155
,
1
E156
,
1
E157
,
1
E158
,
1
E159
,
1
E160
,
1
E161
,
1
E162
,
1
E163
,
1
E164
,
1
E165
,
1
E166
,
1
E167
,
1
E168
,
1
E169
,
1
E170
,
1
E171
,
1
E172
,
1
E173
,
1
E174
,
1
E175
,
1
E176
,
1
E177
,
1
E178
,
1
E179
,
1
E180
,
1
E181
,
1
E182
,
1
E183
,
1
E184
,
1
E185
,
1
E186
,
1
E187
,
1
E188
,
1
E189
,
1
E190
,
1
E191
,
1
E192
,
1
E193
,
1
E194
,
1
E195
,
1
E196
,
1
E197
,
1
E198
,
1
E199
,
1
E200
,
1
E201
,
1
E202
,
1
E203
,
1
E204
,
1
E205
,
1
E206
,
1
E207
,
1
E208
,
1
E209
,
1
E210
,
1
E211
,
1
E212
,
1
E213
,
1
E214
,
1
E215
,
1
E216
,
1
E217
,
1
E218
,
1
E219
,
1
E220
,
1
E221
,
1
E222
,
1
E223
,
1
E224
,
1
E225
,
1
E226
,
1
E227
,
1
E228
,
1
E229
,
1
E230
,
1
E231
,
1
E232
,
1
E233
,
1
E234
,
1
E235
,
1
E236
,
1
E237
,
1
E238
,
1
E239
,
1
E240
,
1
E241
,
1
E242
,
1
E243
,
1
E244
,
1
E245
,
1
E246
,
1
E247
,
1
E248
,
1
E249
,
1
E250
,
1
E251
,
1
E252
,
1
E253
,
1
E254
,
1
E255
,
1
E256
,
1
E257
,
1
E258
,
1
E259
,
1
E260
,
1
E261
,
1
E262
,
1
E263
,
1
E264
,
1
E265
,
1
E266
,
1
E267
,
1
E268
,
1
E269
,
1
E270
,
1
E271
,
1
E272
,
1
E273
,
1
E274
,
1
E275
,
1
E276
,
1
E277
,
1
E278
,
1
E279
,
1
E280
,
1
E281
,
1
E282
,
1
E283
,
1
E284
,
1
E285
,
1
E286
,
1
E287
,
1
E288
,
1
E289
,
1
E290
,
1
E291
,
1
E292
,
1
E293
,
1
E294
,
1
E295
,
1
E296
,
1
E297
,
1
E298
,
1
E299
,
1
E300
,
1
E301
,
1
E302
,
1
E303
,
1
E304
,
1
E305
,
1
E306
,
1
E307
,
1
E308
};
private
static
final
double
[]
pow10dNeg
=
new
double
[]{
1
,
1
E
-
1
,
1
E
-
2
,
1
E
-
3
,
1
E
-
4
,
1
E
-
5
,
1
E
-
6
,
1
E
-
7
,
1
E
-
8
,
1
E
-
9
,
1
E
-
10
,
1
E
-
11
,
1
E
-
12
,
1
E
-
13
,
1
E
-
14
,
1
E
-
15
,
1
E
-
16
,
1
E
-
17
,
1
E
-
18
,
1
E
-
19
,
1
E
-
20
,
1
E
-
21
,
1
E
-
22
,
1
E
-
23
,
1
E
-
24
,
1
E
-
25
,
1
E
-
26
,
1
E
-
27
,
1
E
-
28
,
1
E
-
29
,
1
E
-
30
,
1
E
-
31
,
1
E
-
32
,
1
E
-
33
,
1
E
-
34
,
1
E
-
35
,
1
E
-
36
,
1
E
-
37
,
1
E
-
38
,
1
E
-
39
,
1
E
-
40
,
1
E
-
41
,
1
E
-
42
,
1
E
-
43
,
1
E
-
44
,
1
E
-
45
,
1
E
-
46
,
1
E
-
47
,
1
E
-
48
,
1
E
-
49
,
1
E
-
50
,
1
E
-
51
,
1
E
-
52
,
1
E
-
53
,
1
E
-
54
,
1
E
-
55
,
1
E
-
56
,
1
E
-
57
,
1
E
-
58
,
1
E
-
59
,
1
E
-
60
,
1
E
-
61
,
1
E
-
62
,
1
E
-
63
,
1
E
-
64
,
1
E
-
65
,
1
E
-
66
,
1
E
-
67
,
1
E
-
68
,
1
E
-
69
,
1
E
-
70
,
1
E
-
71
,
1
E
-
72
,
1
E
-
73
,
1
E
-
74
,
1
E
-
75
,
1
E
-
76
,
1
E
-
77
,
1
E
-
78
,
1
E
-
79
,
1
E
-
80
,
1
E
-
81
,
1
E
-
82
,
1
E
-
83
,
1
E
-
84
,
1
E
-
85
,
1
E
-
86
,
1
E
-
87
,
1
E
-
88
,
1
E
-
89
,
1
E
-
90
,
1
E
-
91
,
1
E
-
92
,
1
E
-
93
,
1
E
-
94
,
1
E
-
95
,
1
E
-
96
,
1
E
-
97
,
1
E
-
98
,
1
E
-
99
,
1
E
-
100
,
1
E
-
101
,
1
E
-
102
,
1
E
-
103
,
1
E
-
104
,
1
E
-
105
,
1
E
-
106
,
1
E
-
107
,
1
E
-
108
,
1
E
-
109
,
1
E
-
110
,
1
E
-
111
,
1
E
-
112
,
1
E
-
113
,
1
E
-
114
,
1
E
-
115
,
1
E
-
116
,
1
E
-
117
,
1
E
-
118
,
1
E
-
119
,
1
E
-
120
,
1
E
-
121
,
1
E
-
122
,
1
E
-
123
,
1
E
-
124
,
1
E
-
125
,
1
E
-
126
,
1
E
-
127
,
1
E
-
128
,
1
E
-
129
,
1
E
-
130
,
1
E
-
131
,
1
E
-
132
,
1
E
-
133
,
1
E
-
134
,
1
E
-
135
,
1
E
-
136
,
1
E
-
137
,
1
E
-
138
,
1
E
-
139
,
1
E
-
140
,
1
E
-
141
,
1
E
-
142
,
1
E
-
143
,
1
E
-
144
,
1
E
-
145
,
1
E
-
146
,
1
E
-
147
,
1
E
-
148
,
1
E
-
149
,
1
E
-
150
,
1
E
-
151
,
1
E
-
152
,
1
E
-
153
,
1
E
-
154
,
1
E
-
155
,
1
E
-
156
,
1
E
-
157
,
1
E
-
158
,
1
E
-
159
,
1
E
-
160
,
1
E
-
161
,
1
E
-
162
,
1
E
-
163
,
1
E
-
164
,
1
E
-
165
,
1
E
-
166
,
1
E
-
167
,
1
E
-
168
,
1
E
-
169
,
1
E
-
170
,
1
E
-
171
,
1
E
-
172
,
1
E
-
173
,
1
E
-
174
,
1
E
-
175
,
1
E
-
176
,
1
E
-
177
,
1
E
-
178
,
1
E
-
179
,
1
E
-
180
,
1
E
-
181
,
1
E
-
182
,
1
E
-
183
,
1
E
-
184
,
1
E
-
185
,
1
E
-
186
,
1
E
-
187
,
1
E
-
188
,
1
E
-
189
,
1
E
-
190
,
1
E
-
191
,
1
E
-
192
,
1
E
-
193
,
1
E
-
194
,
1
E
-
195
,
1
E
-
196
,
1
E
-
197
,
1
E
-
198
,
1
E
-
199
,
1
E
-
200
,
1
E
-
201
,
1
E
-
202
,
1
E
-
203
,
1
E
-
204
,
1
E
-
205
,
1
E
-
206
,
1
E
-
207
,
1
E
-
208
,
1
E
-
209
,
1
E
-
210
,
1
E
-
211
,
1
E
-
212
,
1
E
-
213
,
1
E
-
214
,
1
E
-
215
,
1
E
-
216
,
1
E
-
217
,
1
E
-
218
,
1
E
-
219
,
1
E
-
220
,
1
E
-
221
,
1
E
-
222
,
1
E
-
223
,
1
E
-
224
,
1
E
-
225
,
1
E
-
226
,
1
E
-
227
,
1
E
-
228
,
1
E
-
229
,
1
E
-
230
,
1
E
-
231
,
1
E
-
232
,
1
E
-
233
,
1
E
-
234
,
1
E
-
235
,
1
E
-
236
,
1
E
-
237
,
1
E
-
238
,
1
E
-
239
,
1
E
-
240
,
1
E
-
241
,
1
E
-
242
,
1
E
-
243
,
1
E
-
244
,
1
E
-
245
,
1
E
-
246
,
1
E
-
247
,
1
E
-
248
,
1
E
-
249
,
1
E
-
250
,
1
E
-
251
,
1
E
-
252
,
1
E
-
253
,
1
E
-
254
,
1
E
-
255
,
1
E
-
256
,
1
E
-
257
,
1
E
-
258
,
1
E
-
259
,
1
E
-
260
,
1
E
-
261
,
1
E
-
262
,
1
E
-
263
,
1
E
-
264
,
1
E
-
265
,
1
E
-
266
,
1
E
-
267
,
1
E
-
268
,
1
E
-
269
,
1
E
-
270
,
1
E
-
271
,
1
E
-
272
,
1
E
-
273
,
1
E
-
274
,
1
E
-
275
,
1
E
-
276
,
1
E
-
277
,
1
E
-
278
,
1
E
-
279
,
1
E
-
280
,
1
E
-
281
,
1
E
-
282
,
1
E
-
283
,
1
E
-
284
,
1
E
-
285
,
1
E
-
286
,
1
E
-
287
,
1
E
-
288
,
1
E
-
289
,
1
E
-
290
,
1
E
-
291
,
1
E
-
292
,
1
E
-
293
,
1
E
-
294
,
1
E
-
295
,
1
E
-
296
,
1
E
-
297
,
1
E
-
298
,
1
E
-
299
,
1
E
-
300
,
1
E
-
301
,
1
E
-
302
,
1
E
-
303
,
1
E
-
304
,
1
E
-
305
,
1
E
-
306
,
1
E
-
307
,
1
E
-
308
};
private
static
final
float
[]
pow10f
=
new
float
[]{
1
,
1
E1f
,
1
E2f
,
1
E3f
,
1
E4f
,
1
E5f
,
1
E6f
,
1
E7f
,
1
E8f
,
1
E9f
,
1
E10f
,
1
E11f
,
1
E12f
,
1
E13f
,
1
E14f
,
1
E15f
,
1
E16f
,
1
E17f
,
1
E18f
,
1
E19f
,
1
E20f
,
1
E21f
,
1
E22f
,
1
E23f
,
1
E24f
,
1
E25f
,
1
E26f
,
1
E27f
,
1
E28f
,
1
E29f
,
1
E30f
,
1
E31f
,
1
E32f
,
1
E33f
,
1
E34f
,
1
E35f
,
1
E36f
,
1
E37f
,
1
E38f
};
private
final
static
int
pow10max
;
private
static
final
LongHexAppender
[]
longHexAppender
=
new
LongHexAppender
[
Long
.
SIZE
+
1
];
...
...
@@ -942,16 +944,17 @@ public final class Numbers {
}
boolean
negative
=
sequence
.
charAt
(
0
)
==
'-'
;
int
i
=
0
;
int
i
;
if
(
negative
)
{
i
++;
i
=
1
;
}
else
{
i
=
0
;
}
if
(
i
>=
lim
)
{
throw
NumericException
.
INSTANCE
;
}
switch
(
sequence
.
charAt
(
i
))
{
case
'N'
:
return
parseConst
(
sequence
,
i
,
lim
,
NaN
,
Double
.
NaN
);
...
...
@@ -967,7 +970,7 @@ public final class Numbers {
int
exp
=
0
;
out:
for
(;
i
<
lim
;
i
++)
{
int
c
=
sequence
.
charAt
(
i
);
final
int
c
=
sequence
.
charAt
(
i
);
switch
(
c
)
{
case
'.'
:
dp
=
i
;
...
...
@@ -993,7 +996,7 @@ public final class Numbers {
throw
NumericException
.
INSTANCE
;
}
if
(
val
<
=
LONG_OVERFLOW_MAX
)
{
if
(
val
<
LONG_OVERFLOW_MAX
)
{
// val * 10 + (c - '0')
val
=
(
val
<<
3
)
+
(
val
<<
1
)
+
(
c
-
'0'
);
}
else
if
(
dpe
==
lim
)
{
...
...
@@ -1011,10 +1014,10 @@ public final class Numbers {
exp
=
-
308
;
}
if
(
exp
>
0
)
{
if
(
exp
>
-
1
)
{
return
(
negative
?
-
val
:
val
)
*
pow10d
[
exp
];
}
else
{
return
(
negative
?
-
val
:
val
)
/
pow10d
[-
exp
];
return
(
negative
?
-
val
:
val
)
*
pow10dNeg
[-
exp
];
}
}
...
...
core/src/test/java/io/questdb/griffin/JoinTest.java
浏览文件 @
6c53da29
...
...
@@ -442,6 +442,198 @@ public class JoinTest extends AbstractGriffinTest {
});
}
@Test
public
void
testAsOfJoinNoSelect
()
throws
Exception
{
TestUtils
.
assertMemoryLeak
(()
->
{
try
{
final
String
query
=
"x asof join y on y.sym2 = x.sym"
;
final
String
expected
=
"i\tsym\tamt\ttimestamp\ti1\tsym2\tprice\ttimestamp1\n"
+
"1\tmsft\t22.463000000000\t2018-01-01T00:12:00.000000Z\tNaN\t\tNaN\t\n"
+
"2\tgoogl\t29.920000000000\t2018-01-01T00:24:00.000000Z\t12\tgoogl\t0.885000000000\t2018-01-01T00:24:00.000000Z\n"
+
"3\tmsft\t65.086000000000\t2018-01-01T00:36:00.000000Z\t18\tmsft\t0.566000000000\t2018-01-01T00:36:00.000000Z\n"
+
"4\tibm\t98.563000000000\t2018-01-01T00:48:00.000000Z\t17\tibm\t0.405000000000\t2018-01-01T00:34:00.000000Z\n"
+
"5\tmsft\t50.938000000000\t2018-01-01T01:00:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"6\tibm\t76.110000000000\t2018-01-01T01:12:00.000000Z\t28\tibm\t0.954000000000\t2018-01-01T00:56:00.000000Z\n"
+
"7\tmsft\t55.992000000000\t2018-01-01T01:24:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"8\tibm\t23.905000000000\t2018-01-01T01:36:00.000000Z\t28\tibm\t0.954000000000\t2018-01-01T00:56:00.000000Z\n"
+
"9\tgoogl\t67.786000000000\t2018-01-01T01:48:00.000000Z\t30\tgoogl\t0.198000000000\t2018-01-01T01:00:00.000000Z\n"
+
"10\tgoogl\t38.540000000000\t2018-01-01T02:00:00.000000Z\t30\tgoogl\t0.198000000000\t2018-01-01T01:00:00.000000Z\n"
;
compiler
.
compile
(
"create table x as ("
+
"select"
+
" to_int(x) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym,"
+
" round(rnd_double(0)*100, 3) amt,"
+
" to_timestamp('2018-01', 'yyyy-MM') + x * 720000000 timestamp"
+
" from long_sequence(10)"
+
") timestamp (timestamp)"
);
compiler
.
compile
(
"create table y as ("
+
"select to_int(x) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym2,"
+
" round(rnd_double(0), 3) price,"
+
" to_timestamp('2018-01', 'yyyy-MM') + x * 120000000 timestamp"
+
" from long_sequence(30)"
+
") timestamp(timestamp)"
);
assertQueryAndCache
(
expected
,
query
,
"timestamp"
);
compiler
.
compile
(
"insert into x select * from ("
+
"select"
+
" to_int(x + 10) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym,"
+
" round(rnd_double(0)*100, 3) amt,"
+
" to_timestamp('2018-01', 'yyyy-MM') + (x + 10) * 720000000 timestamp"
+
" from long_sequence(10)"
+
") timestamp(timestamp)"
);
compiler
.
compile
(
"insert into y select * from ("
+
"select"
+
" to_int(x + 30) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym2,"
+
" round(rnd_double(0), 3) price,"
+
" to_timestamp('2018-01', 'yyyy-MM') + (x + 30) * 120000000 timestamp"
+
" from long_sequence(30)"
+
") timestamp(timestamp)"
);
assertQuery
(
"i\tsym\tamt\ttimestamp\ti1\tsym2\tprice\ttimestamp1\n"
+
"1\tmsft\t22.463000000000\t2018-01-01T00:12:00.000000Z\tNaN\t\tNaN\t\n"
+
"2\tgoogl\t29.920000000000\t2018-01-01T00:24:00.000000Z\t12\tgoogl\t0.885000000000\t2018-01-01T00:24:00.000000Z\n"
+
"3\tmsft\t65.086000000000\t2018-01-01T00:36:00.000000Z\t18\tmsft\t0.566000000000\t2018-01-01T00:36:00.000000Z\n"
+
"4\tibm\t98.563000000000\t2018-01-01T00:48:00.000000Z\t17\tibm\t0.405000000000\t2018-01-01T00:34:00.000000Z\n"
+
"5\tmsft\t50.938000000000\t2018-01-01T01:00:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"6\tibm\t76.110000000000\t2018-01-01T01:12:00.000000Z\t36\tibm\t0.337000000000\t2018-01-01T01:12:00.000000Z\n"
+
"7\tmsft\t55.992000000000\t2018-01-01T01:24:00.000000Z\t38\tmsft\t0.226000000000\t2018-01-01T01:16:00.000000Z\n"
+
"8\tibm\t23.905000000000\t2018-01-01T01:36:00.000000Z\t48\tibm\t0.767000000000\t2018-01-01T01:36:00.000000Z\n"
+
"9\tgoogl\t67.786000000000\t2018-01-01T01:48:00.000000Z\t54\tgoogl\t0.101000000000\t2018-01-01T01:48:00.000000Z\n"
+
"10\tgoogl\t38.540000000000\t2018-01-01T02:00:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"11\tmsft\t68.069000000000\t2018-01-01T02:12:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"12\tmsft\t24.008000000000\t2018-01-01T02:24:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"13\tgoogl\t94.559000000000\t2018-01-01T02:36:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"14\tibm\t62.474000000000\t2018-01-01T02:48:00.000000Z\t50\tibm\t0.068000000000\t2018-01-01T01:40:00.000000Z\n"
+
"15\tmsft\t39.017000000000\t2018-01-01T03:00:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"16\tgoogl\t10.643000000000\t2018-01-01T03:12:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"17\tmsft\t7.246000000000\t2018-01-01T03:24:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"18\tmsft\t36.798000000000\t2018-01-01T03:36:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"19\tmsft\t66.980000000000\t2018-01-01T03:48:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"20\tgoogl\t26.369000000000\t2018-01-01T04:00:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
,
query
,
"timestamp"
);
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
Assert
.
assertEquals
(
0
,
engine
.
getBusyWriterCount
());
}
finally
{
engine
.
releaseAllWriters
();
engine
.
releaseAllReaders
();
}
});
}
@Test
public
void
testAsOfJoinNoTimestamps
()
throws
Exception
{
TestUtils
.
assertMemoryLeak
(()
->
{
try
{
final
String
query
=
"(x timestamp(timestamp)) x asof join (y timestamp(timestamp)) y on y.sym2 = x.sym"
;
final
String
expected
=
"i\tsym\tamt\ttimestamp\ti1\tsym2\tprice\ttimestamp1\n"
+
"1\tmsft\t22.463000000000\t2018-01-01T00:12:00.000000Z\tNaN\t\tNaN\t\n"
+
"2\tgoogl\t29.920000000000\t2018-01-01T00:24:00.000000Z\t12\tgoogl\t0.885000000000\t2018-01-01T00:24:00.000000Z\n"
+
"3\tmsft\t65.086000000000\t2018-01-01T00:36:00.000000Z\t18\tmsft\t0.566000000000\t2018-01-01T00:36:00.000000Z\n"
+
"4\tibm\t98.563000000000\t2018-01-01T00:48:00.000000Z\t17\tibm\t0.405000000000\t2018-01-01T00:34:00.000000Z\n"
+
"5\tmsft\t50.938000000000\t2018-01-01T01:00:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"6\tibm\t76.110000000000\t2018-01-01T01:12:00.000000Z\t28\tibm\t0.954000000000\t2018-01-01T00:56:00.000000Z\n"
+
"7\tmsft\t55.992000000000\t2018-01-01T01:24:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"8\tibm\t23.905000000000\t2018-01-01T01:36:00.000000Z\t28\tibm\t0.954000000000\t2018-01-01T00:56:00.000000Z\n"
+
"9\tgoogl\t67.786000000000\t2018-01-01T01:48:00.000000Z\t30\tgoogl\t0.198000000000\t2018-01-01T01:00:00.000000Z\n"
+
"10\tgoogl\t38.540000000000\t2018-01-01T02:00:00.000000Z\t30\tgoogl\t0.198000000000\t2018-01-01T01:00:00.000000Z\n"
;
compiler
.
compile
(
"create table x as ("
+
"select"
+
" to_int(x) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym,"
+
" round(rnd_double(0)*100, 3) amt,"
+
" to_timestamp('2018-01', 'yyyy-MM') + x * 720000000 timestamp"
+
" from long_sequence(10)"
+
")"
);
compiler
.
compile
(
"create table y as ("
+
"select to_int(x) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym2,"
+
" round(rnd_double(0), 3) price,"
+
" to_timestamp('2018-01', 'yyyy-MM') + x * 120000000 timestamp"
+
" from long_sequence(30)"
+
")"
);
assertQueryAndCache
(
expected
,
query
,
"timestamp"
);
compiler
.
compile
(
"insert into x select * from ("
+
"select"
+
" to_int(x + 10) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym,"
+
" round(rnd_double(0)*100, 3) amt,"
+
" to_timestamp('2018-01', 'yyyy-MM') + (x + 10) * 720000000 timestamp"
+
" from long_sequence(10)"
+
") timestamp(timestamp)"
);
compiler
.
compile
(
"insert into y select * from ("
+
"select"
+
" to_int(x + 30) i,"
+
" rnd_symbol('msft','ibm', 'googl') sym2,"
+
" round(rnd_double(0), 3) price,"
+
" to_timestamp('2018-01', 'yyyy-MM') + (x + 30) * 120000000 timestamp"
+
" from long_sequence(30)"
+
") timestamp(timestamp)"
);
assertQuery
(
"i\tsym\tamt\ttimestamp\ti1\tsym2\tprice\ttimestamp1\n"
+
"1\tmsft\t22.463000000000\t2018-01-01T00:12:00.000000Z\tNaN\t\tNaN\t\n"
+
"2\tgoogl\t29.920000000000\t2018-01-01T00:24:00.000000Z\t12\tgoogl\t0.885000000000\t2018-01-01T00:24:00.000000Z\n"
+
"3\tmsft\t65.086000000000\t2018-01-01T00:36:00.000000Z\t18\tmsft\t0.566000000000\t2018-01-01T00:36:00.000000Z\n"
+
"4\tibm\t98.563000000000\t2018-01-01T00:48:00.000000Z\t17\tibm\t0.405000000000\t2018-01-01T00:34:00.000000Z\n"
+
"5\tmsft\t50.938000000000\t2018-01-01T01:00:00.000000Z\t23\tmsft\t0.545000000000\t2018-01-01T00:46:00.000000Z\n"
+
"6\tibm\t76.110000000000\t2018-01-01T01:12:00.000000Z\t36\tibm\t0.337000000000\t2018-01-01T01:12:00.000000Z\n"
+
"7\tmsft\t55.992000000000\t2018-01-01T01:24:00.000000Z\t38\tmsft\t0.226000000000\t2018-01-01T01:16:00.000000Z\n"
+
"8\tibm\t23.905000000000\t2018-01-01T01:36:00.000000Z\t48\tibm\t0.767000000000\t2018-01-01T01:36:00.000000Z\n"
+
"9\tgoogl\t67.786000000000\t2018-01-01T01:48:00.000000Z\t54\tgoogl\t0.101000000000\t2018-01-01T01:48:00.000000Z\n"
+
"10\tgoogl\t38.540000000000\t2018-01-01T02:00:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"11\tmsft\t68.069000000000\t2018-01-01T02:12:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"12\tmsft\t24.008000000000\t2018-01-01T02:24:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"13\tgoogl\t94.559000000000\t2018-01-01T02:36:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"14\tibm\t62.474000000000\t2018-01-01T02:48:00.000000Z\t50\tibm\t0.068000000000\t2018-01-01T01:40:00.000000Z\n"
+
"15\tmsft\t39.017000000000\t2018-01-01T03:00:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"16\tgoogl\t10.643000000000\t2018-01-01T03:12:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
+
"17\tmsft\t7.246000000000\t2018-01-01T03:24:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"18\tmsft\t36.798000000000\t2018-01-01T03:36:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"19\tmsft\t66.980000000000\t2018-01-01T03:48:00.000000Z\t55\tmsft\t0.051000000000\t2018-01-01T01:50:00.000000Z\n"
+
"20\tgoogl\t26.369000000000\t2018-01-01T04:00:00.000000Z\t60\tgoogl\t0.690000000000\t2018-01-01T02:00:00.000000Z\n"
,
query
,
"timestamp"
);
Assert
.
assertEquals
(
0
,
engine
.
getBusyReaderCount
());
Assert
.
assertEquals
(
0
,
engine
.
getBusyWriterCount
());
}
finally
{
engine
.
releaseAllWriters
();
engine
.
releaseAllReaders
();
}
});
}
@Test
public
void
testAsOfJoinAllTypes
()
throws
Exception
{
TestUtils
.
assertMemoryLeak
(()
->
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录