[
https://issues.apache.org/jira/browse/PHOENIX-688?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14215416#comment-14215416
]
Alicia Ying Shu commented on PHOENIX-688:
-----------------------------------------
1) Added some support for TO_TIMESTAMP(). If using pattern 'yyyy-MM-dd
hh:mm:ss', it works. If using 'yyyy-MM-dd hh:mm:ss.nnnnnnnnn' got parse error
from Java SimpleDateFormat because it expects a Date format. Should we consider
using Joda time?
SELECT TO_TIMESTAMP('2003-12-13 10:13:18', 'yyyy-MM-dd hh:mm:ss') FROM
TO_TIMESTAMP_TEST;
+-----------------------------+
| '2003-12-13 10:13:18.000.0' |
+-----------------------------+
SELECT TO_TIMESTAMP('2003-12-13 10:13:18', 'yyyy-MM-dd hh:mm:ss.nnnnnnnnn')
FROM TO_TIMESTAMP_TEST;
java.lang.IllegalArgumentException: Illegal pattern character 'n'
at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:845)
at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:659)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:585)
at java.text.SimpleDateFormat.<init>(SimpleDateFormat.java:560)
at org.apache.phoenix.util.DateUtil$3.<init>(DateUtil.java:73)
at org.apache.phoenix.util.DateUtil.getTimestampParser(DateUtil.java:73)
at
org.apache.phoenix.parse.ToTimestampParseNode.create(ToTimestampParseNode.java:47)
at
org.apache.phoenix.parse.ToTimestampParseNode.create(ToTimestampParseNode.java:32)
at
org.apache.phoenix.compile.ExpressionCompiler.visitLeave(ExpressionCompiler.java:300)
at
org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:596)
at
org.apache.phoenix.compile.ProjectionCompiler$SelectClauseVisitor.visitLeave(ProjectionCompiler.java:497)
at
org.apache.phoenix.parse.FunctionParseNode.accept(FunctionParseNode.java:81)
at
org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:361)
at
org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:400)
at
org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:357)
at
org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:142)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:311)
at
org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:294)
at
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:215)
at
org.apache.phoenix.jdbc.PhoenixStatement$1.call(PhoenixStatement.java:211)
at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
at
org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:210)
at
org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1040)
at sqlline.SqlLine$Commands.execute(SqlLine.java:3673)
at sqlline.SqlLine$Commands.sql(SqlLine.java:3584)
at sqlline.SqlLine.dispatch(SqlLine.java:821)
at sqlline.SqlLine.begin(SqlLine.java:699)
at sqlline.SqlLine.mainWithInputRedirection(SqlLine.java:441)
at sqlline.SqlLine.main(SqlLine.java:424)
> Add to_time and to_timestamp built-in functions
> -----------------------------------------------
>
> Key: PHOENIX-688
> URL: https://issues.apache.org/jira/browse/PHOENIX-688
> Project: Phoenix
> Issue Type: Task
> Affects Versions: 3.0-Release
> Reporter: James Taylor
> Assignee: Alicia Ying Shu
>
> We already have a to_date function implemented by ToDateFunction, so adding a
> ToTimeFunction could be done by just deriving the class from ToDateFunction
> and changing the getDataType() to be PDataType.TIME instead.
> For a general overview on adding a new built-in function, see the phoenix
> blog
> [here](http://phoenix-hbase.blogspot.com/2013/04/how-to-add-your-own-built-in-function.html)
> The to_timestamp function would be similar as well, but in this case we'd
> want to register a new ToTimestampParseNode (very similar to
> ToDateParseNode), that uses the DateUtil.getTimestampParser(format) to create
> the timestamp instance. This class would then be defined in the
> ToTimestampFunction as the nodeClass attribute (which would cause it to be
> used to construct a ToTimestampFunction at compile time).
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)