[jira] [Commented] (CALCITE-2209) Support loading JSON model file through URL

2018-05-31 Thread Rong Rong (JIRA)


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

Rong Rong commented on CALCITE-2209:


Thanks for the pointer, I added a test for custom URLStreamHandlerFactory. 
Wasn't sure if it is the right way since official document indicates that the 
URL.setURLStreamHandlerFactory() method should only be called once every JVM. 
Please let me know if the implementation is non-intrusive. 

> Support loading JSON model file through URL
> ---
>
> Key: CALCITE-2209
> URL: https://issues.apache.org/jira/browse/CALCITE-2209
> Project: Calcite
>  Issue Type: New Feature
>  Components: core
>Reporter: Shuyi Chen
>Assignee: Shuyi Chen
>Priority: Major
>
> Currently, Calcite only support loading JSON model file through inline or 
> local file. The Jira attemps to extend it to support loading JSON model file 
> through URL, so users can implement their own URLStreamHandlerFactory to read 
> the JSON model file from e.g., HDFS or etc.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2302) Implicit type cast support

2018-05-31 Thread Yuzhao Chen (JIRA)


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

Yuzhao Chen commented on CALCITE-2302:
--

Hi, committers, can you give me some suggestions? Our users really need this 
implicit type coercion, i considered to implement this function outside Calcite 
but it always validates fails, finally i added it in the Calcite validation 
process, and this seems the only way to, so i really appreciate for your 
suggestions.

In total, i wanna know if this implementation is ok for now the Calcite 
architecture, and if there are some hidden trouble or negative effects.

The test cases in Calcite are all ok and desirable, also the Cases i added in 
TypeCoercionTest.java. But i think this need more cases which computing real 
dataset and output the right answers.

I plan to add more test cases from Hive/Mysql/Spark in and then let this 
function default open in our product cluster.

So really look forward to your suggestions if you have time.

> Implicit type cast support
> --
>
> Key: CALCITE-2302
> URL: https://issues.apache.org/jira/browse/CALCITE-2302
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.17.0
>Reporter: Yuzhao Chen
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.
> Implicit type cast is an useful function for many cases, So we should support 
> this.
> I checkout Calcite code and found that:
>  # Now we use a validator to validate our operands types[ through kinds of 
> namespaces and scopes ]
>  # Most of the validations will finally goes to
> {code:java}
> SqlOperator.validateOperands
> {code}
>  # which will use validation logic defined in corresponding 
> SqlOperandTypeChecker
> What i'm confused about is where should i put the implicit type cast logic 
> in? I figured out 2 ways:
>  # Supply a tool class/rules to add casts into a parsed SqlNode tree which 
> will then go through the validation logic later on.
>  # Unleash the validation logic in kinds of SqlOperandTypeChecker, then 
> modify the RelNode/RexNodes tree converted from a validated SqlNode tree to 
> add in casts through custom RelOptRules.
> So guys, which of the 2 ways should i go, or if there are better way to do 
> this?
> I need your help.
>  
> Updated 18-05-30:
> Hi guys, i have made a PR in 
> [CALCITE-2302|https://github.com/apache/calcite/pull/706]
> This is design doc: [Calcite Implicit Type Cast 
> Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].
> This is the conversion types mapping: [Conversion Types 
> Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].
> I really appreciate your suggestions, thx.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread yuqi (JIRA)


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

yuqi commented on CALCITE-2336:
---

[~xu fei] You can make a MR about this problem or i do it later

> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
> Attachments: 1.patch
>
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType validateSelectList(
> final SqlNodeList selectItems,
> SqlSelect select,
> RelDataType targetRowType) {
>   // First pass, ensure that aliases are unique. "*" and "TABLE.*" items
>   // are ignored.
>   // Validate SELECT list. Expand terms of the form "*" or "TABLE.*".
>   final SqlValidatorScope selectScope = getSelectScope(select);
>   final List expandedSelectItems = new ArrayList<>();
>   final Set aliases = Sets.newHashSet();
>   final List> fieldList = new ArrayList<>();
>   for (int i = 0; i < selectItems.size(); i++) {
> SqlNode selectItem = selectItems.get(i);
> if (selectItem instanceof SqlSelect) {
>   handleScalarSubQuery(
>   select,
>   (SqlSelect) selectItem,
>   expandedSelectItems,
>   aliases,
>   fieldList);
> } else {
>   expandSelectItem(
>   selectItem,
>   select,
>   targetRowType.isStruct()
>   && targetRowType.getFieldCount() >= i
>   ? targetRowType.getFieldList().get(i).getType()
>   : unknownType,
>   expandedSelectItems,
>   aliases,
>   fieldList,
>   false);
> }
>   }
> {code}
> See the exception is throw from here, if selectItems's size more than 
> targetRowType's field count
> {code:java}
> && targetRowType.getFieldCount() >= i
> ? targetRowType.getFieldList().get(i).getType(){code}
> When I change it to this, I get what I need.
> {code:java}
> && targetRowType.getFieldCount() - 1 >= i  
> ? targetRowType.getFieldList().get(i).getType(){code}
> So is this a Bug ? Do we need fix it ? 
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread Fei Xu (JIRA)


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

Fei Xu commented on CALCITE-2336:
-

Thanks, It's more clear

> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
> Attachments: 1.patch
>
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType validateSelectList(
> final SqlNodeList selectItems,
> SqlSelect select,
> RelDataType targetRowType) {
>   // First pass, ensure that aliases are unique. "*" and "TABLE.*" items
>   // are ignored.
>   // Validate SELECT list. Expand terms of the form "*" or "TABLE.*".
>   final SqlValidatorScope selectScope = getSelectScope(select);
>   final List expandedSelectItems = new ArrayList<>();
>   final Set aliases = Sets.newHashSet();
>   final List> fieldList = new ArrayList<>();
>   for (int i = 0; i < selectItems.size(); i++) {
> SqlNode selectItem = selectItems.get(i);
> if (selectItem instanceof SqlSelect) {
>   handleScalarSubQuery(
>   select,
>   (SqlSelect) selectItem,
>   expandedSelectItems,
>   aliases,
>   fieldList);
> } else {
>   expandSelectItem(
>   selectItem,
>   select,
>   targetRowType.isStruct()
>   && targetRowType.getFieldCount() >= i
>   ? targetRowType.getFieldList().get(i).getType()
>   : unknownType,
>   expandedSelectItems,
>   aliases,
>   fieldList,
>   false);
> }
>   }
> {code}
> See the exception is throw from here, if selectItems's size more than 
> targetRowType's field count
> {code:java}
> && targetRowType.getFieldCount() >= i
> ? targetRowType.getFieldList().get(i).getType(){code}
> When I change it to this, I get what I need.
> {code:java}
> && targetRowType.getFieldCount() - 1 >= i  
> ? targetRowType.getFieldList().get(i).getType(){code}
> So is this a Bug ? Do we need fix it ? 
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Created] (CALCITE-2347) embedded ElasticSearch node for ES adapter unit tests

2018-05-31 Thread Andrei Sereda (JIRA)
Andrei Sereda created CALCITE-2347:
--

 Summary: embedded ElasticSearch node for ES adapter unit tests
 Key: CALCITE-2347
 URL: https://issues.apache.org/jira/browse/CALCITE-2347
 Project: Calcite
  Issue Type: Improvement
  Components: elasticsearch-adapter
Reporter: Andrei Sereda
Assignee: Julian Hyde


Currently ES adapter integration tests require manual startup of elastic 
cluster. Elastic node can also be started programmatically and embedded in a 
java application. Init costs are small enough to be run as part of unit test.

The plan is to migrate (re-use) exiting IT to be executed as part of unit test 
as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread Francis Chuang (JIRA)


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

Francis Chuang commented on CALCITE-2022:
-

I think we can go ahead and make this part of 1.12. The fix seems pretty 
straight forward and the release will be tested on Windows as well.

> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

Github user F21 commented on the issue:

https://github.com/apache/calcite-avatica/pull/54
  
Thanks for merging! I'll update rebase the release branch.


> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread Josh Elser (JIRA)


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

Josh Elser commented on CALCITE-2022:
-

Similarly, leaving this open until we figure out if this will be in 
avatica-1.12 or just in avatica-1.13.

[~francischuang]

> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

Github user asfgit closed the pull request at:

https://github.com/apache/calcite-avatica/pull/54


> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

Github user joshelser commented on the issue:

https://github.com/apache/calcite-avatica/pull/54
  
Perfect, thanks for the fix, @snuyanzin!

FYI @F21. I'd pull this over to branch-avatica-1.12, but I see you have 
already updated it in prep for the release.  Don't want to mess you up :)


> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (CALCITE-2285) Support client cert keystore for Avatica Client

2018-05-31 Thread Karan Mehta (JIRA)


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

Karan Mehta edited comment on CALCITE-2285 at 5/31/18 8:55 PM:
---

Jetty offers client/server classes which allow dynamic reloading of 
{{SslContextFactory}} when ever new certificates are loaded, especially for 
short lived certificates. Avatica Client depends on Apache HttpClient lib, 
which doesn't offer that feature. Long running Java clients can potentially run 
into issues with this. 

Any thoughts/ideas? [~alexaraujo] [~risdenk]
 I am currently looking into other potential ideas especially how things are 
implemented in Jetty and will post soon. I am also looking for approaches where 
a reference to {{SSLConnectionSocketFactory}} can be dynamically updated 
whenever the underlying cert changes.


was (Author: karanmehta93):
Jetty offers client/server classes which allow dynamic reloading of 
{{SslContextFactory}} when ever new certificates are loaded, especially for 
short lived certificates. Avatica Client depends on Apache HttpClient lib, 
which doesn't offer that feature. Long running Java clients can potentially run 
into issues with this. 

Any thoughts/ideas? [~alexaraujo] [~risdenk]
I am currently looking into other potential ideas and will post soon.

> Support client cert keystore for Avatica Client
> ---
>
> Key: CALCITE-2285
> URL: https://issues.apache.org/jira/browse/CALCITE-2285
> Project: Calcite
>  Issue Type: Improvement
>  Components: avatica
>Reporter: Karan Mehta
>Assignee: Karan Mehta
>Priority: Major
>
> Currently Avatica only supports adding trust-store in {{SSLContext}} in all 
> {{AvaticaHttpClient}} implementations. If keystore support it added, MTLS 
> connections can be established as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2285) Support client cert keystore for Avatica Client

2018-05-31 Thread Karan Mehta (JIRA)


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

Karan Mehta commented on CALCITE-2285:
--

Jetty offers client/server classes which allow dynamic reloading of 
{{SslContextFactory}} when ever new certificates are loaded, especially for 
short lived certificates. Avatica Client depends on Apache HttpClient lib, 
which doesn't offer that feature. Long running Java clients can potentially run 
into issues with this. 

Any thoughts/ideas? [~alexaraujo] [~risdenk]
I am currently looking into other potential ideas and will post soon.

> Support client cert keystore for Avatica Client
> ---
>
> Key: CALCITE-2285
> URL: https://issues.apache.org/jira/browse/CALCITE-2285
> Project: Calcite
>  Issue Type: Improvement
>  Components: avatica
>Reporter: Karan Mehta
>Assignee: Karan Mehta
>Priority: Major
>
> Currently Avatica only supports adding trust-store in {{SSLContext}} in all 
> {{AvaticaHttpClient}} implementations. If keystore support it added, MTLS 
> connections can be established as well.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Michael Mior (JIRA)


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

Michael Mior commented on CALCITE-2345:
---

If they take too long, one option would be to only enable those tests when run 
with the integration profile. At least that way we would still have the same 
interface for all the tests.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Andrei Sereda (JIRA)


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

Andrei Sereda commented on CALCITE-2345:


Hmm. My concern is that unit tests have to be fast. Populating fakes with full 
data-set will be slow (zips.json has  ~30k records). 

In practice, I've never managed to have solely unit or integration tests. It 
was always a combination of two (not to mention performance tests).

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2344) Wrong constant reduction over windows function

2018-05-31 Thread Laurent Goujon (JIRA)


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

Laurent Goujon commented on CALCITE-2344:
-

So I guess there are two issues?
1/ the return type of some aggregate functions (min/max/... but not count) 
should be nullable but isn't
2/ if the return type is not nullable, a wrong inference in RexUtil causes 
parser to barf

My patch seems to address 2/ but I didn't realize about 1/ for sure.

> Wrong constant reduction over windows function
> --
>
> Key: CALCITE-2344
> URL: https://issues.apache.org/jira/browse/CALCITE-2344
> Project: Calcite
>  Issue Type: Bug
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{RexUtil}} might incorrectly infer a IS NULL predicate would cause a 
> reference over a window function to return null, but a window function type 
> is never nullable.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Michael Mior (JIRA)


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

Michael Mior commented on CALCITE-2345:
---

If we're moving towards unifying the integration tests and unit tests with the 
fake then I don't have a problem with using the zips dataset. We may want to 
publish this as a separate package to keep the size down however. This would be 
similar to how calcite-test-dataset pulls in the foodmart data.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Andrei Sereda (JIRA)


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

Andrei Sereda commented on CALCITE-2345:


I will work to have a single test for Mongo Adapter.

But you need to decide what to use for data seed. Existing IT are using 
external datasource (populated  by zips.json) which is not available during 
unit tests. 

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2341) ImmutableBitSetTest fails with JDK11

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2341:
--

I saw some javadoc failures under JDK 11. While you're in the code, can you fix 
those also. It would be good to get 100% clean builds under JDK 11.

> ImmutableBitSetTest fails with JDK11
> 
>
> Key: CALCITE-2341
> URL: https://issues.apache.org/jira/browse/CALCITE-2341
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Minor
>
> A error message change in JDK11 causes ImmutableBitSetTest to fail



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Issue Comment Deleted] (CALCITE-2342) use of assert with side-effect in Schemas

2018-05-31 Thread Julian Hyde (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2342?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Julian Hyde updated CALCITE-2342:
-
Comment: was deleted

(was: I saw some javadoc failures under JDK 11. While you're in the code, can 
you fix those also.)

> use of assert with side-effect in Schemas
> -
>
> Key: CALCITE-2342
> URL: https://issues.apache.org/jira/browse/CALCITE-2342
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{Schemas#path(CalciteSchema,Iterable)}} method has the following 
> code:
> {code:java}
> if (!rootSchema.name.isEmpty()) {
>   assert rootSchema.name.equals(iterator.next());
> }
> {code}
> Depending if assertions are enabled or not, iterator state might be different



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2342) use of assert with side-effect in Schemas

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2342:
--

I saw some javadoc failures under JDK 11. While you're in the code, can you fix 
those also.

> use of assert with side-effect in Schemas
> -
>
> Key: CALCITE-2342
> URL: https://issues.apache.org/jira/browse/CALCITE-2342
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{Schemas#path(CalciteSchema,Iterable)}} method has the following 
> code:
> {code:java}
> if (!rootSchema.name.isEmpty()) {
>   assert rootSchema.name.equals(iterator.next());
> }
> {code}
> Depending if assertions are enabled or not, iterator state might be different



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Michael Mior (JIRA)


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

Michael Mior commented on CALCITE-2345:
---

Based on discussion on the mailing list, [~asereda] is willing to keep working 
on this. I'm happy to help out if needed. I'm leaning the other way because we 
can always just delete the new tests if they cause problems, so it seems like 
minimal regret.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2345:
--

[~michaelmior] I'm not criticizing you. It's a 45:55 decision. I had a slight 
preference for the other option, that's all.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2345:
--

{quote}until we manage to unify these tests
{quote}
Who is the "we" who is going to do this work? If it is not [~asereda], right 
now, is is no one. We do not have a maintainer for the Mongo adapter.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2344) Wrong constant reduction over windows function

2018-05-31 Thread Laurent Goujon (JIRA)


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

Laurent Goujon commented on CALCITE-2344:
-

Attaching pull request with 2 test cases added to RelOptRulesTests and a 
possible fix

> Wrong constant reduction over windows function
> --
>
> Key: CALCITE-2344
> URL: https://issues.apache.org/jira/browse/CALCITE-2344
> Project: Calcite
>  Issue Type: Bug
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{RexUtil}} might incorrectly infer a IS NULL predicate would cause a 
> reference over a window function to return null, but a window function type 
> is never nullable.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2344) Wrong constant reduction over windows function

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2344:
--

If an aggregate function is applied over 0 rows - i.e. an empty window - then 
the result is null. This applies to min, max, sum, but not count.

> Wrong constant reduction over windows function
> --
>
> Key: CALCITE-2344
> URL: https://issues.apache.org/jira/browse/CALCITE-2344
> Project: Calcite
>  Issue Type: Bug
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{RexUtil}} might incorrectly infer a IS NULL predicate would cause a 
> reference over a window function to return null, but a window function type 
> is never nullable.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2344) Wrong constant reduction over windows function

2018-05-31 Thread Laurent Goujon (JIRA)


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

Laurent Goujon commented on CALCITE-2344:
-

I tried the following query:
{code:sql}
select empno, deptno, w_count from (
  select empno, deptno, count(empno) over (ROWS BETWEEN 10 PRECEDING AND 1 
PRECEDING) w_count
  from emp
) sub_query where w_count is null
{code}

In {{RelOptRulesTest}} I configured a preplanner with the 
{{ProjectToWindowRule.PROJECT}} rule and then a planner with the 
{{ReduceExpressionsRule.PROJECT_INSTANCE}}. I got the following exception:
{noformat}
java.lang.AssertionError: Cannot add expression of different type to set:
set type is RecordType(INTEGER NOT NULL EMPNO, INTEGER NOT NULL DEPTNO, BIGINT 
NOT NULL W_COUNT) NOT NULL
expression type is RecordType(INTEGER NOT NULL EMPNO, INTEGER NOT NULL DEPTNO, 
BIGINT W_COUNT) NOT NULL
set is 
rel#26:LogicalProject(input=HepRelVertex#25,EMPNO=$0,DEPTNO=$1,W_COUNT=$2)
expression is LogicalProject#28
at 
org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:410)
at 
org.apache.calcite.plan.hep.HepRuleCall.transformTo(HepRuleCall.java:57)
at 
org.apache.calcite.plan.RelOptRuleCall.transformTo(RelOptRuleCall.java:234)
at 
org.apache.calcite.rel.rules.ReduceExpressionsRule$ProjectReduceExpressionsRule.onMatch(ReduceExpressionsRule.java:290)
at 
org.apache.calcite.plan.AbstractRelOptPlanner.fireRule(AbstractRelOptPlanner.java:317)
at org.apache.calcite.plan.hep.HepPlanner.applyRule(HepPlanner.java:556)
at 
org.apache.calcite.plan.hep.HepPlanner.applyRules(HepPlanner.java:415)
at 
org.apache.calcite.plan.hep.HepPlanner.executeInstruction(HepPlanner.java:252)
at 
org.apache.calcite.plan.hep.HepInstruction$RuleInstance.execute(HepInstruction.java:127)
at 
org.apache.calcite.plan.hep.HepPlanner.executeProgram(HepPlanner.java:211)
at 
org.apache.calcite.plan.hep.HepPlanner.findBestExp(HepPlanner.java:198)
at 
org.apache.calcite.test.RelOptTestBase.checkPlanning(RelOptTestBase.java:170)
at 
org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:315)
at 
org.apache.calcite.test.RelOptTestBase$Sql.check(RelOptTestBase.java:299)
at 
org.apache.calcite.test.RelOptRulesTest.testIsNullPushDown2(RelOptRulesTest.java:3027)
{noformat}

> Wrong constant reduction over windows function
> --
>
> Key: CALCITE-2344
> URL: https://issues.apache.org/jira/browse/CALCITE-2344
> Project: Calcite
>  Issue Type: Bug
>Reporter: Laurent Goujon
>Assignee: Laurent Goujon
>Priority: Major
>
> {{RexUtil}} might incorrectly infer a IS NULL predicate would cause a 
> reference over a window function to return null, but a window function type 
> is never nullable.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Michael Mior (JIRA)


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

Michael Mior commented on CALCITE-2345:
---

Agreed that it is added complexity, which is far from ideal. But if it can 
potentially prevent issues with the adapter now until we manage to unify these 
tests, I'm still for it. I'm open to reverting though if you feel strongly that 
the extra complexity isn't worth the benefit.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Julian Hyde (JIRA)


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

Julian Hyde commented on CALCITE-2345:
--

After this change, we have both MongoAdapterIT and MongoAdapterTest. That's 
more complexity. I'd like to rationalize down to a single test now.

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

Github user snuyanzin commented on the issue:

https://github.com/apache/calcite-avatica/pull/54
  
yes, before fix it failed like 
```
java.lang.AssertionError: 
Expected: is "C:\my\truststore.jks"
 but: was "D:\my\truststore.jks"
Expected :C:\my\truststore.jks
Actual   :D:\my\truststore.jks
```

at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
at org.junit.Assert.assertThat(Assert.java:956)
at org.junit.Assert.assertThat(Assert.java:923)
at 
org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:42)
 


> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

Github user joshelser commented on the issue:

https://github.com/apache/calcite-avatica/pull/54
  
@snuyanzin thanks for the change. Have you tested this on Windows?


> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2346?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Marc Prud'hommeaux updated CALCITE-2346:

Description: 
Trying to union results from two separate data types is throwing:

{code:none}
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
java.base/java.lang.Integer
at 
org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
at sqlline.SqlLine.print(SqlLine.java:1648)

{code}

It can reproduced with the command:

{code:none}
coursier launch \
  sqlline:sqlline:1.4.0 \
  org.apache.calcite:calcite-core:1.16.0 \
  org.hsqldb:hsqldb:2.4.0 \
  net.hydromatic:scott-data-hsqldb:0.1 \
  net.hydromatic:foodmart-data-hsqldb:0.4 \
  -M sqlline.SqlLine -- \
  -d org.apache.calcite.jdbc.Driver \
  -u 
'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
 
{code}


The following command works fine:

{code:none}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from 
"scott"."DEPT" union all select "department_description" from 
"foodmart"."department";
++
| DNAME  |
++
| ACCOUNTING |
| RESEARCH   |
| SALES  |
| OPERATIONS |
| HQ General Management  |
| HQ Information Systems |
| HQ Marketing   |
| HQ Human Resources |
| HQ Finance and Accounting  |
| Store Management   |
| Store Information Systems  |
| Store Permanent Checkers   |
| Store Temporary Checkers   |
| Store Permanent Stockers   |
| Store Temporary Stockers   |
| Store Permanent Butchers   |
++
16 rows selected (0.069 seconds)
{code}

But when unioning two different column types:

{code:none}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DEPTNO", "DNAME" from 
"scott"."DEPT" union all select "department_id", "department_description" from 
"foodmart"."department";
+++
|   DEPTNO   | DNAME  |
+++
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
java.base/java.lang.Integer
at 
org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
at sqlline.SqlLine.print(SqlLine.java:1648)
at sqlline.Commands.execute(Commands.java:834)
at sqlline.Commands.sql(Commands.java:733)
at sqlline.SqlLine.dispatch(SqlLine.java:795)
{code}

Possibly related: https://issues.apache.org/jira/browse/CALCITE-580


  was:
Trying to union results from two separate data types is throwing:

{code:java}
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
java.base/java.lang.Integer
at 
org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
at sqlline.SqlLine.print(SqlLine.java:1648)

{code}

It can reproduced with the command:

{code:java}
coursier launch \
  sqlline:sqlline:1.4.0 \
  org.apache.calcite:calcite-core:1.16.0 \
  org.hsqldb:hsqldb:2.4.0 \
  net.hydromatic:scott-data-hsqldb:0.1 \
  net.hydromatic:foodmart-data-hsqldb:0.4 \
  -M sqlline.SqlLine -- \
  -d org.apache.calcite.jdbc.Driver \
  -u 
'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
 
{code}


The following 

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:37 PM:
--

I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{code:none}
0: jdbc:calcite:model=inline:> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   14
ORDINAL_POSITION2
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME LOC
DATA_TYPE   12
TYPE_NAME   VARCHAR(13) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 13
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   13
ORDINAL_POSITION3
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "foodmart"."department"
TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_id
DATA_TYPE   4
TYPE_NAME   INTEGER NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_description
DATA_TYPE   12
TYPE_NAME   VARCHAR(30) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary" NOT NULL
COLUMN_SIZE 30
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   30
ORDINAL_POSITION2
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  
{code}


was (Author: mprudhom):
I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{code:none}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:36 PM:
--

Also, a much simpler query can more easily demonstrate the issue:

{code:none}
0: jdbc:calcite:model=inline:> select 1.0 union all select 2;
EXPR$0  1.0

java.lang.ClassCastException: java.base/java.lang.Integer cannot be cast to 
java.base/java.math.BigDecimal
at 
org.apache.calcite.avatica.util.AbstractCursor$BigDecimalAccessor.getBigDecimal(AbstractCursor.java:705)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:328)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.VerticalOutputFormat.print(VerticalOutputFormat.java:28)
at sqlline.SqlLine.print(SqlLine.java:1648)
at sqlline.Commands.execute(Commands.java:834)
at sqlline.Commands.sql(Commands.java:733)
{code}



was (Author: mprudhom):
Also, a much simpler query can more easily demonstrate the issue:

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> select 1.0 union all select 2;
EXPR$0  1.0

java.lang.ClassCastException: java.base/java.lang.Integer cannot be cast to 
java.base/java.math.BigDecimal
at 
org.apache.calcite.avatica.util.AbstractCursor$BigDecimalAccessor.getBigDecimal(AbstractCursor.java:705)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:328)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.VerticalOutputFormat.print(VerticalOutputFormat.java:28)
at sqlline.SqlLine.print(SqlLine.java:1648)
at sqlline.Commands.execute(Commands.java:834)
at sqlline.Commands.sql(Commands.java:733)
{code}


> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from 
> "scott"."DEPT" union all select "department_description" from 
> "foodmart"."department";
> ++
> | DNAME  |
> ++
> | ACCOUNTING |
> | RESEARCH   |
> | SALES  |
> | OPERATIONS |
> | HQ General Management  |
> | HQ Information Systems |
> | HQ Marketing   |
> | HQ Human Resources |
> | HQ Finance and Accounting  |
> | Store Management   |
> | Store Information Systems  |
> | Store Permanent Checkers   |
> | Store Temporary Checkers   |
> | Store Permanent Stockers   |
> | Store Temporary 

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:36 PM:
--

I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{code:none}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   14
ORDINAL_POSITION2
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME LOC
DATA_TYPE   12
TYPE_NAME   VARCHAR(13) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 13
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   13
ORDINAL_POSITION3
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "foodmart"."department"
TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_id
DATA_TYPE   4
TYPE_NAME   INTEGER NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_description
DATA_TYPE   12
TYPE_NAME   VARCHAR(30) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary" NOT NULL
COLUMN_SIZE 30
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   30
ORDINAL_POSITION2
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  
{code}


was (Author: mprudhom):
I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:35 PM:
--

And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code:none}
0: jdbc:calcite:model=inline> select cast("DEPTNO" as int), "DNAME" from 
"scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}


was (Author: mprudhom):
And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code:SQL}
0: jdbc:calcite:model=inline> select cast("DEPTNO" as int), "DNAME" from 
"scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}

> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}
> 0: 

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:35 PM:
--

And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code:Bash}
0: jdbc:calcite:model=inline> select cast("DEPTNO" as int), "DNAME" from 
"scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}


was (Author: mprudhom):
And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> select cast("DEPTNO" as int), 
"DNAME" from "scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}

> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:35 PM:
--

And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code:SQL}
0: jdbc:calcite:model=inline> select cast("DEPTNO" as int), "DNAME" from 
"scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}


was (Author: mprudhom):
And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code:Bash}
0: jdbc:calcite:model=inline> select cast("DEPTNO" as int), "DNAME" from 
"scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}

> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}
> 0: 

[jira] [Resolved] (CALCITE-2345) add tests using Fongo to Mongo Adapter

2018-05-31 Thread Michael Mior (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2345?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Michael Mior resolved CALCITE-2345.
---
Resolution: Fixed
  Assignee: Michael Mior  (was: Julian Hyde)

> add tests using Fongo to Mongo Adapter
> --
>
> Key: CALCITE-2345
> URL: https://issues.apache.org/jira/browse/CALCITE-2345
> Project: Calcite
>  Issue Type: Improvement
>Reporter: Andrei Sereda
>Assignee: Michael Mior
>Priority: Major
>
> Better test coverage for unit tests using 
> [Fongo|https://github.com/fakemongo/fongo] which is in-memory implementation 
> of Mongo API.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux commented on CALCITE-2346:
-

And I will lastly add that this issue can be worked around be explicitly 
casting the heterogeneous columns to the same type:

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> select cast("DEPTNO" as int), 
"DNAME" from "scott"."DEPT" union all select cast("department_id" as int), 
"department_description" from "foodmart"."department" order by 1;
+++
|   EXPR$0   | DNAME  |
+++
| 1  | HQ General Management  |
| 2  | HQ Information Systems |
| 3  | HQ Marketing   |
| 4  | HQ Human Resources |
| 5  | HQ Finance and Accounting  |
| 10 | ACCOUNTING |
| 11 | Store Management   |
| 14 | Store Information Systems  |
| 15 | Store Permanent Checkers   |
| 16 | Store Temporary Checkers   |
| 17 | Store Permanent Stockers   |
| 18 | Store Temporary Stockers   |
| 19 | Store Permanent Butchers   |
| 20 | RESEARCH   |
| 30 | SALES  |
| 40 | OPERATIONS |
+++
{code}

> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from 
> "scott"."DEPT" union all select "department_description" from 
> "foodmart"."department";
> ++
> | DNAME  |
> ++
> | ACCOUNTING |
> | RESEARCH   |
> | SALES  |
> | OPERATIONS |
> | HQ General Management  |
> | HQ Information Systems |
> | HQ Marketing   |
> | HQ Human Resources |
> | HQ Finance and Accounting  |
> | Store Management   |
> | Store Information Systems  |
> | Store Permanent Checkers   |
> | Store Temporary Checkers   |
> | Store Permanent Stockers   |
> | Store Temporary Stockers   |
> | Store Permanent Butchers   |
> ++
> 16 rows selected (0.069 seconds)
> {code}
> But when unioning two different column types:
> {code:java}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> select "DEPTNO", "DNAME" from 
> "scott"."DEPT" union all select "department_id", "department_description" 
> from "foodmart"."department";
> +++
> |   DEPTNO   | DNAME  |
> +++
> java.lang.ClassCastException: 

[jira] [Commented] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux commented on CALCITE-2346:
-

Also, a much simpler query can more easily demonstrate the issue:

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> select 1.0 union all select 2;
EXPR$0  1.0

java.lang.ClassCastException: java.base/java.lang.Integer cannot be cast to 
java.base/java.math.BigDecimal
at 
org.apache.calcite.avatica.util.AbstractCursor$BigDecimalAccessor.getBigDecimal(AbstractCursor.java:705)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:328)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.VerticalOutputFormat.print(VerticalOutputFormat.java:28)
at sqlline.SqlLine.print(SqlLine.java:1648)
at sqlline.Commands.execute(Commands.java:834)
at sqlline.Commands.sql(Commands.java:733)
{code}


> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
>   at sqlline.SqlLine.print(SqlLine.java:1648)
> {code}
> It can reproduced with the command:
> {code:java}
> coursier launch \
>   sqlline:sqlline:1.4.0 \
>   org.apache.calcite:calcite-core:1.16.0 \
>   org.hsqldb:hsqldb:2.4.0 \
>   net.hydromatic:scott-data-hsqldb:0.1 \
>   net.hydromatic:foodmart-data-hsqldb:0.4 \
>   -M sqlline.SqlLine -- \
>   -d org.apache.calcite.jdbc.Driver \
>   -u 
> 'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
>  
> {code}
> The following command works fine:
> {code:java}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from 
> "scott"."DEPT" union all select "department_description" from 
> "foodmart"."department";
> ++
> | DNAME  |
> ++
> | ACCOUNTING |
> | RESEARCH   |
> | SALES  |
> | OPERATIONS |
> | HQ General Management  |
> | HQ Information Systems |
> | HQ Marketing   |
> | HQ Human Resources |
> | HQ Finance and Accounting  |
> | Store Management   |
> | Store Information Systems  |
> | Store Permanent Checkers   |
> | Store Temporary Checkers   |
> | Store Permanent Stockers   |
> | Store Temporary Stockers   |
> | Store Permanent Butchers   |
> ++
> 16 rows selected (0.069 seconds)
> {code}
> But when unioning two different column types:
> {code:java}
> 0: jdbc:calcite:model=inline:{"version":1.0,"> select "DEPTNO", "DNAME" from 
> "scott"."DEPT" union all select "department_id", "department_description" 
> from "foodmart"."department";
> +++
> |   DEPTNO   | DNAME  |
> +++
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at 

[jira] [Comment Edited] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux edited comment on CALCITE-2346 at 5/31/18 2:23 PM:
--

I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{code}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   14
ORDINAL_POSITION2
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME LOC
DATA_TYPE   12
TYPE_NAME   VARCHAR(13) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 13
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   13
ORDINAL_POSITION3
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "foodmart"."department"
TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_id
DATA_TYPE   4
TYPE_NAME   INTEGER NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_description
DATA_TYPE   12
TYPE_NAME   VARCHAR(30) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary" NOT NULL
COLUMN_SIZE 30
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   30
ORDINAL_POSITION2
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  
{code}


was (Author: mprudhom):
I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{{code}}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  

[jira] [Commented] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)


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

Marc Prud'hommeaux commented on CALCITE-2346:
-

I should mention that the two columns in question are a TINYINT NOT NULL (-6) 
and an INTEGER NOT NULL (4), which ought be compatible for the purposes of 
comparison, aggregation, and unioning purposes.

{{code}}
0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "scott"."DEPT"
TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DEPTNO
DATA_TYPE   -6
TYPE_NAME   TINYINT NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME DNAME
DATA_TYPE   12
TYPE_NAME   VARCHAR(14) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 14
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   14
ORDINAL_POSITION2
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM scott
TABLE_NAME  DEPT
COLUMN_NAME LOC
DATA_TYPE   12
TYPE_NAME   VARCHAR(13) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary"
COLUMN_SIZE 13
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE1
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   13
ORDINAL_POSITION3
IS_NULLABLE YES
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

0: jdbc:calcite:model=inline:{"version":1.0,"> !columns "foodmart"."department"
TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_id
DATA_TYPE   4
TYPE_NAME   INTEGER NOT NULL
COLUMN_SIZE -1
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   -1
ORDINAL_POSITION1
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  

TABLE_CAT   
TABLE_SCHEM foodmart
TABLE_NAME  department
COLUMN_NAME department_description
DATA_TYPE   12
TYPE_NAME   VARCHAR(30) CHARACTER SET "ISO-8859-1" COLLATE 
"ISO-8859-1$en_US$primary" NOT NULL
COLUMN_SIZE 30
BUFFER_LENGTH   null
DECIMAL_DIGITS  null
NUM_PREC_RADIX  10
NULLABLE0
REMARKS 
COLUMN_DEF  
SQL_DATA_TYPE   null
SQL_DATETIME_SUBnull
CHAR_OCTET_LENGTH   30
ORDINAL_POSITION2
IS_NULLABLE NO
SCOPE_CATALOG   
SCOPE_SCHEMA
SCOPE_TABLE 
SOURCE_DATA_TYPEnull
IS_AUTOINCREMENT
IS_GENERATEDCOLUMN  
{{code}}

> UNION results with different column types can cause ClassCastException
> --
>
> Key: CALCITE-2346
> URL: https://issues.apache.org/jira/browse/CALCITE-2346
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.16.0
> Environment: macOS 10.13.4 (17E202)
> openjdk version "10" 2018-03-20
> OpenJDK Runtime Environment 18.3 (build 10+46)
> OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)
>Reporter: Marc Prud'hommeaux
>Assignee: Julian Hyde
>Priority: Minor
>
> Trying to union results from two separate data types is throwing:
> {code:java}
> java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
> java.base/java.lang.Integer
>   at 
> org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
>   at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
>   at 
> org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
>   at sqlline.Rows$Row.(Rows.java:157)
>   at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
>   at 

[jira] [Created] (CALCITE-2346) UNION results with different column types can cause ClassCastException

2018-05-31 Thread Marc Prud'hommeaux (JIRA)
Marc Prud'hommeaux created CALCITE-2346:
---

 Summary: UNION results with different column types can cause 
ClassCastException
 Key: CALCITE-2346
 URL: https://issues.apache.org/jira/browse/CALCITE-2346
 Project: Calcite
  Issue Type: Bug
  Components: core
Affects Versions: 1.16.0
 Environment: macOS 10.13.4 (17E202)
openjdk version "10" 2018-03-20
OpenJDK Runtime Environment 18.3 (build 10+46)
OpenJDK 64-Bit Server VM 18.3 (build 10+46, mixed mode)

Reporter: Marc Prud'hommeaux
Assignee: Julian Hyde


Trying to union results from two separate data types is throwing:

{code:java}
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
java.base/java.lang.Integer
at 
org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
at sqlline.SqlLine.print(SqlLine.java:1648)

{code}

It can reproduced with the command:

{code:java}
coursier launch \
  sqlline:sqlline:1.4.0 \
  org.apache.calcite:calcite-core:1.16.0 \
  org.hsqldb:hsqldb:2.4.0 \
  net.hydromatic:scott-data-hsqldb:0.1 \
  net.hydromatic:foodmart-data-hsqldb:0.4 \
  -M sqlline.SqlLine -- \
  -d org.apache.calcite.jdbc.Driver \
  -u 
'jdbc:calcite:model=inline:{"version":1.0,"schemas":[{"name":"scott","type":"jdbc","jdbcUrl":"jdbc:hsqldb:res:scott","jdbcUser":"SCOTT","jdbcPassword":"TIGER"},{"name":"foodmart","type":"jdbc","jdbcSchema":"foodmart","jdbcUrl":"jdbc:hsqldb:res:foodmart"}]}'
 
{code}


The following command works fine:

{code:java}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DNAME" from 
"scott"."DEPT" union all select "department_description" from 
"foodmart"."department";
++
| DNAME  |
++
| ACCOUNTING |
| RESEARCH   |
| SALES  |
| OPERATIONS |
| HQ General Management  |
| HQ Information Systems |
| HQ Marketing   |
| HQ Human Resources |
| HQ Finance and Accounting  |
| Store Management   |
| Store Information Systems  |
| Store Permanent Checkers   |
| Store Temporary Checkers   |
| Store Permanent Stockers   |
| Store Temporary Stockers   |
| Store Permanent Butchers   |
++
16 rows selected (0.069 seconds)
{code}

But when unioning two different column types:

{code:java}
0: jdbc:calcite:model=inline:{"version":1.0,"> select "DEPTNO", "DNAME" from 
"scott"."DEPT" union all select "department_id", "department_description" from 
"foodmart"."department";
+++
|   DEPTNO   | DNAME  |
+++
java.lang.ClassCastException: java.base/java.lang.Byte cannot be cast to 
java.base/java.lang.Integer
at 
org.apache.calcite.avatica.util.AbstractCursor$IntAccessor.getInt(AbstractCursor.java:545)
at org.apache.calcite.avatica.AvaticaSite.get(AvaticaSite.java:339)
at 
org.apache.calcite.avatica.AvaticaResultSet.getObject(AvaticaResultSet.java:377)
at sqlline.Rows$Row.(Rows.java:157)
at sqlline.IncrementalRows.hasNext(IncrementalRows.java:66)
at sqlline.TableOutputFormat.print(TableOutputFormat.java:33)
at sqlline.SqlLine.print(SqlLine.java:1648)
at sqlline.Commands.execute(Commands.java:834)
at sqlline.Commands.sql(Commands.java:733)
at sqlline.SqlLine.dispatch(SqlLine.java:795)
{code}

Possibly related: https://issues.apache.org/jira/browse/CALCITE-580




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Comment Edited] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread yuqi (JIRA)


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

yuqi edited comment on CALCITE-2336 at 5/31/18 1:43 PM:


[~xu fei]
I suggest you check column size in function `validateInsert `, for example, 
should check row column size of insert should not less than size of select. see 
the patch
 [^1.patch] 

and you will get error information as below:


{code:java}
org.apache.calcite.tools.ValidationException: 
java.lang.IllegalArgumentException: Insert column size(1) should not less than 
that of select column(2)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:196)
at com.netease.yuqi.calcatetest.TestTwo.main(TestTwo.java:46)
Caused by: java.lang.IllegalArgumentException: Insert column size(1) should not 
less than that of select column(2)
at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3188)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateInsert(SqlValidatorImpl.java:4175)
at org.apache.calcite.sql.SqlInsert.validate(SqlInsert.java:148)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:915)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:625)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:194)
... 1 more

{code}





was (Author: yuqi):
[~xu fei]
I suggest you check column size in function `validateInsert `, for example, 
should check row column size of insert should not less than size of select. see 
the patch
 [^1.patch] 

and you will get error information as below:
```java
org.apache.calcite.tools.ValidationException: 
java.lang.IllegalArgumentException: Insert column size(1) should not less than 
that of select column(2)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:196)
at com.netease.yuqi.calcatetest.TestTwo.main(TestTwo.java:46)
Caused by: java.lang.IllegalArgumentException: Insert column size(1) should not 
less than that of select column(2)
at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3188)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateInsert(SqlValidatorImpl.java:4175)
at org.apache.calcite.sql.SqlInsert.validate(SqlInsert.java:148)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:915)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:625)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:194)
... 1 more
```



> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
> Attachments: 1.patch
>
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType 

[jira] [Commented] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread yuqi (JIRA)


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

yuqi commented on CALCITE-2336:
---

[~xu fei]
I suggest you check column size in function `validateInsert `, for example, 
should check row column size of insert should not less than size of select. see 
the patch
 [^1.patch] 

and you will get error information as below:
```java
org.apache.calcite.tools.ValidationException: 
java.lang.IllegalArgumentException: Insert column size(1) should not less than 
that of select column(2)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:196)
at com.netease.yuqi.calcatetest.TestTwo.main(TestTwo.java:46)
Caused by: java.lang.IllegalArgumentException: Insert column size(1) should not 
less than that of select column(2)
at 
com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3188)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateInsert(SqlValidatorImpl.java:4175)
at org.apache.calcite.sql.SqlInsert.validate(SqlInsert.java:148)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:915)
at 
org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:625)
at org.apache.calcite.prepare.PlannerImpl.validate(PlannerImpl.java:194)
... 1 more
```



> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
> Attachments: 1.patch
>
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType validateSelectList(
> final SqlNodeList selectItems,
> SqlSelect select,
> RelDataType targetRowType) {
>   // First pass, ensure that aliases are unique. "*" and "TABLE.*" items
>   // are ignored.
>   // Validate SELECT list. Expand terms of the form "*" or "TABLE.*".
>   final SqlValidatorScope selectScope = getSelectScope(select);
>   final List expandedSelectItems = new ArrayList<>();
>   final Set aliases = Sets.newHashSet();
>   final List> fieldList = new ArrayList<>();
>   for (int i = 0; i < selectItems.size(); i++) {
> SqlNode selectItem = selectItems.get(i);
> if (selectItem instanceof SqlSelect) {
>   handleScalarSubQuery(
>   select,
>   (SqlSelect) selectItem,
>   expandedSelectItems,
>   aliases,
>   fieldList);
> } else {
>   expandSelectItem(
>   selectItem,
>   select,
>   targetRowType.isStruct()
>   && targetRowType.getFieldCount() >= i
>   ? targetRowType.getFieldList().get(i).getType()
>   : unknownType,
>   expandedSelectItems,
>   aliases,
>   fieldList,
>   false);
> }
>   }
> {code}
> See the exception is throw from here, if selectItems's size more than 
> targetRowType's field count
> {code:java}
> && targetRowType.getFieldCount() >= i
> ? targetRowType.getFieldList().get(i).getType(){code}
> When I change it to this, I 

[jira] [Updated] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread yuqi (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2336?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

yuqi updated CALCITE-2336:
--
Attachment: 1.patch

> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
> Attachments: 1.patch
>
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType validateSelectList(
> final SqlNodeList selectItems,
> SqlSelect select,
> RelDataType targetRowType) {
>   // First pass, ensure that aliases are unique. "*" and "TABLE.*" items
>   // are ignored.
>   // Validate SELECT list. Expand terms of the form "*" or "TABLE.*".
>   final SqlValidatorScope selectScope = getSelectScope(select);
>   final List expandedSelectItems = new ArrayList<>();
>   final Set aliases = Sets.newHashSet();
>   final List> fieldList = new ArrayList<>();
>   for (int i = 0; i < selectItems.size(); i++) {
> SqlNode selectItem = selectItems.get(i);
> if (selectItem instanceof SqlSelect) {
>   handleScalarSubQuery(
>   select,
>   (SqlSelect) selectItem,
>   expandedSelectItems,
>   aliases,
>   fieldList);
> } else {
>   expandSelectItem(
>   selectItem,
>   select,
>   targetRowType.isStruct()
>   && targetRowType.getFieldCount() >= i
>   ? targetRowType.getFieldList().get(i).getType()
>   : unknownType,
>   expandedSelectItems,
>   aliases,
>   fieldList,
>   false);
> }
>   }
> {code}
> See the exception is throw from here, if selectItems's size more than 
> targetRowType's field count
> {code:java}
> && targetRowType.getFieldCount() >= i
> ? targetRowType.getFieldList().get(i).getType(){code}
> When I change it to this, I get what I need.
> {code:java}
> && targetRowType.getFieldCount() - 1 >= i  
> ? targetRowType.getFieldList().get(i).getType(){code}
> So is this a Bug ? Do we need fix it ? 
>  
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2022) ConnectionConfigImplTest failing on Jenkins

2018-05-31 Thread ASF GitHub Bot (JIRA)


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

ASF GitHub Bot commented on CALCITE-2022:
-

GitHub user snuyanzin opened a pull request:

https://github.com/apache/calcite-avatica/pull/54

CALCITE-2022 add dynamic drive calculation in case of Windows

test fixed in case non "C" drive in Windows

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/snuyanzin/calcite-avatica CALCITE_2022

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/calcite-avatica/pull/54.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 #54


commit 3f4cbc5c9ccaab8c510896c4e15829235331ec63
Author: snuyanzin 
Date:   2018-05-31T11:08:21Z

add dynamic drive calculation in case of Windows




> ConnectionConfigImplTest failing on Jenkins
> ---
>
> Key: CALCITE-2022
> URL: https://issues.apache.org/jira/browse/CALCITE-2022
> Project: Calcite
>  Issue Type: Bug
>  Components: avatica
>Reporter: Josh Elser
>Assignee: Josh Elser
>Priority: Minor
> Fix For: avatica-1.12.0
>
>
> {noformat}
> Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< 
> FAILURE! - in org.apache.calcite.avatica.ConnectionConfigImplTest
> testTrustStore(org.apache.calcite.avatica.ConnectionConfigImplTest)  Time 
> elapsed: 0.015 sec  <<< FAILURE!
> java.lang.AssertionError: 
> Expected: is "C:\my\truststore.jks"
>  but: was "F:\my\truststore.jks"
>   at 
> org.apache.calcite.avatica.ConnectionConfigImplTest.testTrustStore(ConnectionConfigImplTest.java:41)
> {noformat}
> Looks like a pretty simple test failure on Windows that Jenkins caught for us.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Updated] (CALCITE-2302) Implicit type cast support

2018-05-31 Thread Yuzhao Chen (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yuzhao Chen updated CALCITE-2302:
-
Description: 
Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.

Implicit type cast is an useful function for many cases, So we should support 
this.

I checkout Calcite code and found that:
 # Now we use a validator to validate our operands types[ through kinds of 
namespaces and scopes ]
 # Most of the validations will finally goes to
{code:java}
SqlOperator.validateOperands
{code}

 # which will use validation logic defined in corresponding 
SqlOperandTypeChecker

What i'm confused about is where should i put the implicit type cast logic in? 
I figured out 2 ways:
 # Supply a tool class/rules to add casts into a parsed SqlNode tree which will 
then go through the validation logic later on.
 # Unleash the validation logic in kinds of SqlOperandTypeChecker, then modify 
the RelNode/RexNodes tree converted from a validated SqlNode tree to add in 
casts through custom RelOptRules.

So guys, which of the 2 ways should i go, or if there are better way to do this?

I need your help.

 

Updated 18-05-30:

Hi guys, i have made a PR in 
[CALCITE-2302|https://github.com/apache/calcite/pull/706]

This is design doc: [Calcite Implicit Type Cast 
Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].

This is the conversion types mapping: [Conversion Types 
Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].

I really appreciate your suggestions, thx.

  was:
Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.

Implicit type cast is an useful function for many cases, So we should support 
this.

I checkout Calcite code and found that:
 # Now we use a validator to validate our operands types[ through kinds of 
namespaces and scopes ]
 # Most of the validations will finally goes to
{code:java}
SqlOperator.validateOperands
{code}

 # which will use validation logic defined in corresponding 
SqlOperandTypeChecker

What i'm confused about is where should i put the implicit type cast logic in? 
I figured out 2 ways:
 # Supply a tool class/rules to add casts into a parsed SqlNode tree which will 
then go through the validation logic later on.
 # Unleash the validation logic in kinds of SqlOperandTypeChecker, then modify 
the RelNode/RexNodes tree converted from a validated SqlNode tree to add in 
casts through custom RelOptRules.

So guys, which of the 2 ways should i go, or if there are better way to do this?

I need your help.

 

Updated 18-05-30:

Hi guys, i have made a PR in 
[https://github.com/apache/calcite/pull/706|https://github.com/apache/calcite/pull/706,]

This is design doc: [Calcite Implicit Type Cast 
Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].

This is the conversion types mapping: [Conversion Types 
Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].

I really appreciate your suggestions, thx.


> Implicit type cast support
> --
>
> Key: CALCITE-2302
> URL: https://issues.apache.org/jira/browse/CALCITE-2302
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.17.0
>Reporter: Yuzhao Chen
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.
> Implicit type cast is an useful function for many cases, So we should support 
> this.
> I checkout Calcite code and found that:
>  # Now we use a validator to validate our operands types[ through kinds of 
> namespaces and scopes ]
>  # Most of the validations will finally goes to
> {code:java}
> SqlOperator.validateOperands
> {code}
>  # which will use validation logic defined in corresponding 
> SqlOperandTypeChecker
> What i'm confused about is where should i put the implicit type cast logic 
> in? I figured out 2 ways:
>  # Supply a tool class/rules to add casts into a parsed SqlNode tree which 
> will then go through the validation logic later on.
>  # Unleash the validation logic in kinds of SqlOperandTypeChecker, then 
> modify the RelNode/RexNodes tree converted from a validated SqlNode tree to 
> add in casts through custom RelOptRules.
> So guys, which of the 2 ways should i go, or if there are better way to do 
> this?
> I need your help.
>  
> Updated 18-05-30:
> Hi guys, i have made a PR in 
> [CALCITE-2302|https://github.com/apache/calcite/pull/706]
> This is design doc: [Calcite Implicit Type Cast 
> Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].
> This is the conversion 

[jira] [Updated] (CALCITE-2302) Implicit type cast support

2018-05-31 Thread Yuzhao Chen (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yuzhao Chen updated CALCITE-2302:
-
Description: 
Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.

Implicit type cast is an useful function for many cases, So we should support 
this.

I checkout Calcite code and found that:
 # Now we use a validator to validate our operands types[ through kinds of 
namespaces and scopes ]
 # Most of the validations will finally goes to
{code:java}
SqlOperator.validateOperands
{code}

 # which will use validation logic defined in corresponding 
SqlOperandTypeChecker

What i'm confused about is where should i put the implicit type cast logic in? 
I figured out 2 ways:
 # Supply a tool class/rules to add casts into a parsed SqlNode tree which will 
then go through the validation logic later on.
 # Unleash the validation logic in kinds of SqlOperandTypeChecker, then modify 
the RelNode/RexNodes tree converted from a validated SqlNode tree to add in 
casts through custom RelOptRules.

So guys, which of the 2 ways should i go, or if there are better way to do this?

I need your help.

 

Updated 18-05-30:

Hi guys, i have made a PR in 
[https://github.com/apache/calcite/pull/706|https://github.com/apache/calcite/pull/706,]

This is design doc: [Calcite Implicit Type Cast 
Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].

This is the conversion types mapping: [Conversion Types 
Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].

I really appreciate your suggestions, thx.

  was:
Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.

Implicit type cast is an useful function for many cases, So we should support 
this.

I checkout Calcite code and found that:
 # Now we use a validator to validate our operands types[ through kinds of 
namespaces and scopes ]
 # Most of the validations will finally goes to
{code:java}
SqlOperator.validateOperands
{code}

 # which will use validation logic defined in corresponding 
SqlOperandTypeChecker

What i'm confused about is where should i put the implicit type cast logic in? 
I figured out 2 ways:
 # Supply a tool class/rules to add casts into a parsed SqlNode tree which will 
then go through the validation logic later on.
 # Unleash the validation logic in kinds of SqlOperandTypeChecker, then modify 
the RelNode/RexNodes tree converted from a validated SqlNode tree to add in 
casts through custom RelOptRules.

So guys, which of the 2 ways should i go, or if there are better way to do this?

I need your help.

 

Updated 18-05-30:

Hi guys, i have made a PR in [https://github.com/apache/calcite/pull/706,] 

This is design doc: [Calcite Implicit Type Cast 
Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].

This is the conversion types mapping: [Conversion Types 
Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].

I really appreciate your suggestions, thx.


> Implicit type cast support
> --
>
> Key: CALCITE-2302
> URL: https://issues.apache.org/jira/browse/CALCITE-2302
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.17.0
>Reporter: Yuzhao Chen
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.
> Implicit type cast is an useful function for many cases, So we should support 
> this.
> I checkout Calcite code and found that:
>  # Now we use a validator to validate our operands types[ through kinds of 
> namespaces and scopes ]
>  # Most of the validations will finally goes to
> {code:java}
> SqlOperator.validateOperands
> {code}
>  # which will use validation logic defined in corresponding 
> SqlOperandTypeChecker
> What i'm confused about is where should i put the implicit type cast logic 
> in? I figured out 2 ways:
>  # Supply a tool class/rules to add casts into a parsed SqlNode tree which 
> will then go through the validation logic later on.
>  # Unleash the validation logic in kinds of SqlOperandTypeChecker, then 
> modify the RelNode/RexNodes tree converted from a validated SqlNode tree to 
> add in casts through custom RelOptRules.
> So guys, which of the 2 ways should i go, or if there are better way to do 
> this?
> I need your help.
>  
> Updated 18-05-30:
> Hi guys, i have made a PR in 
> [https://github.com/apache/calcite/pull/706|https://github.com/apache/calcite/pull/706,]
> This is design doc: [Calcite Implicit Type Cast 
> Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].
> 

[jira] [Issue Comment Deleted] (CALCITE-2302) Implicit type cast support

2018-05-31 Thread Yuzhao Chen (JIRA)


 [ 
https://issues.apache.org/jira/browse/CALCITE-2302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Yuzhao Chen updated CALCITE-2302:
-
Comment: was deleted

(was: hi, [~julianhyde]

I have made a PR here 
[CALCITE-2302|https://github.com/apache/calcite/pull/706], really appreciate 
that you can give me some suggestions.)

> Implicit type cast support
> --
>
> Key: CALCITE-2302
> URL: https://issues.apache.org/jira/browse/CALCITE-2302
> Project: Calcite
>  Issue Type: Improvement
>  Components: core
>Affects Versions: 1.17.0
>Reporter: Yuzhao Chen
>Assignee: Julian Hyde
>Priority: Major
> Fix For: 1.17.0
>
>
> Now many DBs have support implicit type cast, eg: SqlServer, Oracle, Hive.
> Implicit type cast is an useful function for many cases, So we should support 
> this.
> I checkout Calcite code and found that:
>  # Now we use a validator to validate our operands types[ through kinds of 
> namespaces and scopes ]
>  # Most of the validations will finally goes to
> {code:java}
> SqlOperator.validateOperands
> {code}
>  # which will use validation logic defined in corresponding 
> SqlOperandTypeChecker
> What i'm confused about is where should i put the implicit type cast logic 
> in? I figured out 2 ways:
>  # Supply a tool class/rules to add casts into a parsed SqlNode tree which 
> will then go through the validation logic later on.
>  # Unleash the validation logic in kinds of SqlOperandTypeChecker, then 
> modify the RelNode/RexNodes tree converted from a validated SqlNode tree to 
> add in casts through custom RelOptRules.
> So guys, which of the 2 ways should i go, or if there are better way to do 
> this?
> I need your help.
>  
> Updated 18-05-30:
> Hi guys, i have made a PR in [https://github.com/apache/calcite/pull/706,] 
> This is design doc: [Calcite Implicit Type Cast 
> Design|https://docs.google.com/document/d/1g2RUnLXyp_LjUlO-wbblKuP5hqEu3a_2Mt2k4dh6RwU/edit?usp=sharing].
> This is the conversion types mapping: [Conversion Types 
> Mapping|https://docs.google.com/spreadsheets/d/1GhleX5h5W8-kJKh7NMJ4vtoE78pwfaZRJl88ULX_MgU/edit?usp=sharing].
> I really appreciate your suggestions, thx.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)


[jira] [Commented] (CALCITE-2336) SqlValidatorImpl throws java.lang.IndexOutOfBoundsException

2018-05-31 Thread Fei Xu (JIRA)


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

Fei Xu commented on CALCITE-2336:
-

Well, would you please execute the following unit test in 
org.apache.calcite.test.InterpreterTest to verify ?, I found the problem when I 
use calcite in my own application. So I write a temporary test case.
{code:java}
  @Test public void testIndexOutOfBoundsException() throws Exception {
rootSchema = Frameworks.createRootSchema(true);

rootSchema.add("USERS", new AbstractTable() {
  @Override public RelDataType getRowType(final RelDataTypeFactory 
typeFactory) {
RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
//builder.add("name", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
SqlTypeName.BIGINT));
builder.add("name", typeFactory.createSqlType(SqlTypeName.INTEGER));
return builder.build();
  }
});

final FrameworkConfig config = Frameworks.newConfigBuilder()
.parserConfig(SqlParser.Config.DEFAULT)
.defaultSchema(rootSchema)
.build();
planner = Frameworks.getPlanner(config);
dataContext = new MyDataContext(planner);

SqlNode parse =
planner.parse("insert into users select y, x\n"
+ "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
+ "where x > 1");

SqlNode validate = planner.validate(parse);
//RelNode convert = planner.rel(validate).rel;

//final Interpreter interpreter = new Interpreter(dataContext, convert);
//assertRows(interpreter, "[0]", "[10]", "[20]", "[30]");
  }
{code}
 

> SqlValidatorImpl throws java.lang.IndexOutOfBoundsException
> ---
>
> Key: CALCITE-2336
> URL: https://issues.apache.org/jira/browse/CALCITE-2336
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Reporter: Fei Xu
>Assignee: Julian Hyde
>Priority: Major
>
> I register a table "users" with a single column, age. And try to insert two 
> columns into the "users".
> {code:java}
> rootSchema = Frameworks.createRootSchema(true);
> rootSchema.add("USERS", new AbstractTable() {
>   @Override public RelDataType getRowType(final RelDataTypeFactory 
> typeFactory) {
> RelDataTypeFactory.FieldInfoBuilder builder = typeFactory.builder();
> builder.add("age", new BasicSqlType(new RelDataTypeSystemImpl() {}, 
> SqlTypeName.CHAR));
> return builder.build();
>   }
> });
> final FrameworkConfig config = Frameworks.newConfigBuilder()
> .parserConfig(SqlParser.Config.DEFAULT)
> .defaultSchema(rootSchema)
> .build();
> planner = Frameworks.getPlanner(config);
> dataContext = new MyDataContext(planner);
> SqlNode parse =
> planner.parse("insert into users select y, x\n"
> + "from (values (1, 'a'), (2, 'b'), (3, 'c')) as t(x, y)\n"
> + "where x > 1");
> SqlNode validate = planner.validate(parse);
> {code}
> Apparently, I want to see some error message like:
> {code:java}
> Number of INSERT target columns (1) does not equal number of source items (2)
> {code}
> But actually, I got message:
> {code:java}
> org.apache.calcite.tools.ValidationException: 
> java.lang.IndexOutOfBoundsException: index (1) must be less than size (1)
> {code}
> which was confused.
> Then I debug the code in SqlValidatorImpl#validateSelectList method.
>  
> {code:java}
> protected RelDataType validateSelectList(
> final SqlNodeList selectItems,
> SqlSelect select,
> RelDataType targetRowType) {
>   // First pass, ensure that aliases are unique. "*" and "TABLE.*" items
>   // are ignored.
>   // Validate SELECT list. Expand terms of the form "*" or "TABLE.*".
>   final SqlValidatorScope selectScope = getSelectScope(select);
>   final List expandedSelectItems = new ArrayList<>();
>   final Set aliases = Sets.newHashSet();
>   final List> fieldList = new ArrayList<>();
>   for (int i = 0; i < selectItems.size(); i++) {
> SqlNode selectItem = selectItems.get(i);
> if (selectItem instanceof SqlSelect) {
>   handleScalarSubQuery(
>   select,
>   (SqlSelect) selectItem,
>   expandedSelectItems,
>   aliases,
>   fieldList);
> } else {
>   expandSelectItem(
>   selectItem,
>   select,
>   targetRowType.isStruct()
>   && targetRowType.getFieldCount() >= i
>   ? targetRowType.getFieldList().get(i).getType()
>   : unknownType,
>   expandedSelectItems,
>   aliases,
>   fieldList,
>   false);
> }
>   }
> {code}
> See the exception is throw from here, if selectItems's size more than 
> targetRowType's field count
> {code:java}
> &&