Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
b8e46bcb
Q
Questdb
项目概览
jobily
/
Questdb
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
b8e46bcb
编写于
5月 26, 2020
作者:
J
jaugsburger
提交者:
GitHub
5月 26, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(griffin) - timestamp search issue with partial date. Equality fix #323 (#331)
上级
c83c8303
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
126 addition
and
1 deletion
+126
-1
core/src/main/java/io/questdb/cairo/AbstractIntervalDataFrameCursor.java
...ava/io/questdb/cairo/AbstractIntervalDataFrameCursor.java
+1
-1
core/src/test/java/io/questdb/griffin/TimestampQueryTest.java
.../src/test/java/io/questdb/griffin/TimestampQueryTest.java
+125
-0
未找到文件。
core/src/main/java/io/questdb/cairo/AbstractIntervalDataFrameCursor.java
浏览文件 @
b8e46bcb
...
@@ -158,7 +158,7 @@ public abstract class AbstractIntervalDataFrameCursor implements DataFrameCursor
...
@@ -158,7 +158,7 @@ public abstract class AbstractIntervalDataFrameCursor implements DataFrameCursor
}
else
{
}
else
{
intervalLo
=
reader
.
floorToPartitionTimestamp
(
lo
);
intervalLo
=
reader
.
floorToPartitionTimestamp
(
lo
);
}
}
this
.
initialPartitionLo
=
reader
.
get
PartitionCountBetweenTimestamps
(
reader
.
getMinTimestamp
(),
intervalLo
)
;
this
.
initialPartitionLo
=
reader
.
get
MinTimestamp
()
<
intervalLo
?
reader
.
getPartitionCountBetweenTimestamps
(
reader
.
getMinTimestamp
(),
intervalLo
)
:
0
;
long
intervalHi
=
reader
.
floorToPartitionTimestamp
(
intervals
.
getQuick
((
initialIntervalsHi
-
1
)
*
2
+
1
));
long
intervalHi
=
reader
.
floorToPartitionTimestamp
(
intervals
.
getQuick
((
initialIntervalsHi
-
1
)
*
2
+
1
));
this
.
initialPartitionHi
=
Math
.
min
(
reader
.
getPartitionCount
(),
reader
.
getPartitionCountBetweenTimestamps
(
reader
.
getMinTimestamp
(),
intervalHi
)
+
1
);
this
.
initialPartitionHi
=
Math
.
min
(
reader
.
getPartitionCount
(),
reader
.
getPartitionCountBetweenTimestamps
(
reader
.
getMinTimestamp
(),
intervalHi
)
+
1
);
}
}
...
...
core/src/test/java/io/questdb/griffin/TimestampQueryTest.java
0 → 100644
浏览文件 @
b8e46bcb
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* Copyright (c) 2014-2019 Appsicle
* Copyright (c) 2019-2020 QuestDB
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
******************************************************************************/
package
io.questdb.griffin
;
import
io.questdb.griffin.engine.functions.rnd.SharedRandom
;
import
io.questdb.std.Rnd
;
import
org.junit.Before
;
import
org.junit.Test
;
public
class
TimestampQueryTest
extends
AbstractGriffinTest
{
@Before
public
void
setUp3
()
{
SharedRandom
.
RANDOM
.
set
(
new
Rnd
());
}
@Test
public
void
testEqualityTimestampFormatYearOnlyPositiveTest
()
throws
Exception
{
assertMemoryLeak
(()
->
{
//create table
String
createStmt
=
"create table ob_mem_snapshot (symbol int, me_seq_num long, timestamp timestamp) timestamp(timestamp) partition by DAY"
;
String
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
compiler
.
compile
(
createStmt
,
sqlExecutionContext
);
//insert
executeInsert
(
"INSERT INTO ob_mem_snapshot VALUES(1, 1, 1609459199000000)"
);
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
String
query
=
"select * from ob_mem_snapshot"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
// test where ts ='2020'
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
query
=
"SELECT * FROM ob_mem_snapshot where timestamp ='2020'"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
});
}
@Test
public
void
testEqualityTimestampFormatYearOnlyNegativeTest
()
throws
Exception
{
assertMemoryLeak
(()
->
{
//create table
String
createStmt
=
"create table ob_mem_snapshot (symbol int, me_seq_num long, timestamp timestamp) timestamp(timestamp) partition by DAY"
;
String
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
compiler
.
compile
(
createStmt
,
sqlExecutionContext
);
//insert
executeInsert
(
"INSERT INTO ob_mem_snapshot VALUES(1, 1, 1609459199000000)"
);
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
String
query
=
"select * from ob_mem_snapshot"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
// test where ts ='2021'
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
query
=
"SELECT * FROM ob_mem_snapshot where timestamp ='2021'"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
});
}
@Test
public
void
testEqualityTimestampFormatYearAndMonthPositiveTest
()
throws
Exception
{
assertMemoryLeak
(()
->
{
//create table
String
createStmt
=
"create table ob_mem_snapshot (symbol int, me_seq_num long, timestamp timestamp) timestamp(timestamp) partition by DAY"
;
String
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
compiler
.
compile
(
createStmt
,
sqlExecutionContext
);
//insert
executeInsert
(
"INSERT INTO ob_mem_snapshot VALUES(1, 1, 1609459199000000)"
);
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
String
query
=
"select * from ob_mem_snapshot"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
// test where ts ='2020-12'
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
query
=
"SELECT * FROM ob_mem_snapshot where timestamp ='2020-12'"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
});
}
@Test
public
void
testEqualityTimestampFormatYearAndMonthNegativeTest
()
throws
Exception
{
assertMemoryLeak
(()
->
{
//create table
String
createStmt
=
"create table ob_mem_snapshot (symbol int, me_seq_num long, timestamp timestamp) timestamp(timestamp) partition by DAY"
;
String
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
compiler
.
compile
(
createStmt
,
sqlExecutionContext
);
//insert
executeInsert
(
"INSERT INTO ob_mem_snapshot VALUES(1, 1, 1609459199000000)"
);
expected
=
"symbol\tme_seq_num\ttimestamp\n"
+
"1\t1\t2020-12-31T23:59:59.000000Z\n"
;
String
query
=
"select * from ob_mem_snapshot"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
// test where ts ='2021-01'
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
query
=
"SELECT * FROM ob_mem_snapshot where timestamp ='2021-01'"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
// test where ts ='2020-11'
expected
=
"symbol\tme_seq_num\ttimestamp\n"
;
query
=
"SELECT * FROM ob_mem_snapshot where timestamp ='2020-11'"
;
printSqlResult
(
expected
,
query
,
"timestamp"
,
null
,
null
,
true
,
true
);
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录