[jira] [Commented] (CALCITE-6361) Uncollect.deriveUncollectRowType crashes if the input data is not a collection

2024-04-19 Thread Mihai Budiu (Jira)


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

Mihai Budiu commented on CALCITE-6361:
--

What I find strange here is that the row type is derived very early, apparently 
before validation.
This happens in the constructor of the Unnest.
Validation would probably reject this query.
Right now deriveRowType never seems to throw, but I don't see what else could 
be done here. I will try a fix using such an approach.

> Uncollect.deriveUncollectRowType crashes if the input data is not a collection
> --
>
> Key: CALCITE-6361
> URL: https://issues.apache.org/jira/browse/CALCITE-6361
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.37.0
>Reporter: Mihai Budiu
>Priority: Minor
>
> This happens because the type checker calls getComponentType() without 
> checking first that the field type has components. It should report an error 
> in such a case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6361) Uncollect.deriveUncollectRowType crashes if the input data is not a collection

2024-04-19 Thread Mihai Budiu (Jira)


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

Mihai Budiu commented on CALCITE-6361:
--

I have managed to create a small reproduction for this. One has to use 
ServerTest:

{code:java}
  /** Test case for
   * https://issues.apache.org/jira/browse/CALCITE-6361;>[CALCITE-6361]
   * Uncollect.deriveUncollectRowType crashes if the input data is not a 
collection. */
  @Test void testUnnest() throws SQLException {
try (Connection c = connect();
 Statement s = c.createStatement()) {
  boolean b = s.execute("CREATE TYPE simple AS (s INT, t BOOLEAN)");
  assertThat(b, is(false));
  b = s.execute("CREATE TYPE vec AS (fields SIMPLE ARRAY)");
  assertThat(b, is(false));
  b = s.execute(" CREATE TABLE T(col vec)");
  assertThat(b, is(false));
  s.executeQuery("SELECT A.* FROM (T CROSS JOIN UNNEST(T.col) A)");
}
  }
{code}

> Uncollect.deriveUncollectRowType crashes if the input data is not a collection
> --
>
> Key: CALCITE-6361
> URL: https://issues.apache.org/jira/browse/CALCITE-6361
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.37.0
>Reporter: Mihai Budiu
>Priority: Minor
>
> This happens because the type checker calls getComponentType() without 
> checking first that the field type has components. It should report an error 
> in such a case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6361) Uncollect.deriveUncollectRowType crashes if the input data is not a collection

2024-04-11 Thread Mihai Budiu (Jira)


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

Mihai Budiu commented on CALCITE-6361:
--

This is an assertion failure:

{code:java}
RelDataType ret = field.getType().getComponentType();
assert null != ret;
{code}

The top of the stack trace is:
{code:java}
at 
org.apache.calcite.rel.core.Uncollect.deriveUncollectRowType(Uncollect.java:171)
at 
org.apache.calcite.rel.core.Uncollect.deriveRowType(Uncollect.java:127)
at org.apache.calcite.rel.core.Uncollect.(Uncollect.java:78)
at org.apache.calcite.tools.RelBuilder.uncollect(RelBuilder.java:2254)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertUnnest(SqlToRelConverter.java:2480)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2436)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2334)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2296)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertJoin(SqlToRelConverter.java:3182)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2417)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertFrom(SqlToRelConverter.java:2296)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:709)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:690)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3769)
at 
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:610)
{code}

I will try to post here a test to reproduce. Mine is currently a bit involved 
using several "CREATE TYPE statements"

> Uncollect.deriveUncollectRowType crashes if the input data is not a collection
> --
>
> Key: CALCITE-6361
> URL: https://issues.apache.org/jira/browse/CALCITE-6361
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.37.0
>Reporter: Mihai Budiu
>Priority: Minor
>
> This happens because the type checker calls getComponentType() without 
> checking first that the field type has components. It should report an error 
> in such a case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6361) Uncollect.deriveUncollectRowType crashes if the input data is not a collection

2024-04-10 Thread Julian Hyde (Jira)


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

Julian Hyde commented on CALCITE-6361:
--

By the way, please don't say 'crashes'. Say what error is thrown.

> Uncollect.deriveUncollectRowType crashes if the input data is not a collection
> --
>
> Key: CALCITE-6361
> URL: https://issues.apache.org/jira/browse/CALCITE-6361
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.37.0
>Reporter: Mihai Budiu
>Priority: Minor
>
> This happens because the type checker calls getComponentType() without 
> checking first that the field type has components. It should report an error 
> in such a case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)


[jira] [Commented] (CALCITE-6361) Uncollect.deriveUncollectRowType crashes if the input data is not a collection

2024-04-10 Thread Julian Hyde (Jira)


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

Julian Hyde commented on CALCITE-6361:
--

Is there a SQL query that reproduces this problem? It's sometimes reasonable 
that methods such as deriveUncollectRowType() make certain assumptions -- the 
alternative is an overly defensive programming style.

An alternative formulation of the same question: Do you consider this to be a 
user error or an internal error?

> Uncollect.deriveUncollectRowType crashes if the input data is not a collection
> --
>
> Key: CALCITE-6361
> URL: https://issues.apache.org/jira/browse/CALCITE-6361
> Project: Calcite
>  Issue Type: Bug
>  Components: core
>Affects Versions: 1.37.0
>Reporter: Mihai Budiu
>Priority: Minor
>
> This happens because the type checker calls getComponentType() without 
> checking first that the field type has components. It should report an error 
> in such a case.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)