[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15766475#comment-15766475 ] Khurram Faraaz commented on DRILL-4674: --- Verified, tests are added here https://github.com/mapr/drill-test-framework/tree/master/framework/resources/Functional/case_expr/castTo*.q > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15638242#comment-15638242 ] ASF GitHub Bot commented on DRILL-4674: --- Github user asfgit closed the pull request at: https://github.com/apache/drill/pull/610 > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor$1.run(FragmentExecutor.java:257) >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15632226#comment-15632226 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on the issue: https://github.com/apache/drill/pull/610 @sudheeshkatkam Done. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15630514#comment-15630514 ] ASF GitHub Bot commented on DRILL-4674: --- Github user sudheeshkatkam commented on the issue: https://github.com/apache/drill/pull/610 Can you please squash and rebase? > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15630494#comment-15630494 ] ASF GitHub Bot commented on DRILL-4674: --- Github user sudheeshkatkam commented on the issue: https://github.com/apache/drill/pull/610 +1 > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15630436#comment-15630436 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86230956 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; --- End diff -- Done. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15630437#comment-15630437 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86231467 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { +return numericValue; + } + + public List getLiterals() { +return literals; + } + + /** Contains all literals that are allowed to represent boolean type. */ + private final static MapallLiterals = Maps.newHashMap(); --- End diff -- Done. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15630438#comment-15630438 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86238839 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { +return numericValue; + } + + public List getLiterals() { +return literals; + } + + /** Contains all literals that are allowed to represent boolean type. */ + private final static MapallLiterals = Maps.newHashMap(); + + static { +for (BooleanType booleanType : BooleanType.values()) { + for (String literal : booleanType.getLiterals()) { +allLiterals.put(literal, booleanType); + } +} + } + + /** + * Finds boolean by passed literal. + * Leading or trailing whitespace is ignored, and case does not matter. + * + * @param literal boolean string representation + * @return boolean type + * @throws IllegalArgumentException if boolean type is not found + */ + public static BooleanType get(String literal) { +String value = literal.toLowerCase().trim(); +BooleanType booleanType = allLiterals.get(value); +if (booleanType == null) { + throw new IllegalArgumentException("Invalid value for boolean: " + literal); --- End diff -- Exception is straight-forward, I am not sure it needs additional handling. It returns wrapped up in UserRemoteException. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=#
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15629806#comment-15629806 ] ASF GitHub Bot commented on DRILL-4674: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86201969 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { +return numericValue; + } + + public List getLiterals() { +return literals; + } + + /** Contains all literals that are allowed to represent boolean type. */ + private final static MapallLiterals = Maps.newHashMap(); + + static { +for (BooleanType booleanType : BooleanType.values()) { + for (String literal : booleanType.getLiterals()) { +allLiterals.put(literal, booleanType); + } +} + } + + /** + * Finds boolean by passed literal. + * Leading or trailing whitespace is ignored, and case does not matter. + * + * @param literal boolean string representation + * @return boolean type + * @throws IllegalArgumentException if boolean type is not found + */ + public static BooleanType get(String literal) { +String value = literal.toLowerCase().trim(); +BooleanType booleanType = allLiterals.get(value); +if (booleanType == null) { + throw new IllegalArgumentException("Invalid value for boolean: " + literal); --- End diff -- How is this exception handled? > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15629804#comment-15629804 ] ASF GitHub Bot commented on DRILL-4674: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86201965 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { +return numericValue; + } + + public List getLiterals() { +return literals; + } + + /** Contains all literals that are allowed to represent boolean type. */ + private final static MapallLiterals = Maps.newHashMap(); --- End diff -- Use `org.apache.drill.common.map.CaseInsensitiveMap`? > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15629805#comment-15629805 ] ASF GitHub Bot commented on DRILL-4674: --- Github user sudheeshkatkam commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r86202063 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/BooleanType.java --- @@ -0,0 +1,80 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr; + +import com.google.common.collect.Maps; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals if formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; --- End diff -- final (here and wherever possible below) > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Sudheesh Katkam > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15626121#comment-15626121 ] ASF GitHub Bot commented on DRILL-4674: --- Github user gparai commented on the issue: https://github.com/apache/drill/pull/610 +1 LGTM > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:162) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:104) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.ScreenCreator$ScreenRoot.innerNext(ScreenCreator.java:81) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.BaseRootExec.next(BaseRootExec.java:94) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15625816#comment-15625816 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85945665 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { + return numericValue; +} + + public List getLiterals() { + return literals; +} + + /** + * Finds boolean by passed literal. + * Leading or trailing whitespace is ignored, and case does not matter. + * + * @param literal boolean string representation + * @return boolean type + * @throws IllegalArgumentException if boolean type is not found + */ + public static BooleanType get(String literal) { +String value = literal.toLowerCase().trim(); +for (BooleanType booleanType : BooleanType.values()) { + if(booleanType.getLiterals().contains(value)) { --- End diff -- Done. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15625813#comment-15625813 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85948565 --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java --- @@ -18,18 +18,108 @@ package org.apache.drill.exec.sql; import org.apache.drill.BaseTestQuery; +import org.apache.drill.common.exceptions.UserRemoteException; import org.junit.Test; +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; + public class TestSimpleCastFunctions extends BaseTestQuery { - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleCastFunctions.class); @Test - public void castFromBoolean() throws Exception { -test("select cast(false as varchar(5)), cast(true as varchar(4)), cast((1 < 5) as varchar(4)) from sys.options limit 1;"); + public void testCastFromBooleanToString() throws Exception { +testBuilder() +.sqlQuery("select" + +" cast(false as varchar(5)) c1," + +" cast(true as varchar(4)) c2," + +" cast((1 < 5) as varchar(4)) c3," + +" cast((1 > 5) as varchar(5)) c4" + +" from (values(1))") +.unOrdered() +.baselineColumns("c1", "c2", "c3", "c4") +.baselineValues("false", "true", "true", "false") +.go(); + } + + @Test + public void testCastStringToBooleanTrueValue() throws Exception { +List literals = Arrays.asList("t", "true", "y", "yes", "on", "1"); --- End diff -- Agree. Also added check for leading and trailing spaces. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15625815#comment-15625815 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85945622 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { + return numericValue; --- End diff -- Done. > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15625814#comment-15625814 ] ASF GitHub Bot commented on DRILL-4674: --- Github user arina-ielchiieva commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85948603 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { --- End diff -- Moved to org.apache.drill.exec.expr > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744)
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15607105#comment-15607105 ] ASF GitHub Bot commented on DRILL-4674: --- Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85036858 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { --- End diff -- Is this the desired package to declare BooleanType.java? > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15607108#comment-15607108 ] ASF GitHub Bot commented on DRILL-4674: --- Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85036792 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { + return numericValue; +} + + public List getLiterals() { + return literals; +} + + /** + * Finds boolean by passed literal. + * Leading or trailing whitespace is ignored, and case does not matter. + * + * @param literal boolean string representation + * @return boolean type + * @throws IllegalArgumentException if boolean type is not found + */ + public static BooleanType get(String literal) { +String value = literal.toLowerCase().trim(); +for (BooleanType booleanType : BooleanType.values()) { + if(booleanType.getLiterals().contains(value)) { --- End diff -- if ( > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15607106#comment-15607106 ] ASF GitHub Bot commented on DRILL-4674: --- Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85038037 --- Diff: exec/java-exec/src/test/java/org/apache/drill/exec/sql/TestSimpleCastFunctions.java --- @@ -18,18 +18,108 @@ package org.apache.drill.exec.sql; import org.apache.drill.BaseTestQuery; +import org.apache.drill.common.exceptions.UserRemoteException; import org.junit.Test; +import java.util.Arrays; +import java.util.List; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.junit.Assert.assertThat; + public class TestSimpleCastFunctions extends BaseTestQuery { - static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(TestSimpleCastFunctions.class); @Test - public void castFromBoolean() throws Exception { -test("select cast(false as varchar(5)), cast(true as varchar(4)), cast((1 < 5) as varchar(4)) from sys.options limit 1;"); + public void testCastFromBooleanToString() throws Exception { +testBuilder() +.sqlQuery("select" + +" cast(false as varchar(5)) c1," + +" cast(true as varchar(4)) c2," + +" cast((1 < 5) as varchar(4)) c3," + +" cast((1 > 5) as varchar(5)) c4" + +" from (values(1))") +.unOrdered() +.baselineColumns("c1", "c2", "c3", "c4") +.baselineValues("false", "true", "true", "false") +.go(); + } + + @Test + public void testCastStringToBooleanTrueValue() throws Exception { +List literals = Arrays.asList("t", "true", "y", "yes", "on", "1"); --- End diff -- Would be good to also check for case insensitivity here and in testCastStringToBooleanFalseValue? > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15607107#comment-15607107 ] ASF GitHub Bot commented on DRILL-4674: --- Github user gparai commented on a diff in the pull request: https://github.com/apache/drill/pull/610#discussion_r85036776 --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/BooleanType.java --- @@ -0,0 +1,67 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.drill.exec.expr.fn.impl; + +import java.util.Arrays; +import java.util.List; + +/** + * Enum that contains two boolean types: TRUE and FALSE. + * Each has numeric representation and list of allowed literals. + * List of literals is formed according to + * {@link https://www.postgresql.org/docs/9.6/static/datatype-boolean.html;>Postgre Documentation} + */ +public enum BooleanType { + TRUE(1, Arrays.asList("t", "true", "y", "yes", "on", "1")), + FALSE(0, Arrays.asList("f", "false", "n", "no", "off", "0")); + + private int numericValue; + private List literals; + + BooleanType(int numericValue, List literals) { +this.numericValue = numericValue; +this.literals = literals; + } + + public int getNumericValue() { + return numericValue; --- End diff -- Please correct alignment here and in getLiterals() > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Gautam Kumar Parai > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) >
[jira] [Commented] (DRILL-4674) Allow casting to boolean the same literals as in Postgre
[ https://issues.apache.org/jira/browse/DRILL-4674?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=15568460#comment-15568460 ] ASF GitHub Bot commented on DRILL-4674: --- GitHub user arina-ielchiieva opened a pull request: https://github.com/apache/drill/pull/610 DRILL-4674: Allow casting to boolean the same literals as in Postgre You can merge this pull request into a Git repository by running: $ git pull https://github.com/arina-ielchiieva/drill DRILL-4674 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/drill/pull/610.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #610 commit 92d33880f480eb6f39e08ecedb2aa3c642542801 Author: Arina IelchiievaDate: 2016-10-11T16:30:14Z DRILL-4674: Allow casting to boolean the same literals as in Postgre > Allow casting to boolean the same literals as in Postgre > > > Key: DRILL-4674 > URL: https://issues.apache.org/jira/browse/DRILL-4674 > Project: Apache Drill > Issue Type: Improvement > Components: Execution - Data Types >Affects Versions: 1.7.0 > Environment: 4 node cluster CentOS >Reporter: Khurram Faraaz >Assignee: Arina Ielchiieva > Labels: doc-impacting > Fix For: 1.9.0 > > > Drill does not return results when we try to cast 0 and 1 to boolean inside a > value constructor. > Drill version : 1.7.0-SNAPSHOT commit ID : 09b26277 > {noformat} > 0: jdbc:drill:schema=dfs.tmp> values(cast(1 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 1 > Fragment 0:0 > [Error Id: 35dcc4bb-0c5d-466f-8fb5-cf7f0a892155 on centos-02.qa.lab:31010] > (state=,code=0) > 0: jdbc:drill:schema=dfs.tmp> values(cast(0 as boolean)); > Error: SYSTEM ERROR: IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > (state=,code=0) > {noformat} > Where as we get results on Postgres for same query. > {noformat} > postgres=# values(cast(1 as boolean)); > column1 > - > t > (1 row) > postgres=# values(cast(0 as boolean)); > column1 > - > f > (1 row) > {noformat} > Stack trace from drillbit.log > {noformat} > 2016-05-13 07:16:16,578 [28ca80bf-0af9-bc05-258b-6b5744739ed8:frag:0:0] ERROR > o.a.d.e.w.fragment.FragmentExecutor - SYSTEM ERROR: IllegalArgumentException: > Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: > IllegalArgumentException: Invalid value for boolean: 0 > Fragment 0:0 > [Error Id: 2dbcafe2-92c7-475e-a2aa-9745ef72c1cc on centos-02.qa.lab:31010] > at > org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:543) > ~[drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:318) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:185) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:287) > [drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38) > [drill-common-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) > [na:1.7.0_45] > at > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) > [na:1.7.0_45] > at java.lang.Thread.run(Thread.java:744) [na:1.7.0_45] > Caused by: java.lang.IllegalArgumentException: Invalid value for boolean: 0 > at > org.apache.drill.exec.test.generated.ProjectorGen9.doSetup(ProjectorTemplate.java:95) > ~[na:na] > at > org.apache.drill.exec.test.generated.ProjectorGen9.setup(ProjectorTemplate.java:93) > ~[na:na] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.setupNewSchema(ProjectRecordBatch.java:444) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.record.AbstractSingleRecordBatch.innerNext(AbstractSingleRecordBatch.java:78) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at > org.apache.drill.exec.physical.impl.project.ProjectRecordBatch.innerNext(ProjectRecordBatch.java:129) > ~[drill-java-exec-1.7.0-SNAPSHOT.jar:1.7.0-SNAPSHOT] > at >