Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
jobily
Questdb
提交
5c739ab0
Q
Questdb
项目概览
jobily
/
Questdb
11 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
5c739ab0
编写于
10月 30, 2019
作者:
V
Vlad Ilyushchenko
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GRIFFIN: renamed 'to_char' for date and timestamp to 'to_str' to make them easier to find
上级
793cc26e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
50 addition
and
62 deletion
+50
-62
core/src/main/java/io/questdb/griffin/engine/functions/date/ToStrDateFunctionFactory.java
...iffin/engine/functions/date/ToStrDateFunctionFactory.java
+3
-3
core/src/main/java/io/questdb/griffin/engine/functions/date/ToStrTimestampFunctionFactory.java
.../engine/functions/date/ToStrTimestampFunctionFactory.java
+3
-3
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
...rces/META-INF/services/io.questdb.griffin.FunctionFactory
+4
-27
core/src/test/java/io/questdb/griffin/FunctionParserTest.java
.../src/test/java/io/questdb/griffin/FunctionParserTest.java
+11
-7
core/src/test/java/io/questdb/griffin/engine/functions/bind/BindVariablesTest.java
...stdb/griffin/engine/functions/bind/BindVariablesTest.java
+23
-18
core/src/test/java/io/questdb/griffin/engine/functions/str/ToCharDateVCFunctionFactoryTest.java
...engine/functions/str/ToCharDateVCFunctionFactoryTest.java
+3
-2
core/src/test/java/io/questdb/griffin/engine/functions/str/ToCharTimestampVCFunctionFactoryTest.java
...e/functions/str/ToCharTimestampVCFunctionFactoryTest.java
+3
-2
未找到文件。
core/src/main/java/io/questdb/griffin/engine/functions/
str/ToCha
rDateFunctionFactory.java
→
core/src/main/java/io/questdb/griffin/engine/functions/
date/ToSt
rDateFunctionFactory.java
浏览文件 @
5c739ab0
...
...
@@ -21,7 +21,7 @@
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.
str
;
package
io.questdb.griffin.engine.functions.
date
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
...
...
@@ -42,14 +42,14 @@ import io.questdb.std.time.DateLocale;
import
io.questdb.std.time.DateLocaleFactory
;
import
org.jetbrains.annotations.Nullable
;
public
class
To
Cha
rDateFunctionFactory
implements
FunctionFactory
{
public
class
To
St
rDateFunctionFactory
implements
FunctionFactory
{
private
static
final
ThreadLocal
<
DateFormatCompiler
>
tlCompiler
=
ThreadLocal
.
withInitial
(
DateFormatCompiler:
:
new
);
private
static
final
ThreadLocal
<
StringSink
>
tlSink
=
ThreadLocal
.
withInitial
(
StringSink:
:
new
);
@Override
public
String
getSignature
()
{
return
"to_
cha
r(Ms)"
;
return
"to_
st
r(Ms)"
;
}
@Override
...
...
core/src/main/java/io/questdb/griffin/engine/functions/
str/ToCha
rTimestampFunctionFactory.java
→
core/src/main/java/io/questdb/griffin/engine/functions/
date/ToSt
rTimestampFunctionFactory.java
浏览文件 @
5c739ab0
...
...
@@ -21,7 +21,7 @@
*
******************************************************************************/
package
io.questdb.griffin.engine.functions.
str
;
package
io.questdb.griffin.engine.functions.
date
;
import
io.questdb.cairo.CairoConfiguration
;
import
io.questdb.cairo.sql.Function
;
...
...
@@ -42,14 +42,14 @@ import io.questdb.std.str.CharSink;
import
io.questdb.std.str.StringSink
;
import
org.jetbrains.annotations.Nullable
;
public
class
To
Cha
rTimestampFunctionFactory
implements
FunctionFactory
{
public
class
To
St
rTimestampFunctionFactory
implements
FunctionFactory
{
private
static
final
ThreadLocal
<
DateFormatCompiler
>
tlCompiler
=
ThreadLocal
.
withInitial
(
DateFormatCompiler:
:
new
);
private
static
final
ThreadLocal
<
StringSink
>
tlSink
=
ThreadLocal
.
withInitial
(
StringSink:
:
new
);
@Override
public
String
getSignature
()
{
return
"to_
cha
r(Ns)"
;
return
"to_
st
r(Ns)"
;
}
@Override
...
...
core/src/main/resources/META-INF/services/io.questdb.griffin.FunctionFactory
浏览文件 @
5c739ab0
...
...
@@ -21,29 +21,6 @@
#
################################################################################
################################################################################
# ___ _ ____ ____
# / _ \ _ _ ___ ___| |_| _ \| __ )
# | | | | | | |/ _ \/ __| __| | | | _ \
# | |_| | |_| | __/\__ \ |_| |_| | |_) |
# \__\_\\__,_|\___||___/\__|____/|____/
#
# Copyright (C) 2014-2019 Appsicle
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License, version 3,
# as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
################################################################################
# logical operations
io.questdb.griffin.engine.functions.bool.OrFunctionFactory
io.questdb.griffin.engine.functions.bool.AndFunctionFactory
...
...
@@ -109,8 +86,8 @@ io.questdb.griffin.engine.functions.regex.MatchCharFunctionFactory
io.questdb.griffin.engine.functions.regex.NotMatchStrFunctionFactory
# 'to_char'
io.questdb.griffin.engine.functions.
str.ToCha
rDateFunctionFactory
io.questdb.griffin.engine.functions.
str.ToCha
rTimestampFunctionFactory
io.questdb.griffin.engine.functions.
date.ToSt
rDateFunctionFactory
io.questdb.griffin.engine.functions.
date.ToSt
rTimestampFunctionFactory
io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory
# 'to_symbol'
...
...
@@ -150,11 +127,11 @@ io.questdb.griffin.engine.functions.rnd.RndLong256FunctionFactory
io.questdb.griffin.engine.functions.date.SysdateFunctionFactory
io.questdb.griffin.engine.functions.date.ToTimestampVCFunctionFactory
io.questdb.griffin.engine.functions.
str.ToCha
rTimestampFunctionFactory
io.questdb.griffin.engine.functions.
date.ToSt
rTimestampFunctionFactory
io.questdb.griffin.engine.functions.cast.SecondsToTimestampFunctionFactory
io.questdb.griffin.engine.functions.date.ToDateFunctionFactory
io.questdb.griffin.engine.functions.
str.ToCha
rDateFunctionFactory
io.questdb.griffin.engine.functions.
date.ToSt
rDateFunctionFactory
# cast functions
io.questdb.griffin.engine.functions.cast.ToDateLongFunctionFactory
...
...
core/src/test/java/io/questdb/griffin/FunctionParserTest.java
浏览文件 @
5c739ab0
...
...
@@ -33,8 +33,12 @@ import io.questdb.griffin.engine.functions.bool.NotFunctionFactory;
import
io.questdb.griffin.engine.functions.bool.OrFunctionFactory
;
import
io.questdb.griffin.engine.functions.constants.*
;
import
io.questdb.griffin.engine.functions.date.SysdateFunctionFactory
;
import
io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory
;
import
io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory
;
import
io.questdb.griffin.engine.functions.math.*
;
import
io.questdb.griffin.engine.functions.str.*
;
import
io.questdb.griffin.engine.functions.str.LengthStrFunctionFactory
;
import
io.questdb.griffin.engine.functions.str.LengthSymbolFunctionFactory
;
import
io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory
;
import
io.questdb.std.BinarySequence
;
import
io.questdb.std.NumericException
;
import
io.questdb.std.ObjList
;
...
...
@@ -355,8 +359,8 @@ public class FunctionParserTest extends BaseFunctionFactoryTest {
@Test
public
void
testFunctionOverload
()
throws
SqlException
{
functions
.
add
(
new
To
Cha
rDateFunctionFactory
());
functions
.
add
(
new
To
Cha
rTimestampFunctionFactory
());
functions
.
add
(
new
To
St
rDateFunctionFactory
());
functions
.
add
(
new
To
St
rTimestampFunctionFactory
());
functions
.
add
(
new
ToCharBinFunctionFactory
());
final
GenericRecordMetadata
metadata
=
new
GenericRecordMetadata
();
...
...
@@ -367,11 +371,11 @@ public class FunctionParserTest extends BaseFunctionFactoryTest {
FunctionParser
functionParser
=
createFunctionParser
();
Record
record
=
new
TestRecord
();
Function
function
=
parseFunction
(
"to_
cha
r(a, 'EE, dd-MMM-yyyy hh:mm:ss')"
,
metadata
,
functionParser
);
Function
function
=
parseFunction
(
"to_
st
r(a, 'EE, dd-MMM-yyyy hh:mm:ss')"
,
metadata
,
functionParser
);
Assert
.
assertEquals
(
ColumnType
.
STRING
,
function
.
getType
());
TestUtils
.
assertEquals
(
"Thursday, 03-Apr-150577 03:54:03"
,
function
.
getStr
(
record
));
Function
function2
=
parseFunction
(
"to_
cha
r(b, 'EE, dd-MMM-yyyy hh:mm:ss')"
,
metadata
,
functionParser
);
Function
function2
=
parseFunction
(
"to_
st
r(b, 'EE, dd-MMM-yyyy hh:mm:ss')"
,
metadata
,
functionParser
);
Assert
.
assertEquals
(
ColumnType
.
STRING
,
function2
.
getType
());
TestUtils
.
assertEquals
(
"Tuesday, 21-Nov-2119 08:50:58"
,
function2
.
getStr
(
record
));
...
...
@@ -928,7 +932,7 @@ public class FunctionParserTest extends BaseFunctionFactoryTest {
@Test
public
void
testNoArgFunction
()
throws
SqlException
,
JsonException
{
functions
.
add
(
new
SysdateFunctionFactory
());
functions
.
add
(
new
To
Cha
rDateFunctionFactory
());
functions
.
add
(
new
To
St
rDateFunctionFactory
());
FunctionParser
functionParser
=
new
FunctionParser
(
new
DefaultCairoConfiguration
(
root
)
{
@Override
...
...
@@ -945,7 +949,7 @@ public class FunctionParserTest extends BaseFunctionFactoryTest {
},
functions
);
Function
function
=
parseFunction
(
"to_
cha
r(sysdate(), 'EE, dd-MMM-yyyy HH:mm:ss')"
,
Function
function
=
parseFunction
(
"to_
st
r(sysdate(), 'EE, dd-MMM-yyyy HH:mm:ss')"
,
new
GenericRecordMetadata
(),
functionParser
);
...
...
core/src/test/java/io/questdb/griffin/engine/functions/bind/BindVariablesTest.java
浏览文件 @
5c739ab0
...
...
@@ -34,9 +34,14 @@ import io.questdb.griffin.FunctionParser;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.TestBinarySequence
;
import
io.questdb.griffin.engine.functions.bool.NotFunctionFactory
;
import
io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory
;
import
io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory
;
import
io.questdb.griffin.engine.functions.eq.EqLong256FunctionFactory
;
import
io.questdb.griffin.engine.functions.math.*
;
import
io.questdb.griffin.engine.functions.str.*
;
import
io.questdb.griffin.engine.functions.str.LengthBinFunctionFactory
;
import
io.questdb.griffin.engine.functions.str.LengthStrFunctionFactory
;
import
io.questdb.griffin.engine.functions.str.SubStrFunctionFactory
;
import
io.questdb.griffin.engine.functions.str.ToCharBinFunctionFactory
;
import
io.questdb.std.*
;
import
io.questdb.std.time.DateFormatUtils
;
import
io.questdb.test.tools.TestUtils
;
...
...
@@ -59,9 +64,9 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
bindVariableService
.
setDate
(
"xyz"
,
0
);
Function
func
=
expr
(
"to_
cha
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rDateFunctionFactory
())
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
Function
func
=
expr
(
"to_
st
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
St
rDateFunctionFactory
())
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -77,7 +82,7 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
Function
func
=
expr
(
"to_char(:x)"
)
.
withFunction
(
new
ToCharBinFunctionFactory
())
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -133,7 +138,7 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
Function
func
=
expr
(
"to_char($1)"
)
.
withFunction
(
new
ToCharBinFunctionFactory
())
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -242,8 +247,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
@Test
public
void
testDate
()
throws
SqlException
,
NumericException
{
bindVariableService
.
setDate
(
"xyz"
,
DateFormatUtils
.
parseDateTime
(
"2015-04-10T10:00:00.000Z"
));
Function
func
=
expr
(
"to_
cha
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rDateFunctionFactory
())
Function
func
=
expr
(
"to_
st
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
St
rDateFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -270,8 +275,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
public
void
testDateIndexed
()
throws
SqlException
,
NumericException
{
bindVariableService
.
setDate
(
1
,
0
);
bindVariableService
.
setDate
(
0
,
DateFormatUtils
.
parseDateTime
(
"2015-04-10T10:00:00.000Z"
));
Function
func
=
expr
(
"to_
cha
r($1, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rDateFunctionFactory
())
Function
func
=
expr
(
"to_
st
r($1, 'yyyy-MM')"
)
.
withFunction
(
new
To
St
rDateFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -657,8 +662,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
public
void
testTimestamp
()
throws
SqlException
,
NumericException
{
bindVariableService
.
setTimestamp
(
"xyz"
,
io
.
questdb
.
std
.
microtime
.
DateFormatUtils
.
parseDateTime
(
"2015-04-10T10:00:00.000Z"
));
Function
func
=
expr
(
"to_
cha
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
Function
func
=
expr
(
"to_
st
r(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -673,8 +678,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
bindVariableService
.
setTimestamp
(
1
,
25
);
bindVariableService
.
setTimestamp
(
0
,
io
.
questdb
.
std
.
microtime
.
DateFormatUtils
.
parseDateTime
(
"2015-04-10T10:00:00.000Z"
));
Function
func
=
expr
(
"to_
cha
r($1, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
Function
func
=
expr
(
"to_
st
r($1, 'yyyy-MM')"
)
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
func
.
init
(
null
,
sqlExecutionContext
);
...
...
@@ -688,8 +693,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
public
void
testUndefined
()
{
try
{
expr
(
"to_char(:xyz, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rDateFunctionFactory
())
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
.
withFunction
(
new
To
St
rDateFunctionFactory
())
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
}
catch
(
SqlException
e
)
{
Assert
.
assertEquals
(
8
,
e
.
getPosition
());
...
...
@@ -701,8 +706,8 @@ public class BindVariablesTest extends BaseFunctionFactoryTest {
public
void
testUndefinedIndexed
()
{
try
{
expr
(
"to_char($1, 'yyyy-MM')"
)
.
withFunction
(
new
To
Cha
rDateFunctionFactory
())
.
withFunction
(
new
To
Cha
rTimestampFunctionFactory
())
.
withFunction
(
new
To
St
rDateFunctionFactory
())
.
withFunction
(
new
To
St
rTimestampFunctionFactory
())
.
$
();
}
catch
(
SqlException
e
)
{
Assert
.
assertEquals
(
8
,
e
.
getPosition
());
...
...
core/src/test/java/io/questdb/griffin/engine/functions/str/ToCharDateVCFunctionFactoryTest.java
浏览文件 @
5c739ab0
...
...
@@ -26,6 +26,7 @@ package io.questdb.griffin.engine.functions.str;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
io.questdb.griffin.engine.functions.date.ToStrDateFunctionFactory
;
import
io.questdb.std.Numbers
;
import
io.questdb.std.NumericException
;
import
io.questdb.std.time.DateFormatUtils
;
...
...
@@ -39,7 +40,7 @@ public class ToCharDateVCFunctionFactoryTest extends AbstractFunctionFactoryTest
@Test
public
void
testNullFormat
()
{
assertFailure
(
1
1
,
"format must not be null"
,
0L
,
null
);
assertFailure
(
1
0
,
"format must not be null"
,
0L
,
null
);
}
@Test
...
...
@@ -50,6 +51,6 @@ public class ToCharDateVCFunctionFactoryTest extends AbstractFunctionFactoryTest
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
To
Cha
rDateFunctionFactory
();
return
new
To
St
rDateFunctionFactory
();
}
}
\ No newline at end of file
core/src/test/java/io/questdb/griffin/engine/functions/str/ToCharTimestampVCFunctionFactoryTest.java
浏览文件 @
5c739ab0
...
...
@@ -26,6 +26,7 @@ package io.questdb.griffin.engine.functions.str;
import
io.questdb.griffin.FunctionFactory
;
import
io.questdb.griffin.SqlException
;
import
io.questdb.griffin.engine.AbstractFunctionFactoryTest
;
import
io.questdb.griffin.engine.functions.date.ToStrTimestampFunctionFactory
;
import
io.questdb.std.Numbers
;
import
io.questdb.std.NumericException
;
import
io.questdb.std.microtime.DateFormatUtils
;
...
...
@@ -39,7 +40,7 @@ public class ToCharTimestampVCFunctionFactoryTest extends AbstractFunctionFactor
@Test
public
void
testNullFormat
()
{
assertFailure
(
1
1
,
"format must not be null"
,
0L
,
null
);
assertFailure
(
1
0
,
"format must not be null"
,
0L
,
null
);
}
@Test
...
...
@@ -50,7 +51,7 @@ public class ToCharTimestampVCFunctionFactoryTest extends AbstractFunctionFactor
@Override
protected
FunctionFactory
getFunctionFactory
()
{
return
new
To
Cha
rTimestampFunctionFactory
();
return
new
To
St
rTimestampFunctionFactory
();
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录