[ 
https://issues.apache.org/jira/browse/PHOENIX-2803?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15213751#comment-15213751
 ] 

Thomas D'Silva edited comment on PHOENIX-2803 at 3/28/16 3:28 AM:
------------------------------------------------------------------

[~jfernando_sfdc], [~jamestaylor] I have attached an inital patch. The test 
passes if ToDateFunction implements 
{code}
public ScalarFunction clone(List<Expression> children)
{code}

PHOENIX-2593  added a test to ensure that all ScalarFunctions have a 
constructor that takes (List<Expression> children).
If the scalar function has other parameters required for initialization this 
will cause issues. 

Maybe we should add  the clone(List<Expression> children) method to ToDate as 
well?


was (Author: tdsilva):
[~jfernando_sfdc], [~jamestaylor] I have attached an inital patch. The test 
passes if ToDateFunction implements 
{code}
public ScalarFunction clone(List<Expression> children)
{code}

PHOENIX-2593  added a test to ensure that all ScalarFunctions have a 
constructor that takes (List<Expression> children). I don't think this is 
required. Maybe we should add  the clone(List<Expression> children) method to 
ToDate as well?

> Initializing ToCharFunction with the List<Expression> constructor fails 
> ------------------------------------------------------------------------
>
>                 Key: PHOENIX-2803
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-2803
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 4.7.0
>            Reporter: Thomas D'Silva
>            Assignee: Thomas D'Silva
>         Attachments: PHOENIX-2803.patch
>
>
> The following test can be used to repro
> {code}
> @Test
>     public void testToCharWithExpressionListConstructor() throws SQLException 
> {
>         Connection conn = DriverManager.getConnection(getUrl());
>       String ddl = "create table t (k varchar primary key, v integer[])";
>         conn.createStatement().execute(ddl);
>         conn.createStatement().executeQuery("select to_char(v[1]) from t");
>     }
> {code}
> throws this exception
> {code}
> java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
>       at 
> org.apache.phoenix.expression.function.ScalarFunction.clone(ScalarFunction.java:44)
>       at 
> org.apache.phoenix.expression.visitor.CloneExpressionVisitor.visitLeave(CloneExpressionVisitor.java:106)
>       at 
> org.apache.phoenix.expression.visitor.ReplaceArrayFunctionExpressionVisitor.visitLeave(ReplaceArrayFunctionExpressionVisitor.java:44)
>       at 
> org.apache.phoenix.expression.visitor.CloneExpressionVisitor.visitLeave(CloneExpressionVisitor.java:1)
>       at 
> org.apache.phoenix.expression.function.ScalarFunction.accept(ScalarFunction.java:58)
>       at 
> org.apache.phoenix.compile.ProjectionCompiler.compile(ProjectionCompiler.java:462)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compileSingleFlatQuery(QueryCompiler.java:546)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compileSingleQuery(QueryCompiler.java:496)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compileSelect(QueryCompiler.java:202)
>       at 
> org.apache.phoenix.compile.QueryCompiler.compile(QueryCompiler.java:158)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:396)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$ExecutableSelectStatement.compilePlan(PhoenixStatement.java:1)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:263)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:1)
>       at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:257)
>       at 
> org.apache.phoenix.jdbc.PhoenixStatement.executeQuery(PhoenixStatement.java:1261)
>       at 
> org.apache.phoenix.end2end.ToCharFunctionIT.testToCharWithExpressionListConstructor(ToCharFunctionIT.java:250)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at 
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
>       at java.lang.reflect.Method.invoke(Method.java:497)
>       at 
> org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
>       at 
> org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
>       at 
> org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
>       at 
> org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
>       at 
> org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
>       at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
>       at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
>       at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
>       at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
>       at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
>       at 
> org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
>       at 
> org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
>       at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:48)
>       at org.junit.rules.RunRules.evaluate(RunRules.java:20)
>       at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
>       at 
> org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
>       at 
> org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
>       at 
> org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
> Caused by: java.lang.reflect.InvocationTargetException
>       at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
>       at 
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>       at 
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>       at java.lang.reflect.Constructor.newInstance(Constructor.java:422)
>       at 
> org.apache.phoenix.expression.function.ScalarFunction.clone(ScalarFunction.java:42)
>       ... 46 more
> Caused by: java.lang.NullPointerException
>       at 
> com.google.common.base.Preconditions.checkNotNull(Preconditions.java:191)
>       at 
> org.apache.phoenix.expression.function.ToCharFunction.<init>(ToCharFunction.java:66)
>       at 
> org.apache.phoenix.expression.function.ToCharFunction.<init>(ToCharFunction.java:61)
>       ... 51 more
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to