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 a
UnsupportedOperationException: class org.apache.calcite.sql.SqlBasicCall:
LEAD(COUNT(*)) OVER (ORDER BY `dim4`)
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.
--
[image: Download the Buyers Guide for Warehouse-Native Product Analytics]
<https://www.netspring.io/resources/buyers-guide/>
*Jordie Hannel*
Founding Product Owner
www.netspring.io
java.lang.UnsupportedOperationException: class
org.apache.calcite.sql.SqlBasicCall: LEAD(COUNT(*)) OVER (ORDER BY `dim4`)
at org.apache.calcite.util.Util.needToImplement(Util.java:1119)
at
org.apache.calcite.sql.validate.SqlValidatorImpl.getValidatedNodeType(SqlValidatorImpl.java:1814)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertOver(SqlToRelConverter.java:2263)
at
org.apache.calcite.sql2rel.SqlToRelConverter.access$1900(SqlToRelConverter.java:235)
at
org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5461)
at
org.apache.calcite.sql2rel.StandardConvertletTable.lambda$new$11(StandardConvertletTable.java:271)
at
org.apache.calcite.sql2rel.SqlNodeToRexConverterImpl.convertCall(SqlNodeToRexConverterImpl.java:59)
at
org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:5655)
at
org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.visit(SqlToRelConverter.java:4826)
at org.apache.calcite.sql.SqlCall.accept(SqlCall.java:166)
at
org.apache.calcite.sql2rel.SqlToRelConverter$Blackboard.convertExpression(SqlToRelConverter.java:5468)
at
org.apache.calcite.sql2rel.SqlToRelConverter.createAggImpl(SqlToRelConverter.java:3499)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertAgg(SqlToRelConverter.java:3347)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelectImpl(SqlToRelConverter.java:755)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertSelect(SqlToRelConverter.java:681)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertQueryRecursive(SqlToRelConverter.java:3747)
at
org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:601)
at
io.netspring.netscript.NetScriptSql.parseRelNode(NetScriptSql.java:224)
at
io.netspring.netscript.NetScriptSql.convertDialect(NetScriptSql.java:354)
at io.netspring.polymon.net.SqlUtil.convertSqlDialect(SqlUtil.java:614)
at
io.netspring.polymon.explore.ExploreQueryTest.testDialectSql(ExploreQueryTest.java:182)
at
io.netspring.polymon.explore.ExploreQueryTest.testDialectSql(ExploreQueryTest.java:165)
at
io.netspring.polymon.explore.ExploreQueryTest.runTest(ExploreQueryTest.java:154)
at
io.netspring.polymon.explore.EventSegmentationQueryTest.runTest(EventSegmentationQueryTest.java:77)
at
io.netspring.polymon.explore.EventSegmentationQueryTest.runTest(EventSegmentationQueryTest.java:73)
at
io.netspring.polymon.explore.EventSegmentationQueryTest.testCustomPropWithPeriodOver(EventSegmentationQueryTest.java:506)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
at
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
at
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.rules.TestWatcher$1.evaluate(TestWatcher.java:61)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
at
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
at
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
at
com.google.testing.junit.runner.internal.junit4.CancellableRequestFactory$CancellableRunner.run(CancellableRequestFactory.java:108)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at org.junit.runner.JUnitCore.run(JUnitCore.java:115)
at
com.google.testing.junit.runner.junit4.JUnit4Runner.run(JUnit4Runner.java:116)
at
com.google.testing.junit.runner.BazelTestRunner.runTestsInSuite(BazelTestRunner.java:145)
at
com.google.testing.junit.runner.BazelTestRunner.main(BazelTestRunner.java:76)