Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
38a90c85
Q
Questdb
项目概览
jobily
/
Questdb
10 个月 前同步成功
通知
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,发现更多精彩内容 >>
未验证
提交
38a90c85
编写于
9月 11, 2021
作者:
M
marregui
提交者:
GitHub
9月 11, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(sql): allow comparisons between geohash and string, for chars notation (#1310)
上级
f8575182
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
306 addition
and
17 deletion
+306
-17
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqGeoHashGeoHashFunctionFactory.java
.../engine/functions/eq/EqGeoHashGeoHashFunctionFactory.java
+2
-1
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqGeoHashStrFunctionFactory.java
...ffin/engine/functions/eq/EqGeoHashStrFunctionFactory.java
+55
-0
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqStrGeoHashFunctionFactory.java
...ffin/engine/functions/eq/EqStrGeoHashFunctionFactory.java
+55
-0
core/src/main/java/module-info.java
core/src/main/java/module-info.java
+2
-0
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
...rces/META-INF/services/io.questdb.griffin.FunctionFactory
+2
-0
core/src/test/java/io/questdb/griffin/SqlCodeGeneratorTest.java
...rc/test/java/io/questdb/griffin/SqlCodeGeneratorTest.java
+32
-0
core/src/test/java/io/questdb/griffin/engine/functions/eq/EqGeoHashGeoHashFunctionFactoryTest.java
...ine/functions/eq/EqGeoHashGeoHashFunctionFactoryTest.java
+20
-16
core/src/test/java/io/questdb/griffin/engine/functions/eq/EqGeoHashStrFunctionFactoryTest.java
.../engine/functions/eq/EqGeoHashStrFunctionFactoryTest.java
+138
-0
未找到文件。
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqGeoHashGeoHashFunctionFactory.java
浏览文件 @
38a90c85
...
...
@@ -30,6 +30,7 @@ import io.questdb.cairo.GeoHashes;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.cairo.sql.Record
;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.SqlExecutionContext
;
import
io.questdb.griffin.engine.functions.BinaryFunction
;
import
io.questdb.griffin.engine.functions.NegatableBooleanFunction
;
...
...
@@ -57,7 +58,7 @@ public class EqGeoHashGeoHashFunctionFactory implements FunctionFactory {
ObjList
<
Function
>
args
,
IntList
argPositions
,
CairoConfiguration
configuration
,
SqlExecutionContext
sqlExecutionContext
)
{
SqlExecutionContext
sqlExecutionContext
)
throws
SqlException
{
Function
geohash1
=
args
.
getQuick
(
0
);
Function
geohash2
=
args
.
getQuick
(
1
);
int
type1p
=
geohash1
.
getType
();
...
...
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqGeoHashStrFunctionFactory.java
0 → 100644
浏览文件 @
38a90c85
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* 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.engine.functions.eq
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.SqlExecutionContext
;
import
io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory
;
import
io.questdb.std.IntList
;
import
io.questdb.std.ObjList
;
public
class
EqGeoHashStrFunctionFactory
extends
EqGeoHashGeoHashFunctionFactory
{
private
final
static
CastStrToGeoHashFunctionFactory
STR2GEOHASH_FF
=
new
CastStrToGeoHashFunctionFactory
();
@Override
public
String
getSignature
()
{
return
"=(GS)"
;
}
@Override
public
Function
newInstance
(
int
position
,
ObjList
<
Function
>
args
,
IntList
argPositions
,
CairoConfiguration
configuration
,
SqlExecutionContext
sqlExecutionContext
)
throws
SqlException
{
args
.
set
(
1
,
STR2GEOHASH_FF
.
newInstance
(
position
,
args
.
getQuick
(
0
).
getType
(),
args
.
getQuick
(
1
)));
return
super
.
newInstance
(
position
,
args
,
argPositions
,
configuration
,
sqlExecutionContext
);
}
}
core/src/main/java/io/questdb/griffin/engine/functions/eq/EqStrGeoHashFunctionFactory.java
0 → 100644
浏览文件 @
38a90c85
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* 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.engine.functions.eq
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.SqlExecutionContext
;
import
io.questdb.griffin.engine.functions.cast.CastStrToGeoHashFunctionFactory
;
import
io.questdb.std.IntList
;
import
io.questdb.std.ObjList
;
public
class
EqStrGeoHashFunctionFactory
extends
EqGeoHashGeoHashFunctionFactory
{
private
final
static
CastStrToGeoHashFunctionFactory
STR2GEOHASH_FF
=
new
CastStrToGeoHashFunctionFactory
();
@Override
public
String
getSignature
()
{
return
"=(SG)"
;
}
@Override
public
Function
newInstance
(
int
position
,
ObjList
<
Function
>
args
,
IntList
argPositions
,
CairoConfiguration
configuration
,
SqlExecutionContext
sqlExecutionContext
)
throws
SqlException
{
args
.
set
(
0
,
STR2GEOHASH_FF
.
newInstance
(
position
,
args
.
getQuick
(
1
).
getType
(),
args
.
getQuick
(
0
)));
return
super
.
newInstance
(
position
,
args
,
argPositions
,
configuration
,
sqlExecutionContext
);
}
}
core/src/main/java/module-info.java
浏览文件 @
38a90c85
...
...
@@ -120,6 +120,8 @@ open module io.questdb {
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
EqBooleanFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
EqBinaryFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
EqGeoHashGeoHashFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
EqGeoHashStrFunctionFactory
,
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
EqStrGeoHashFunctionFactory
,
//nullif
io
.
questdb
.
griffin
.
engine
.
functions
.
eq
.
NullIfCharCharFunctionFactory
,
...
...
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
浏览文件 @
38a90c85
...
...
@@ -31,6 +31,8 @@ io.questdb.griffin.engine.functions.eq.EqTimestampFunctionFactory
io.questdb.griffin.engine.functions.eq.EqBooleanFunctionFactory
io.questdb.griffin.engine.functions.eq.EqBinaryFunctionFactory
io.questdb.griffin.engine.functions.eq.EqGeoHashGeoHashFunctionFactory
io.questdb.griffin.engine.functions.eq.EqGeoHashStrFunctionFactory
io.questdb.griffin.engine.functions.eq.EqStrGeoHashFunctionFactory
#nullif
io.questdb.griffin.engine.functions.eq.NullIfCharCharFunctionFactory
...
...
core/src/test/java/io/questdb/griffin/SqlCodeGeneratorTest.java
浏览文件 @
38a90c85
...
...
@@ -2036,6 +2036,38 @@ public class SqlCodeGeneratorTest extends AbstractGriffinTest {
});
}
@Test
public
void
testEqGeoHashWhenOtherIsStr1
()
throws
Exception
{
assertMemoryLeak
(
()
->
{
createGeoHashTable
(
4
);
assertQuery
(
"time\tuuid\thash\n"
+
"2021-05-10T23:59:59.439000Z\tbbb\tewef\n"
,
"select * from pos where hash = 'ewef'"
,
"time"
,
true
,
true
,
true
);
});
}
@Test
public
void
testEqGeoHashWhenOtherIsStr2
()
throws
Exception
{
assertMemoryLeak
(
()
->
{
createGeoHashTable
(
4
);
assertQuery
(
"time\tuuid\thash\n"
+
"2021-05-10T23:59:59.439000Z\tbbb\tewef\n"
,
"select * from pos where 'ewef' = hash"
,
"time"
,
true
,
true
,
true
);
});
}
@Test
public
void
testLatestByAllIndexedGeoHashTimeRange1c
()
throws
Exception
{
assertMemoryLeak
(
...
...
core/src/test/java/io/questdb/griffin/engine/functions/eq/EqGeoHashGeoHashFunctionFactoryTest.java
浏览文件 @
38a90c85
...
...
@@ -112,8 +112,8 @@ public class EqGeoHashGeoHashFunctionFactoryTest extends AbstractGriffinTest {
@Test
public
void
testSameTypeSameNonConstInt
()
{
createEqFunctionNonConstAndAssert
(
(
int
)
1
E9
,
ColumnType
.
getGeoHashTypeWithBits
(
30
),
(
int
)
1
E9
,
ColumnType
.
getGeoHashTypeWithBits
(
30
),
(
int
)
1
E9
,
ColumnType
.
getGeoHashTypeWithBits
(
30
),
(
int
)
1
E9
,
ColumnType
.
getGeoHashTypeWithBits
(
30
),
true
);
}
...
...
@@ -268,9 +268,9 @@ public class EqGeoHashGeoHashFunctionFactoryTest extends AbstractGriffinTest {
public
void
testConstHalfConst1
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash from long_sequence(1)"
+
")"
,
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where cast('sp052w92p1p' as gEoHaSh(10c)) = geohash"
,
...
...
@@ -392,18 +392,22 @@ public class EqGeoHashGeoHashFunctionFactoryTest extends AbstractGriffinTest {
}
private
void
createEqFunctionAndAssert
(
boolean
isConstant
,
boolean
expectedEq
)
{
Function
func
=
factory
.
newInstance
(-
1
,
args
,
null
,
null
,
null
);
Assert
.
assertEquals
(
expectedEq
,
func
.
getBool
(
null
));
Assert
.
assertEquals
(
isConstant
,
func
.
isConstant
());
if
(
func
instanceof
NegatableBooleanFunction
)
{
try
{
NegatingFunctionFactory
nf
=
new
NegatingFunctionFactory
(
"noteq"
,
factory
);
func
=
nf
.
newInstance
(-
1
,
args
,
null
,
null
,
null
);
Assert
.
assertEquals
(!
expectedEq
,
func
.
getBool
(
null
));
}
catch
(
SqlException
e
)
{
e
.
printStackTrace
();
Assert
.
fail
();
try
{
Function
func
=
factory
.
newInstance
(-
1
,
args
,
null
,
null
,
null
);
Assert
.
assertEquals
(
expectedEq
,
func
.
getBool
(
null
));
Assert
.
assertEquals
(
isConstant
,
func
.
isConstant
());
if
(
func
instanceof
NegatableBooleanFunction
)
{
try
{
NegatingFunctionFactory
nf
=
new
NegatingFunctionFactory
(
"noteq"
,
factory
);
func
=
nf
.
newInstance
(-
1
,
args
,
null
,
null
,
null
);
Assert
.
assertEquals
(!
expectedEq
,
func
.
getBool
(
null
));
}
catch
(
SqlException
e
)
{
e
.
printStackTrace
();
Assert
.
fail
();
}
}
}
catch
(
SqlException
e
)
{
Assert
.
fail
(
e
.
getMessage
());
}
}
...
...
core/src/test/java/io/questdb/griffin/engine/functions/eq/EqGeoHashStrFunctionFactoryTest.java
0 → 100644
浏览文件 @
38a90c85
/*******************************************************************************
* ___ _ ____ ____
* / _ \ _ _ ___ ___| |_| _ \| __ )
* | | | | | | |/ _ \/ __| __| | | | _ \
* | |_| | |_| | __/\__ \ |_| |_| | |_) |
* \__\_\\__,_|\___||___/\__|____/|____/
*
* 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.engine.functions.eq
;
import
io.questdb.griffin.AbstractGriffinTest
;
import
org.junit.Test
;
public
class
EqGeoHashStrFunctionFactoryTest
extends
AbstractGriffinTest
{
@Test
public
void
testEq1
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where 'sp052w92p1' = geohash1"
,
"geohash1\tgeohash2\n"
+
"sp052w92p1\t\n"
);
});
}
@Test
public
void
testEq2
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where geohash1 = 'sp052w92p1'"
,
"geohash1\tgeohash2\n"
+
"sp052w92p1\t\n"
);
});
}
@Test
public
void
testEq3
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where geohash2 = null"
,
"geohash1\tgeohash2\n"
+
"sp052w92p1\t\n"
);
});
}
@Test
public
void
testNoEq1
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where 'sp052w92p0' != geohash1"
,
"geohash1\tgeohash2\n"
+
"sp052w92p1\t\n"
);
});
}
@Test
public
void
testNoEq2
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where geohash1 != 'sp052w92p0'"
,
"geohash1\tgeohash2\n"
+
"sp052w92p1\t\n"
);
});
}
@Test
public
void
testNoEq3
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compiler
.
compile
(
"create table geohash as ("
+
"select "
+
" cast('sp052w92p1' as GeOhAsH(50b)) geohash1, "
+
" cast(null as GeOhAsH(50b)) geohash2 "
+
"from long_sequence(1)"
+
")"
,
sqlExecutionContext
);
assertSql
(
"geohash where geohash2 != null"
,
"geohash1\tgeohash2\n"
);
});
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录