Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
7cd9a4d2
Q
Questdb
项目概览
jobily
/
Questdb
9 个月 前同步成功
通知
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,体验更适合开发者的 AI 搜索 >>
未验证
提交
7cd9a4d2
编写于
8月 14, 2023
作者:
B
Bolek Ziobrowski
提交者:
GitHub
8月 14, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(sql): fix error on order by empty string & join condition pushdown (#3646)
上级
14435253
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
70 addition
and
18 deletion
+70
-18
core/src/main/java/io/questdb/griffin/SqlOptimiser.java
core/src/main/java/io/questdb/griffin/SqlOptimiser.java
+4
-0
core/src/main/java/io/questdb/griffin/SqlParser.java
core/src/main/java/io/questdb/griffin/SqlParser.java
+5
-0
core/src/test/java/io/questdb/test/griffin/SqlCompilerImplTest.java
...est/java/io/questdb/test/griffin/SqlCompilerImplTest.java
+61
-18
未找到文件。
core/src/main/java/io/questdb/griffin/SqlOptimiser.java
浏览文件 @
7cd9a4d2
...
...
@@ -2914,7 +2914,11 @@ public class SqlOptimiser implements Mutable {
emitLiteralsTopDown
(
leftJoinWhere
,
jm
);
emitLiteralsTopDown
(
leftJoinWhere
,
model
);
}
}
// propagate join models columns in separate loop to catch columns added to models prior to the current one
for
(
int
i
=
1
,
n
=
joinModels
.
size
();
i
<
n
;
i
++)
{
final
QueryModel
jm
=
joinModels
.
getQuick
(
i
);
propagateTopDownColumns0
(
jm
,
false
,
model
,
true
);
}
...
...
core/src/main/java/io/questdb/griffin/SqlParser.java
浏览文件 @
7cd9a4d2
...
...
@@ -1305,6 +1305,11 @@ public class SqlParser {
throw
SqlException
.
$
(
lexer
.
lastTokenPosition
(),
"literal or expression expected"
);
}
if
((
n
.
type
==
ExpressionNode
.
CONSTANT
&&
Chars
.
equals
(
"''"
,
n
.
token
))
||
(
n
.
type
==
ExpressionNode
.
LITERAL
&&
n
.
token
.
length
()
==
0
))
{
throw
SqlException
.
$
(
lexer
.
lastTokenPosition
(),
"non-empty literal or expression expected"
);
}
tok
=
optTok
(
lexer
);
if
(
tok
!=
null
&&
isDescKeyword
(
tok
))
{
...
...
core/src/test/java/io/questdb/test/griffin/SqlCompilerImplTest.java
浏览文件 @
7cd9a4d2
...
...
@@ -27,10 +27,7 @@ package io.questdb.test.griffin;
import
io.questdb.cairo.*
;
import
io.questdb.cairo.sql.RecordCursorFactory
;
import
io.questdb.cairo.sql.TableRecordMetadata
;
import
io.questdb.griffin.SqlCompiler
;
import
io.questdb.griffin.SqlCompilerImpl
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.SqlExecutionContext
;
import
io.questdb.griffin.*
;
import
io.questdb.griffin.engine.ops.AlterOperationBuilder
;
import
io.questdb.log.Log
;
import
io.questdb.log.LogFactory
;
...
...
@@ -3147,6 +3144,43 @@ public class SqlCompilerImplTest extends AbstractCairoTest {
assertFailure
(
43
,
"cannot compare LONG with type DOUBLE"
,
"select 1 from long_sequence(1) where x in (123.456)"
);
}
@Test
public
void
testInnerJoinConditionPushdown
()
throws
Exception
{
assertMemoryLeak
(()
->
{
compile
(
"create table tab ( created timestamp, value long ) timestamp(created) "
);
compile
(
"insert into tab values (0, 0), (1, 1), (2,2)"
);
for
(
String
join
:
new
String
[]{
""
,
"LEFT"
,
"LT"
,
"ASOF"
,})
{
assertSql
(
"count\n3\n"
,
"SELECT count(T2.created) "
+
"FROM tab as T1 "
+
"JOIN (SELECT * FROM tab) as T2 ON T1.created < T2.created "
+
join
+
" JOIN tab as T3 ON T2.value=T3.value"
);
}
assertSql
(
"count\n1\n"
,
"SELECT count(T2.created) "
+
"FROM tab as T1 "
+
"JOIN tab T2 ON T1.created < T2.created "
+
"JOIN (SELECT * FROM tab) as T3 ON T2.value=T3.value "
+
"JOIN tab T4 on T3.created < T4.created"
);
assertSql
(
"count\n3\n"
,
"SELECT count(T2.created) "
+
"FROM tab as T1 "
+
"JOIN tab T2 ON T1.created < T2.created "
+
"JOIN (SELECT * FROM tab) as T3 ON T2.value=T3.value "
+
"LEFT JOIN tab T4 on T3.created < T4.created"
);
assertSql
(
"count\n3\n"
,
"SELECT count(T2.created) "
+
"FROM tab as T1 "
+
"JOIN tab T2 ON T1.created < T2.created "
+
"JOIN (SELECT * FROM tab) as T3 ON T2.value=T3.value "
+
"LEFT JOIN tab T4 on T3.created-T4.created = 0 "
);
});
}
@Test
public
void
testInsertAsSelect
()
throws
Exception
{
String
expectedData
=
"a\tb\tc\td\te\tf\tg\th\ti\tj\tk\tl\tm\tn\to\tp\n"
+
...
...
@@ -4582,6 +4616,15 @@ public class SqlCompilerImplTest extends AbstractCairoTest {
);
}
@Test
public
void
testOrderByEmptyIdentifier
()
throws
Exception
{
assertMemoryLeak
(()
->
{
assertFailure
(
40
,
"non-empty literal or expression expected"
,
"select 1 from long_sequence(1) order by ''"
);
assertFailure
(
40
,
"non-empty literal or expression expected"
,
"select 1 from long_sequence(1) order by \"\""
);
});
}
@Test
public
void
testOrderByFloat
()
throws
Exception
{
assertQuery
(
"f\n"
+
...
...
@@ -5191,20 +5234,6 @@ public class SqlCompilerImplTest extends AbstractCairoTest {
);
}
@Test
public
void
testTimestampWithNanosInWhereClause
()
throws
Exception
{
assertQuery
(
"x\tts\n"
+
"2\t2019-10-17T00:00:00.200000Z\n"
+
"3\t2019-10-17T00:00:00.700000Z\n"
+
"4\t2019-10-17T00:00:00.800000Z\n"
,
"select * from x where ts between '2019-10-17T00:00:00.200000123Z' and '2019-10-17T00:00:00.800000123Z'"
,
"create table x as "
+
"(SELECT x, timestamp_sequence(to_timestamp('2019-10-17T00:00:00', 'yyyy-MM-ddTHH:mm:ss'), rnd_short(1,5) * 100000L) as ts FROM long_sequence(5)"
+
")"
,
null
,
true
,
false
);
}
@Test
public
void
testSelectTimestampInNullString
()
throws
Exception
{
assertQuery
(
"c\n\n"
,
...
...
@@ -5319,6 +5348,20 @@ public class SqlCompilerImplTest extends AbstractCairoTest {
);
}
@Test
public
void
testTimestampWithNanosInWhereClause
()
throws
Exception
{
assertQuery
(
"x\tts\n"
+
"2\t2019-10-17T00:00:00.200000Z\n"
+
"3\t2019-10-17T00:00:00.700000Z\n"
+
"4\t2019-10-17T00:00:00.800000Z\n"
,
"select * from x where ts between '2019-10-17T00:00:00.200000123Z' and '2019-10-17T00:00:00.800000123Z'"
,
"create table x as "
+
"(SELECT x, timestamp_sequence(to_timestamp('2019-10-17T00:00:00', 'yyyy-MM-ddTHH:mm:ss'), rnd_short(1,5) * 100000L) as ts FROM long_sequence(5)"
+
")"
,
null
,
true
,
false
);
}
@Test
public
void
testUseExtensionPoints
()
{
try
(
SqlCompilerWrapper
compiler
=
new
SqlCompilerWrapper
(
engine
))
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录