[jira] [Commented] (CALCITE-4810) Failed to cast a double field (which isn't a literal) to boolean in the test case.

2021-10-07 Thread xuyangzhong (Jira)


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

xuyangzhong commented on CALCITE-4810:
--

Maybe this issue can be closed because now we all support that casting from 
double to boolean is invalid.

> Failed to cast a double field (which isn't a literal) to boolean in the test 
> case.
> --
>
> Key: CALCITE-4810
> URL: https://issues.apache.org/jira/browse/CALCITE-4810
> Project: Calcite
>  Issue Type: Bug
>Reporter: xuyangzhong
>Priority: Minor
>
> The cause of this matter is that when I add a test case in 
> SqlOperatorBaseTest:
> {code:java}
> // code placeholder
>   @Test void myTest(){
> tester.checkBoolean("cast(0.1e0 as boolean)",false);
>   }
> {code}
> The tester will turn the single sql to these two SQLs which will be all 
> tested:
> {code:java}
> // SQL 1 
> values (cast(0.1e0 as boolean))
> // SQL 2
> select cast(p0 as boolean) from (values (0.1e0)) as t(p0)
> {code}
> The SQL1 passed by the RexSimplify. But The SQL2 throws a exception following:
> {code:java}
> // code placeholder
> java.sql.SQLException: Error while executing SQL "select cast(p0 as boolean) 
> from (values (0.1e0)) as t(p0)": Error while compiling generated Java code:
> public org.apache.calcite.linq4j.Enumerable bind(final 
> org.apache.calcite.DataContext root) {
>   final org.apache.calcite.linq4j.Enumerable _inputEnumerable = 
> org.apache.calcite.linq4j.Linq4j.asEnumerable(new Double[] {
> 0.1D});
>   return new org.apache.calcite.linq4j.AbstractEnumerable(){
>   public org.apache.calcite.linq4j.Enumerator enumerator() {
> return new org.apache.calcite.linq4j.Enumerator(){
> public final org.apache.calcite.linq4j.Enumerator 
> inputEnumerator = _inputEnumerable.enumerator();
> public void reset() {
>   inputEnumerator.reset();
> }
> 
> public boolean moveNext() {
>   return inputEnumerator.moveNext();
> }
> 
> public void close() {
>   inputEnumerator.close();
> }
> 
> public Object current() {
>   return (boolean) 
> org.apache.calcite.runtime.SqlFunctions.toDouble(inputEnumerator.current());
> }
> 
>   };
>   }
> 
> };
> }
> 
> 
> public Class getElementType() {
>   return boolean.class;
> }
> 
> 
> 
> at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
> at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest$TesterImpl.check(SqlOperatorBaseTest.java:10371)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:464)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.checkBoolean(AbstractSqlTester.java:433)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest.myTest(SqlOperatorBaseTest.java:1619)
> at 
> org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
> at 
> org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
> at 
> org.junit.jupiter.engine.extension.TimeoutInvocation.proceed(TimeoutInvocation.java:46)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:139)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:131)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:81)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java

[jira] [Commented] (CALCITE-4810) Failed to cast a double field (which isn't a literal) to boolean in the test case.

2021-09-30 Thread Ruben Q L (Jira)


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

Ruben Q L commented on CALCITE-4810:


There are discussions in CALCITE-4777 to decide whether or not we may want to 
forbid casting DOUBLE (and FLOAT/REAL) into BOOLEAN.

> Failed to cast a double field (which isn't a literal) to boolean in the test 
> case.
> --
>
> Key: CALCITE-4810
> URL: https://issues.apache.org/jira/browse/CALCITE-4810
> Project: Calcite
>  Issue Type: Bug
>Reporter: xuyangzhong
>Priority: Minor
>
> The cause of this matter is that when I add a test case in 
> SqlOperatorBaseTest:
> {code:java}
> // code placeholder
>   @Test void myTest(){
> tester.checkBoolean("cast(0.1e0 as boolean)",false);
>   }
> {code}
> The tester will turn the single sql to these two SQLs which will be all 
> tested:
> {code:java}
> // SQL 1 
> values (cast(0.1e0 as boolean))
> // SQL 2
> select cast(p0 as boolean) from (values (0.1e0)) as t(p0)
> {code}
> The SQL1 passed by the RexSimplify. But The SQL2 throws a exception following:
> {code:java}
> // code placeholder
> java.sql.SQLException: Error while executing SQL "select cast(p0 as boolean) 
> from (values (0.1e0)) as t(p0)": Error while compiling generated Java code:
> public org.apache.calcite.linq4j.Enumerable bind(final 
> org.apache.calcite.DataContext root) {
>   final org.apache.calcite.linq4j.Enumerable _inputEnumerable = 
> org.apache.calcite.linq4j.Linq4j.asEnumerable(new Double[] {
> 0.1D});
>   return new org.apache.calcite.linq4j.AbstractEnumerable(){
>   public org.apache.calcite.linq4j.Enumerator enumerator() {
> return new org.apache.calcite.linq4j.Enumerator(){
> public final org.apache.calcite.linq4j.Enumerator 
> inputEnumerator = _inputEnumerable.enumerator();
> public void reset() {
>   inputEnumerator.reset();
> }
> 
> public boolean moveNext() {
>   return inputEnumerator.moveNext();
> }
> 
> public void close() {
>   inputEnumerator.close();
> }
> 
> public Object current() {
>   return (boolean) 
> org.apache.calcite.runtime.SqlFunctions.toDouble(inputEnumerator.current());
> }
> 
>   };
>   }
> 
> };
> }
> 
> 
> public Class getElementType() {
>   return boolean.class;
> }
> 
> 
> 
> at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
> at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest$TesterImpl.check(SqlOperatorBaseTest.java:10371)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:464)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.checkBoolean(AbstractSqlTester.java:433)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest.myTest(SqlOperatorBaseTest.java:1619)
> at 
> org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
> at 
> org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
> at 
> org.junit.jupiter.engine.extension.TimeoutInvocation.proceed(TimeoutInvocation.java:46)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:139)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:131)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:81)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(Invocation

[jira] [Commented] (CALCITE-4810) Failed to cast a double field (which isn't a literal) to boolean in the test case.

2021-09-29 Thread Feng Zhu (Jira)


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

Feng Zhu commented on CALCITE-4810:
---

Any standards can be inferred to help us review the cast behaviors between two 
types?

Maybe we need to check more pairs, rather than only the (_double_, _boolean_) 
case.

> Failed to cast a double field (which isn't a literal) to boolean in the test 
> case.
> --
>
> Key: CALCITE-4810
> URL: https://issues.apache.org/jira/browse/CALCITE-4810
> Project: Calcite
>  Issue Type: Bug
>Reporter: xuyangzhong
>Priority: Minor
>
> The cause of this matter is that when I add a test case in 
> SqlOperatorBaseTest:
> {code:java}
> // code placeholder
>   @Test void myTest(){
> tester.checkBoolean("cast(0.1e0 as boolean)",false);
>   }
> {code}
> The tester will turn the single sql to these two SQLs which will be all 
> tested:
> {code:java}
> // SQL 1 
> values (cast(0.1e0 as boolean))
> // SQL 2
> select cast(p0 as boolean) from (values (0.1e0)) as t(p0)
> {code}
> The SQL1 passed by the RexSimplify. But The SQL2 throws a exception following:
> {code:java}
> // code placeholder
> java.sql.SQLException: Error while executing SQL "select cast(p0 as boolean) 
> from (values (0.1e0)) as t(p0)": Error while compiling generated Java code:
> public org.apache.calcite.linq4j.Enumerable bind(final 
> org.apache.calcite.DataContext root) {
>   final org.apache.calcite.linq4j.Enumerable _inputEnumerable = 
> org.apache.calcite.linq4j.Linq4j.asEnumerable(new Double[] {
> 0.1D});
>   return new org.apache.calcite.linq4j.AbstractEnumerable(){
>   public org.apache.calcite.linq4j.Enumerator enumerator() {
> return new org.apache.calcite.linq4j.Enumerator(){
> public final org.apache.calcite.linq4j.Enumerator 
> inputEnumerator = _inputEnumerable.enumerator();
> public void reset() {
>   inputEnumerator.reset();
> }
> 
> public boolean moveNext() {
>   return inputEnumerator.moveNext();
> }
> 
> public void close() {
>   inputEnumerator.close();
> }
> 
> public Object current() {
>   return (boolean) 
> org.apache.calcite.runtime.SqlFunctions.toDouble(inputEnumerator.current());
> }
> 
>   };
>   }
> 
> };
> }
> 
> 
> public Class getElementType() {
>   return boolean.class;
> }
> 
> 
> 
> at org.apache.calcite.avatica.Helper.createException(Helper.java:56)
> at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:163)
> at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest$TesterImpl.check(SqlOperatorBaseTest.java:10371)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.check(AbstractSqlTester.java:464)
> at 
> org.apache.calcite.sql.test.AbstractSqlTester.checkBoolean(AbstractSqlTester.java:433)
> at 
> org.apache.calcite.sql.test.SqlOperatorBaseTest.myTest(SqlOperatorBaseTest.java:1619)
> at 
> org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:675)
> at 
> org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:125)
> at 
> org.junit.jupiter.engine.extension.TimeoutInvocation.proceed(TimeoutInvocation.java:46)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:139)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:131)
> at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:81)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
> at 
> org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:104)
> at 
> org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:62)
> at 
> org.junit.jupiter.engine.execution.InvocationInt