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

Thanks,
Gelbana


On Thu, Mar 7, 2019 at 11:33 AM Stamatis Zampetakis <zabe...@gmail.com>
wrote:

> Sorry, I meant to write instead of
>
> final RelDataType type =
> typeFactory.createTypeWithNullability(fieldList.get(0).getType(), true);
>
> in my previous email.
>
> I think it would make sense to change the hardcoded value but I didn't try
> to see if there are test failures after the change neither I know the
> original motive of setting the value to true.
>
> Try it on and log a JIRA case to continue the discussion there.
>
> Best,
> Stamatis
>
>
>
> Στις Πέμ, 7 Μαρ 2019 στις 10:16 π.μ., ο/η Muhammad Gelbana <
> m.gelb...@gmail.com> έγραψε:
>
> > Actually the types is derived this way
> >
> > final RelDataType type =
> > typeFactory.createTypeWithNullability(fieldList.get(0).getType(),
> *true*);
> >
> > Reference:
> >
> >
> https://github.com/apache/calcite/blob/d10aeb7f7e50dc7028ce102a5f590d0c50c49fa8/core/src/main/java/org/apache/calcite/rex/RexSubQuery.java#L99
> >
> > If you beleive it's valid to provide a way to override this hard coded
> > nallability flag, I would love to do it.
> >
> > Thanks,
> > Gelbana
> >
> > On Thu, Mar 7, 2019 at 9:52 AM Stamatis Zampetakis <zabe...@gmail.com>
> > wrote:
> >
> > > Hi Gelbana,
> > >
> > > I am not sure why the scalar type is always nullable at this part of
> the
> > > code but I would expect that the type is obtained as follows:
> > >
> > > final RelDataType type =
> > typeFactory.copyType(fieldList.get(0).getType());
> > > // which copies also the nullability of the type
> > >
> > > instead of
> > >
> > > final RelDataType type =
> > > typeFactory.createTypeWithNullability(fieldList.get(0).getType(),
> > > fieldList.get(0).getType().isNullable());
> > >
> > > Best,
> > > Stamatis
> > >
> > > Στις Τρί, 5 Μαρ 2019 στις 2:01 μ.μ., ο/η Muhammad Gelbana <
> > > m.gelb...@gmail.com> έγραψε:
> > >
> > > > 'm trying to rewrite the below query to be
> > > > SELECT (SELECT PRONAME FROM PG_PROC WHERE OID = col1) FROM (VALUES
> > > > ('array_in', 'array_out')) as tbl(col1, col2)
> > > >
> > > > When I try to test my code using this query
> > > > SELECT col1::regproc FROM (VALUES ('array_in', 'array_out')) as
> > tbl(col1,
> > > > col2)
> > > >
> > > > The casting expression (col1::regproc) type is derived as *not*
> > nullable
> > > > because the casting is applied on a column selected from VALUES.
> > > >
> > > > But RexSubQuery.scalar[1] always returns a RelNode with a nullable
> > type.
> > > >
> > > > The exception I get when I try to run the query after rewriting is:
> > > >
> > > > set type is RecordType(REGPROC *NOT NULL* EXPR$0) NOT NULL
> > > > expression type is RecordType(REGPROC EXPR$0) NOT NULL
> > > > set is
> > > >
> > >
> >
> rel#11:LogicalProject.NONE.[0](input=HepRelVertex#10,EXPR$0=$SCALAR_QUERY({
> > > > LogicalFilter(condition=[=($1, $0)])
> > > >   LogicalProject(PRONAME=[$0])
> > > >     LogicalTableScan(table=[[PG_CATALOG, PG_PROC]])
> > > > }))
> > > > expression is LogicalProject(EXPR$0=[$2])
> > > >   LogicalJoin(condition=[true], joinType=[left])
> > > >     LogicalValues(tuples=[[{ 'array_in', 'array_out' }]])
> > > >     LogicalAggregate(group=[{}], agg#0=[SINGLE_VALUE($0)])
> > > >       LogicalFilter(condition=[=($1, $0)])
> > > >         LogicalProject(PRONAME=[$0])
> > > >           LogicalTableScan(table=[[PG_CATALOG, PG_PROC]])
> > > >
> > > >     at
> > > >
> > > >
> > >
> >
> org.apache.calcite.plan.RelOptUtil.verifyTypeEquivalence(RelOptUtil.java:381)
> > > >     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.SubQueryRemoveRule$SubQueryProjectRemoveRule.onMatch(SubQueryRemoveRule.java:518)
> > > >
> > > > Shouldn't we be able to specify if the scalar query type created by
> > > > RexSubQuery.scalar is nullable or not ?
> > > >
> > > > [1]
> > > >
> > > >
> > >
> >
> https://github.com/apache/calcite/blob/d10aeb7f7e50dc7028ce102a5f590d0c50c49fa8/core/src/main/java/org/apache/calcite/rex/RexSubQuery.java#L94
> > > >
> > > > Thanks,
> > > > Gelbana
> > > >
> > >
> >
>

Reply via email to