OSDir


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Generic Map type (_MAP) and select star (*)


Unfortunately I don't have an answer, but just a minor point that when you
post links to specific lines of code, it's helpful if that link is to a
specific revision. You can press the "y" shortcut to get this link (pasted
below).

https://github.com/apache/calcite/blob/c39bfaa02a06ac91575076a6e74f29863923f5eb/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchProject.java#L67

--
Michael Mior
mmior@xxxxxxxxxx


Le jeu. 4 oct. 2018 à 14:47, Andrei Sereda <andrei@xxxxxxxxx> a écrit :

> Hello,
>
> I would like to understand how exactly generic map type (_MAP) works
> with select
> * expression. Say I have the following query (on document database) :
>
> -- first query:  2 projectionsselect * from elastic.zips order by
> _MAP['state'] -- second query: single projectionselect _MAP['state']
> from elastic.zips order by _MAP['state']
>
> For first query (select *) I’m getting 2 projections (inside
> ElasticsearchProject
> <
> https://github.com/apache/calcite/blob/master/elasticsearch/src/main/java/org/apache/calcite/adapter/elasticsearch/ElasticsearchProject.java#L67
> >)
> for some reason
>
> 0 = {RexInputRef@12207} "$0"
>    index = 0
>    name = "$0"
>    type = {MapSqlType@12211} "(VARCHAR, ANY) MAP"
>    digest = "$0"
> 1 = {RexCall@12208} "ITEM($0, 'state')"
>    op = {SqlItemOperator@12213} "ITEM"
>    operands = {RegularImmutableList@12214}  size = 2
>    type = {BasicSqlType@12215} "ANY"
>    digest = "ITEM($0, 'state')"
>
> For second query and when using views there is no such issue.
>
> My question is how to correctly identify select * when rowType is map (
> MapSqlType
> <
> https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/sql/type/MapSqlType.java
> >)?
>
>
> Thank you,
> Andrei.
>