You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tajo.apache.org by "Keuntae Park (JIRA)" <ji...@apache.org> on 2013/12/03 07:27:36 UTC
[jira] [Commented] (TAJO-339) Implement sin( x ) - returns the sine
of x (x is in radians)
[ https://issues.apache.org/jira/browse/TAJO-339?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13837387#comment-13837387 ]
Keuntae Park commented on TAJO-339:
-----------------------------------
This patch looks good to me.
'mvn clean install' is successfully finished.
However, there is commented code in TestMathFunctions.Java
{noformat}
@Test
public void testSin() throws IOException {
testSimpleEval("select sin(0.0) as col1 ", new String[]{"0.0"});
testSimpleEval("select sin(0.7) as col1 ", new String[]{"0.6442176781200616"});
testSimpleEval("select sin(1.2) as col1 ", new String[]{"0.9320391032457895"});
// testSimpleEval("select sin(-0.5) as col1 ", new String[]{"-0.479425538604203"});
Schema schema = new Schema();
schema.addColumn("col1", FLOAT8);
schema.addColumn("col2", FLOAT8);
schema.addColumn("col3", FLOAT8);
testEval(schema, "table1", "1.0, 0.2, 0.1", "select sin(col1 + col2 + col3) from table1",
new String[]{"0.963558185417193"});
}
{noformat}
And, when I removed the above comment and 'mvn clean install',
I got following error during test:
{noformat}
Test set: org.apache.tajo.engine.function.TestMathFunctions
-------------------------------------------------------------------------------
Tests run: 4, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.12 sec <<< FAILURE!
testSin(org.apache.tajo.engine.function.TestMathFunctions) Time elapsed: 0.01 sec <<< ERROR!
org.apache.tajo.engine.parser.SQLSyntaxError: ERROR: syntax error at or near 'sin'
LINE 1:7 select sin(-0.5) as col1
^^^
at org.apache.tajo.engine.parser.SQLAnalyzer.parse(SQLAnalyzer.java:64)
at org.apache.tajo.engine.eval.ExprTestBase.getRawTargets(ExprTestBase.java:78)
at org.apache.tajo.engine.eval.ExprTestBase.testEval(ExprTestBase.java:123)
at org.apache.tajo.engine.eval.ExprTestBase.testSimpleEval(ExprTestBase.java:91)
at org.apache.tajo.engine.function.TestMathFunctions.testSin(TestMathFunctions.java:89)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:252)
at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:141)
at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(ReflectionUtils.java:189)
at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(ProviderFactory.java:165)
at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(ProviderFactory.java:85)
at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:115)
at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:75)
{noformat}
I'm not sure the exact reason but I think that SQL parser may not handle negative number properly in sin() function.
Does anybody have an idea about the above error?
> Implement sin( x ) - returns the sine of x (x is in radians)
> ------------------------------------------------------------
>
> Key: TAJO-339
> URL: https://issues.apache.org/jira/browse/TAJO-339
> Project: Tajo
> Issue Type: Improvement
> Components: operator/function/udf
> Reporter: Jae Young Lee
> Assignee: Jae Young Lee
> Priority: Minor
> Attachments: TAJO-339.patch
>
>
> sin function returns the sine of x (x is in radians)
> {code}
> double sin(double x)
> {code}
> Only double type implementation is OK, or INT also needs?
--
This message was sent by Atlassian JIRA
(v6.1#6144)