You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Marc Prud'hommeaux <ma...@glimpse.io> on 2017/10/01 21:32:08 UTC

Losing column names when using RelBuilder.values


I notice that if I create inline values using: 

RelBuilder.values(Iterable<? extends List<RexLiteral>> tupleList, RelDataType rowType)

I lose the field names that I put in the RelDataType, and the fields are named "EXPR$0”, “EXPR$1”, ...

This is also seen if I create a Rel from the SQL string "SELECT X.A FROM (VALUES 1) AS X(A)” via Planner.parse, Planner.validate, then Planner.rel, whose JSON representation winds up looking like:

{
  "rels": [
    {
      "id": "0",
      "relOp": "LogicalValues",
      "type": [
        {
          "type": "INTEGER",
          "nullable": false,
          "name": "EXPR$0"
        }
      ],
      "tuples": [
        [
          1
        ]
      ],
      "inputs": []
    },
    {
      "id": "1",
      "relOp": "LogicalProject"
    }
  ]
}

However, in sqlline, I can perform the same query:

0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT X.A FROM (VALUES 1) AS X(A);
+------------+
|     A      |
+------------+
| 1          |
+------------+
1 row selected (0.02 seconds)

and the column name “A” is preserved. 

Is there some mechanism for retaining the column name when using RelBuilder.values() other than putting the column name in the RelDataType?






Re: Losing column names when using RelBuilder.values

Posted by Marc Prud'hommeaux <ma...@glimpse.io>.
Julian-

I managed to reproduce it in isolation. It’s pretty weird.

  https://issues.apache.org/jira/browse/CALCITE-1996

	-Marc

> On Oct 2, 2017, at 1:32 PM, Julian Hyde <jh...@apache.org> wrote:
> 
> Thanks for investigating. I think you should file a bug report with everything you know about this issue. It passes my threshold of “undesirable behavior”. If we later get a reproducible test case and a fix that’s a bonus.
> 
>> On Oct 2, 2017, at 7:58 AM, Marc Prud'hommeaux <ma...@glimpse.io> wrote:
>> 
>> 
>> Interestingly, it turns out this only happens when I re-use a RelBuilder than I’ve used for a bunch of other operations, even though I call clear() on it. When I use a fresh new RelBuilder, I’m able to select from a multi-values values call.
>> 
>> I’ll look into it some more and file a bug report if it turns out to be easily reproducible.
>> 
>> 
>>> On Oct 1, 2017, at 5:32 PM, Marc Prud'hommeaux <ma...@glimpse.io> wrote:
>>> 
>>> 
>>> 
>>> I notice that if I create inline values using: 
>>> 
>>> RelBuilder.values(Iterable<? extends List<RexLiteral>> tupleList, RelDataType rowType)
>>> 
>>> I lose the field names that I put in the RelDataType, and the fields are named "EXPR$0”, “EXPR$1”, ...
>>> 
>>> This is also seen if I create a Rel from the SQL string "SELECT X.A FROM (VALUES 1) AS X(A)” via Planner.parse, Planner.validate, then Planner.rel, whose JSON representation winds up looking like:
>>> 
>>> {
>>> "rels": [
>>>  {
>>>    "id": "0",
>>>    "relOp": "LogicalValues",
>>>    "type": [
>>>      {
>>>        "type": "INTEGER",
>>>        "nullable": false,
>>>        "name": "EXPR$0"
>>>      }
>>>    ],
>>>    "tuples": [
>>>      [
>>>        1
>>>      ]
>>>    ],
>>>    "inputs": []
>>>  },
>>>  {
>>>    "id": "1",
>>>    "relOp": "LogicalProject"
>>>  }
>>> ]
>>> }
>>> 
>>> However, in sqlline, I can perform the same query:
>>> 
>>> 0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT X.A FROM (VALUES 1) AS X(A);
>>> +------------+
>>> |     A      |
>>> +------------+
>>> | 1          |
>>> +------------+
>>> 1 row selected (0.02 seconds)
>>> 
>>> and the column name “A” is preserved. 
>>> 
>>> Is there some mechanism for retaining the column name when using RelBuilder.values() other than putting the column name in the RelDataType?
>>> 
>>> 
>>> 
>>> 
>>> 
>> 
> 


Re: Losing column names when using RelBuilder.values

Posted by Julian Hyde <jh...@apache.org>.
Thanks for investigating. I think you should file a bug report with everything you know about this issue. It passes my threshold of “undesirable behavior”. If we later get a reproducible test case and a fix that’s a bonus.

> On Oct 2, 2017, at 7:58 AM, Marc Prud'hommeaux <ma...@glimpse.io> wrote:
> 
> 
> Interestingly, it turns out this only happens when I re-use a RelBuilder than I’ve used for a bunch of other operations, even though I call clear() on it. When I use a fresh new RelBuilder, I’m able to select from a multi-values values call.
> 
> I’ll look into it some more and file a bug report if it turns out to be easily reproducible.
> 
> 
>> On Oct 1, 2017, at 5:32 PM, Marc Prud'hommeaux <ma...@glimpse.io> wrote:
>> 
>> 
>> 
>> I notice that if I create inline values using: 
>> 
>> RelBuilder.values(Iterable<? extends List<RexLiteral>> tupleList, RelDataType rowType)
>> 
>> I lose the field names that I put in the RelDataType, and the fields are named "EXPR$0”, “EXPR$1”, ...
>> 
>> This is also seen if I create a Rel from the SQL string "SELECT X.A FROM (VALUES 1) AS X(A)” via Planner.parse, Planner.validate, then Planner.rel, whose JSON representation winds up looking like:
>> 
>> {
>> "rels": [
>>   {
>>     "id": "0",
>>     "relOp": "LogicalValues",
>>     "type": [
>>       {
>>         "type": "INTEGER",
>>         "nullable": false,
>>         "name": "EXPR$0"
>>       }
>>     ],
>>     "tuples": [
>>       [
>>         1
>>       ]
>>     ],
>>     "inputs": []
>>   },
>>   {
>>     "id": "1",
>>     "relOp": "LogicalProject"
>>   }
>> ]
>> }
>> 
>> However, in sqlline, I can perform the same query:
>> 
>> 0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT X.A FROM (VALUES 1) AS X(A);
>> +------------+
>> |     A      |
>> +------------+
>> | 1          |
>> +------------+
>> 1 row selected (0.02 seconds)
>> 
>> and the column name “A” is preserved. 
>> 
>> Is there some mechanism for retaining the column name when using RelBuilder.values() other than putting the column name in the RelDataType?
>> 
>> 
>> 
>> 
>> 
> 


Re: Losing column names when using RelBuilder.values

Posted by Marc Prud'hommeaux <ma...@glimpse.io>.
Interestingly, it turns out this only happens when I re-use a RelBuilder than I’ve used for a bunch of other operations, even though I call clear() on it. When I use a fresh new RelBuilder, I’m able to select from a multi-values values call.

I’ll look into it some more and file a bug report if it turns out to be easily reproducible.


> On Oct 1, 2017, at 5:32 PM, Marc Prud'hommeaux <ma...@glimpse.io> wrote:
> 
> 
> 
> I notice that if I create inline values using: 
> 
> RelBuilder.values(Iterable<? extends List<RexLiteral>> tupleList, RelDataType rowType)
> 
> I lose the field names that I put in the RelDataType, and the fields are named "EXPR$0”, “EXPR$1”, ...
> 
> This is also seen if I create a Rel from the SQL string "SELECT X.A FROM (VALUES 1) AS X(A)” via Planner.parse, Planner.validate, then Planner.rel, whose JSON representation winds up looking like:
> 
> {
>  "rels": [
>    {
>      "id": "0",
>      "relOp": "LogicalValues",
>      "type": [
>        {
>          "type": "INTEGER",
>          "nullable": false,
>          "name": "EXPR$0"
>        }
>      ],
>      "tuples": [
>        [
>          1
>        ]
>      ],
>      "inputs": []
>    },
>    {
>      "id": "1",
>      "relOp": "LogicalProject"
>    }
>  ]
> }
> 
> However, in sqlline, I can perform the same query:
> 
> 0: jdbc:calcite:model=inline:{"version":1.0,"> SELECT X.A FROM (VALUES 1) AS X(A);
> +------------+
> |     A      |
> +------------+
> | 1          |
> +------------+
> 1 row selected (0.02 seconds)
> 
> and the column name “A” is preserved. 
> 
> Is there some mechanism for retaining the column name when using RelBuilder.values() other than putting the column name in the RelDataType?
> 
> 
> 
> 
>