Re: RelRunners weird behavior

2017-05-22 Thread Julian Hyde
Thanks! Now, if someone on the list has time to look into it, it would be 
appreciated…


> On May 22, 2017, at 12:03 PM, Laptop huawei  wrote:
> 
> I’ve created the jira: https://issues.apache.org/jira/browse/CALCITE-1801
> and attached the test case in RelBuilderTest as suggested.  
> 
> Thanks,
> 
> -JD
> 
>> On May 19, 2017, at 8:12 PM, Julian Hyde  wrote:
>> 
>> You can create a bug by clicking the “create” button on Apache JIRA: 
>> https://issues.apache.org/jira/browse/CALCITE.
>> 
>> A test case would be a piece of code that anyone could run to reproduce the 
>> problem. Maybe you could add a method to RelBuilderTest similar to testRun().
>> 
>> Julian
>> 
>>> On May 19, 2017, at 2:40 PM, JD Zheng  wrote:
>>> 
>>> Hi, Julian,
>>> 
>>> Thank you for reply. I am new to the open source community. What do you
>>> mean by "log a bug, with a test case"?
>>> 
>>> -JD
>>> 
>>> On May 19, 2017, at 11:52 AM, Julian Hyde  wrote:
>>> 
>>> Please log a bug, with a test case.
>>> 
>>> Maybe we use some callback to create a connection. And maybe if you are
>>> using an anonymous class it causes the connection to be garbage-collected
>>> sooner.
>>> 
>>> Julian
>>> 
>>> 
>>> On May 19, 2017, at 1:24 PM, Laptop huawei  wrote:
>>> 
>>> Hi,
>>> 
>>> I am using RelRunners to execute pre-built relnode tree. It works perfectly
>>> when I put the following code in the junit class:
>>> 
>>> protected String execute(RelNode rel) {
>>>try (final PreparedStatement preparedStatement = RelRunners.run(rel))
>>> {
>>>  final ResultSet resultSet = preparedStatement.executeQuery();
>>>  return printResult(resultSet, true);
>>>} catch (SQLException e) {
>>>  throw new RuntimeException(e);
>>>}
>>> }
>>> 
>>> However,if I put these code inside a src class, the returned resultSet is
>>> closed.
>>> 
>>> More interestingly, if I expand the RelRunners.run() in the method like
>>> this:
>>> 
>>> public static ResultSet execute(RelNode rel) {
>>> /*
>>>try (final PreparedStatement preparedStatement = RelRunners.run(rel))
>>> {
>>>  return preparedStatement.executeQuery();
>>>} catch (SQLException e) {
>>>  throw new AQLExecuteErrorException(e);
>>>}
>>>*/
>>>try (Connection connection =
>>> DriverManager.getConnection("jdbc:calcite:"))
>>> {
>>>final RelRunner runner = connection.unwrap(RelRunner.class);
>>>PreparedStatement preparedStatement = runner.prepare(rel);
>>>return preparedStatement.executeQuery();
>>>  } catch (SQLException e) {
>>>throw new AQLExecuteErrorException(e);
>>>  }
>>> }
>>> 
>>> It works again.
>>> 
>>> Has anyone seen this behavior before or has any insights? Thanks,
>>> 
>>> -JD
>> 
> 



Re: RelRunners weird behavior

2017-05-22 Thread Laptop huawei
I’ve created the jira: https://issues.apache.org/jira/browse/CALCITE-1801
and attached the test case in RelBuilderTest as suggested.  

Thanks,

-JD

> On May 19, 2017, at 8:12 PM, Julian Hyde  wrote:
> 
> You can create a bug by clicking the “create” button on Apache JIRA: 
> https://issues.apache.org/jira/browse/CALCITE.
> 
> A test case would be a piece of code that anyone could run to reproduce the 
> problem. Maybe you could add a method to RelBuilderTest similar to testRun().
> 
> Julian
> 
>> On May 19, 2017, at 2:40 PM, JD Zheng  wrote:
>> 
>> Hi, Julian,
>> 
>> Thank you for reply. I am new to the open source community. What do you
>> mean by "log a bug, with a test case"?
>> 
>> -JD
>> 
>> On May 19, 2017, at 11:52 AM, Julian Hyde  wrote:
>> 
>> Please log a bug, with a test case.
>> 
>> Maybe we use some callback to create a connection. And maybe if you are
>> using an anonymous class it causes the connection to be garbage-collected
>> sooner.
>> 
>> Julian
>> 
>> 
>> On May 19, 2017, at 1:24 PM, Laptop huawei  wrote:
>> 
>> Hi,
>> 
>> I am using RelRunners to execute pre-built relnode tree. It works perfectly
>> when I put the following code in the junit class:
>> 
>> protected String execute(RelNode rel) {
>> try (final PreparedStatement preparedStatement = RelRunners.run(rel))
>> {
>>   final ResultSet resultSet = preparedStatement.executeQuery();
>>   return printResult(resultSet, true);
>> } catch (SQLException e) {
>>   throw new RuntimeException(e);
>> }
>> }
>> 
>> However,if I put these code inside a src class, the returned resultSet is
>> closed.
>> 
>> More interestingly, if I expand the RelRunners.run() in the method like
>> this:
>> 
>> public static ResultSet execute(RelNode rel) {
>> /*
>> try (final PreparedStatement preparedStatement = RelRunners.run(rel))
>> {
>>   return preparedStatement.executeQuery();
>> } catch (SQLException e) {
>>   throw new AQLExecuteErrorException(e);
>> }
>> */
>> try (Connection connection =
>> DriverManager.getConnection("jdbc:calcite:"))
>> {
>> final RelRunner runner = connection.unwrap(RelRunner.class);
>> PreparedStatement preparedStatement = runner.prepare(rel);
>> return preparedStatement.executeQuery();
>>   } catch (SQLException e) {
>> throw new AQLExecuteErrorException(e);
>>   }
>> }
>> 
>> It works again.
>> 
>> Has anyone seen this behavior before or has any insights? Thanks,
>> 
>> -JD
>