adding a function leads to Guice injection failure.

2,402 views
Skip to first unread message

P J

unread,
Jan 29, 2015, 2:38:12 PM1/29/15
to presto...@googlegroups.com
Hi,

I needed a date time parser function. 

@Description("given time with time zone")
@ScalarFunction("parse_time")
@SqlType(StandardTypes.TIME_WITH_TIME_ZONE)
public static long parseTime(@SqlType(StandardTypes.VARCHAR) String timeWithTimeZone)
{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
long ts;
try {
ts = format.parse(timeWithTimeZone).getTime();
}
catch (ParseException e) {
ts = -1;
}
return ts;
}



After adding the above function I am not able to start the presto server. Could someone help me figure out what and where to debug ?


2015-01-29T11:28:40.040-0800 ERROR main Bootstrap Uncaught exception in thread main
com.google.inject.internal.util.$ComputationException: java.lang.ArrayIndexOutOfBoundsException: 52264
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:553) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:419) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$CustomConcurrentHashMap$ComputingImpl.get(CustomConcurrentHashMap.java:2041) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$StackTraceElements.forMember(StackTraceElements.java:53) ~[guice-3.0.jar:na]
at com.google.inject.internal.Errors.formatSource(Errors.java:690) ~[guice-3.0.jar:na]
at com.google.inject.internal.Errors.formatInjectionPoint(Errors.java:720) ~[guice-3.0.jar:na]
at com.google.inject.internal.Errors.formatSource(Errors.java:684) ~[guice-3.0.jar:na]
at com.google.inject.internal.Errors.format(Errors.java:555) ~[guice-3.0.jar:na]
at com.google.inject.CreationException.getMessage(CreationException.java:48) ~[guice-3.0.jar:na]
at io.airlift.log.Logger.error(Logger.java:308) ~[log-0.99.jar:0.99]
at com.facebook.presto.server.PrestoServer.run(PrestoServer.java:122) ~[classes/:na]
at com.facebook.presto.server.PrestoServer.main(PrestoServer.java:59) ~[classes/:na]
Caused by: java.lang.ArrayIndexOutOfBoundsException: 52264
at com.google.inject.internal.asm.$ClassReader.readClass(Unknown Source) ~[guice-3.0.jar:na]
at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source) ~[guice-3.0.jar:na]
at com.google.inject.internal.asm.$ClassReader.accept(Unknown Source) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$LineNumbers.<init>(LineNumbers.java:62) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:36) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$StackTraceElements$1.apply(StackTraceElements.java:33) ~[guice-3.0.jar:na]
at com.google.inject.internal.util.$MapMaker$StrategyImpl.compute(MapMaker.java:549) ~[guice-3.0.jar:na]
... 11 common frames omitted

P J

unread,
Jan 29, 2015, 2:46:30 PM1/29/15
to presto...@googlegroups.com
Oh I figured it out.. This worked.

@Description("given time with time zone")
@ScalarFunction("parse_time")
@SqlType(StandardTypes.TIME_WITH_TIME_ZONE)
public static long parseTime(@SqlType(StandardTypes.VARCHAR) Slice timeWithTimeZone)

{
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSZ");
long ts;
try {
        ts = format.parse(timeWithTimeZone.toString(UTF_8)).getTime();

David Phillips

unread,
Jan 29, 2015, 2:52:09 PM1/29/15
to presto...@googlegroups.com
That is a really weird error. We actually just started seeing it here, so we will dig into it.

Regarding date parsing, have you tried parse_datetime(), which uses the same Java SimpleDateFormat?


--
You received this message because you are subscribed to the Google Groups "Presto" group.
To unsubscribe from this group and stop receiving emails from it, send an email to presto-users...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

P J

unread,
Jan 29, 2015, 3:02:09 PM1/29/15
to presto...@googlegroups.com, da...@acz.org
Oh cool, this is exactly what I needed.

Thanks.

Steven Schlansker

unread,
Jan 29, 2015, 3:12:50 PM1/29/15
to presto...@googlegroups.com
I'm about 80% sure that this is fixed in Guice 4.0beta5, if you aren't already running it.

Martin Traverso

unread,
Jan 29, 2015, 3:25:41 PM1/29/15
to presto...@googlegroups.com
We're still on Guice 3.0. 

This happens when there's an error during injection (e.g., due to missing properties) and Guice tries to generate a nice error message. Apparently, it's trying to look at the bytecode of classes to extract line numbers with an old version of ASM that doesn't support Java 8 bytecode.

Martin
Reply all
Reply to author
Forward
0 new messages