Failed to recognize predicate 'ARRAY'. Failed rule: 'identifier' in table or column identifier
jixuekang opened this issue · 3 comments
I am having a problem with sql translation to Trino that results in a query with an identifier column.
SELECT numbers , animal , n , a
FROM (
VALUES
( ARRAY [ 2 , 5 ], ARRAY [ 'dog' , 'cat' , 'bird' ]),
( ARRAY [ 7 , 8 , 9 ], ARRAY [ 'cow' , 'pig' ])
) AS x ( numbers , animals )
CROSS JOIN UNNEST ( numbers, 动物) AS t ( n , a );
@jixuekang could you please share the input SQL and full stacktrace?
this is my input sql:
SELECT numbers , animal , n , a FROM ( VALUES ( ARRAY [ 2 , 5 ], ARRAY [ 'dog' , 'cat' , 'bird' ]), ( ARRAY [ 7 , 8 , 9 ], ARRAY [ 'cow' , 'pig' ]) ) AS x ( numbers , animals ) CROSS JOIN UNNEST ( numbers, 动物) AS t ( n , a );
this is full stacktrace:
2022-07-01 13:54:54 [WARN] com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.useSQL11ReservedKeywordsForIdentifier(HiveParser.java:1008) - null
FailedPredicateException(identifier,{useSQL11ReservedKeywordsForIdentifier()}?)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_IdentifiersParser.identifier(HiveParser_IdentifiersParser.java:10351)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.identifier(HiveParser.java:40372)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.tableOrColumn(HiveParser_FromClauseParser.java:922)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.tableOrColumn(HiveParser.java:40396)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_IdentifiersParser.atomExpression(HiveParser_IdentifiersParser.java:5515)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_IdentifiersParser.precedenceFieldExpression(HiveParser_IdentifiersParser.java:5603)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_IdentifiersParser.precedenceUnaryPrefixExpression(HiveParser_IdentifiersParser.java:5980)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.precedenceUnaryPrefixExpression(HiveParser.java:40453)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.valueRowConstructor(HiveParser_FromClauseParser.java:5911)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.valuesTableConstructor(HiveParser_FromClauseParser.java:6049)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.valuesClause(HiveParser_FromClauseParser.java:6185)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.virtualTableSource(HiveParser_FromClauseParser.java:6275)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.fromSource(HiveParser_FromClauseParser.java:3027)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.joinSource(HiveParser_FromClauseParser.java:1417)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser_FromClauseParser.fromClause(HiveParser_FromClauseParser.java:1290)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.fromClause(HiveParser.java:40449)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.selectStatement(HiveParser.java:36259)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.regularBody(HiveParser.java:36148)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.queryStatementExpressionBody(HiveParser.java:35180)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.queryStatementExpression(HiveParser.java:35057)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.execStatement(HiveParser.java:1529)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.HiveParser.statement(HiveParser.java:1089)
at com.linkedin.coral.hive.hive2rel.parsetree.parser.CoralParseDriver.parse(CoralParseDriver.java:35)
at com.linkedin.coral.hive.hive2rel.parsetree.ParseTreeBuilder.process(ParseTreeBuilder.java:109)
at com.linkedin.coral.hive.hive2rel.HiveToRelConverter.toSqlNode(HiveToRelConverter.java:94)
at com.linkedin.coral.common.ToRelConverter.toSqlNode(ToRelConverter.java:139)
at com.linkedin.coral.common.ToRelConverter.convertSql(ToRelConverter.java:119)
at com.luckincoffee.dataq.CoralHiveTest.hive2Presto(CoralHiveTest.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
java.lang.RuntimeException: com.linkedin.coral.hive.hive2rel.parsetree.parser.ParseException: line 1:48 Failed to recognize predicate 'ARRAY'. Failed rule: 'identifier' in table or column identifier
at com.linkedin.coral.hive.hive2rel.parsetree.ParseTreeBuilder.process(ParseTreeBuilder.java:112)
at com.linkedin.coral.hive.hive2rel.HiveToRelConverter.toSqlNode(HiveToRelConverter.java:94)
at com.linkedin.coral.common.ToRelConverter.toSqlNode(ToRelConverter.java:139)
at com.linkedin.coral.common.ToRelConverter.convertSql(ToRelConverter.java:119)
at com.luckincoffee.dataq.CoralHiveTest.hive2Presto(CoralHiveTest.java:92)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:220)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:53)
Caused by: com.linkedin.coral.hive.hive2rel.parsetree.parser.ParseException: line 1:48 Failed to recognize predicate 'ARRAY'. Failed rule: 'identifier' in table or column identifier
at com.linkedin.coral.hive.hive2rel.parsetree.parser.CoralParseDriver.parse(CoralParseDriver.java:38)
at com.linkedin.coral.hive.hive2rel.parsetree.ParseTreeBuilder.process(ParseTreeBuilder.java:109)
... 27 more
Hi @jixuekang , looks like your input is a Trino SQL, but HiveToRelConverter
expects Hive SQL as input.