[
https://issues.apache.org/jira/browse/CALCITE-6023?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17768690#comment-17768690
]
Jordan Hannel edited comment on CALCITE-6023 at 9/25/23 1:22 PM:
-----------------------------------------------------------------
Thanks both for the quick responses! I have updated the issue subject and body
as requested.
Re. "calling the parser and sql-to-rel-converter by hand", could you elaborate
on this? I've updated the issue description above to include the code I'm using
to call the parser and converter, is there a different recommended way?
Thanks for the attempted repro, I wonder if the issue has something to do with
a subquery in the from clause - maybe the below query might repro the
issue?{{{{}}{}}}
{{SELECT "dim4" AS "dim7", LEAD(COUNT( * ), -1) OVER (ORDER BY "dim4") AS
"measure10"}}
{{FROM (}}
{{ SELECT "deptno" AS "dim4" FROM emp) AS "t0"}}
{{GROUP BY "dim4"}}
was (Author: JIRAUSER302326):
Thanks both for the quick responses! I have updated the issue subject and body
as requested.
Re. "calling the parser and sql-to-rel-converter by hand", could you elaborate
on this? I've updated the issue description above to include the code I'm using
to call the parser and converter, is there a different recommended way?
Thanks for the attempted repro, I wonder if the issue has something to do with
a subquery in the from clause - maybe the below query might repro the
issue?{{{}{}}}
{{{{SELECT "dim4" AS "dim7", LEAD(COUNT( * ), -1) OVER (ORDER BY "dim4") AS
"measure10"}}
{{FROM (}}
{{ SELECT "deptno" AS "dim4" FROM emp) AS "t0"}}
{{GROUP BY "dim4"}}}}
> Error in SqlToRelConverter.convertQuery, possibly due to unqualified column
> reference
> -------------------------------------------------------------------------------------
>
> Key: CALCITE-6023
> URL: https://issues.apache.org/jira/browse/CALCITE-6023
> Project: Calcite
> Issue Type: Bug
> Affects Versions: 1.35.0
> Reporter: Jordan Hannel
> Priority: Major
> Attachments: stacktrace.txt
>
>
> Hello all, I believe I have found a bug in SqlToRelConverter. The symptom and
> repro are outlined below, and the full stacktrace is attached. This is on
> calcite version 1.35.0. Any insight would be much appreciated, thanks!
> When I parse the below SQL string to get a SqlNode, and call
> SqlToRelConverter.convertQuery on this SqlNode, I get error:
> {quote}UnsupportedOperationException: class
> org.apache.calcite.sql.SqlBasicCall: LEAD(COUNT( * )) OVER (ORDER BY `dim4`)
> {quote}
> SQL:
> {{SELECT "dim4" AS "dim7", LEAD(COUNT( * ), -1) OVER (ORDER BY "dim4") AS
> "measure10"}}
> {{FROM (}}
> {{ SELECT "timestamp" AS "dim4" FROM "Shared.factDataset") AS "t0"}}
> {{GROUP BY "dim4"}}
> I have confirmed that my SqlToRelConverter instance seems generally ok,
> because it is able to convert many other SqlNodes to RelNodes. After some
> experimentation, I noticed that just changing `ORDER BY "dim4"` to `ORDER BY
> "t0"."dim4"` fixes the issue - after that, the SqlNode successfully is
> translated to a RelNode.
>
> Below is the way I am invoking convertQuery. The error comes in the last
> line, on invocation of convertQuery
> {{var config = Frameworks.newConfigBuilder()}}
> {{ .operatorTable(getOperatorTable())}}
> {{ .parserConfig(defaultParserConfig().build())}}
> {{ .build();}}
> {{var sqlNode = Frameworks.getPlanner(config).parse(sqlString);}}
> {{var typeFactory = new JavaTypeFactoryImpl();}}
> {{var calciteSchema = buildCalciteSchema(typeFactory, schema);}}
> {{var catalogReader = new CalciteCatalogReader(}}
> {{ calciteSchema,}}
> {{ List.of(),}}
> {{ typeFactory,}}
> {{ CalciteConnectionConfig.DEFAULT);}}
> {{var validator = new SqlValidatorImpl(}}
> {{ getOperatorTable(),}}
> {{ catalogReader,}}
> {{ typeFactory,}}
> {{ SqlValidator.Config.DEFAULT.withCallRewrite(false)) {};}}
> {{var vol = new VolcanoPlanner();}}
> {{vol.addRelTraitDef(ConventionTraitDef.INSTANCE);}}
> {{var cluster = RelOptCluster.create(vol, new RexBuilder(typeFactory));}}
> {{var sqlToRel = new SqlToRelConverter(}}
> {{ NOOP_EXPANDER,}}
> {{ validator,}}
> {{ catalogReader,}}
> {{ cluster,}}
> {{ StandardConvertletTable.INSTANCE,}}
> {{ SqlToRelConverter.config());}}
> {{return sqlToRel.convertQuery(sqlNode, true, true);}}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)