Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error using non-lowercase identifiers in SQL routines #24460

Open
aalbu opened this issue Dec 12, 2024 · 1 comment
Open

Error using non-lowercase identifiers in SQL routines #24460

aalbu opened this issue Dec 12, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@aalbu
Copy link
Member

aalbu commented Dec 12, 2024

Using an identifier with upper case letters in a routine causes an exception:

with function uppercaseFailure()
returns double 
begin 
  DECLARE UPPERCASEVAR DOUBLE DEFAULT 0;
  RETURN UPPERCASEVAR;
end
select uppercaseFailure();

results in

java.lang.RuntimeException: java.lang.UnsupportedOperationException
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:97)
	at io.trino.sql.InterpretedFunctionInvoker.invoke(InterpretedFunctionInvoker.java:63)
	at io.trino.sql.ir.optimizer.IrExpressionEvaluator.evaluateInternal(IrExpressionEvaluator.java:339)
	at io.trino.sql.ir.optimizer.IrExpressionEvaluator.evaluate(IrExpressionEvaluator.java:99)
	at io.trino.sql.ir.optimizer.rule.EvaluateCall.apply(EvaluateCall.java:76)
	at io.trino.sql.ir.optimizer.IrExpressionOptimizer.applyRules(IrExpressionOptimizer.java:293)
	at io.trino.sql.ir.optimizer.IrExpressionOptimizer.process(IrExpressionOptimizer.java:168)
	at io.trino.sql.planner.iterative.rule.SimplifyExpressions.rewrite(SimplifyExpressions.java:44)
	at io.trino.sql.planner.iterative.rule.SimplifyExpressions.lambda$createRewrite$0(SimplifyExpressions.java:67)
	at io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet$ProjectExpressionRewrite.lambda$apply$0(ExpressionRewriteRuleSet.java:131)
	at io.trino.sql.planner.plan.Assignments.lambda$rewrite$0(Assignments.java:113)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
	at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133)
	at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1939)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:570)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:727)
	at io.trino.sql.planner.plan.Assignments.rewrite(Assignments.java:114)
	at io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet$ProjectExpressionRewrite.apply(ExpressionRewriteRuleSet.java:131)
	at io.trino.sql.planner.iterative.rule.ExpressionRewriteRuleSet$ProjectExpressionRewrite.apply(ExpressionRewriteRuleSet.java:112)
	at io.trino.sql.planner.iterative.IterativeOptimizer.transform(IterativeOptimizer.java:216)
	at io.trino.sql.planner.iterative.IterativeOptimizer.exploreNode(IterativeOptimizer.java:181)
	at io.trino.sql.planner.iterative.IterativeOptimizer.exploreGroup(IterativeOptimizer.java:144)
	at io.trino.sql.planner.iterative.IterativeOptimizer.exploreChildren(IterativeOptimizer.java:264)
	at io.trino.sql.planner.iterative.IterativeOptimizer.exploreGroup(IterativeOptimizer.java:146)
	at io.trino.sql.planner.iterative.IterativeOptimizer.optimizeAndMarkPlanChanges(IterativeOptimizer.java:129)
	at io.trino.sql.planner.optimizations.AdaptivePlanOptimizer.optimize(AdaptivePlanOptimizer.java:33)
	at io.trino.sql.planner.LogicalPlanner.runOptimizer(LogicalPlanner.java:354)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:290)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:262)
	at io.trino.sql.planner.LogicalPlanner.plan(LogicalPlanner.java:257)
	at io.trino.execution.SqlQueryExecution.doPlanQuery(SqlQueryExecution.java:565)
	at io.trino.execution.SqlQueryExecution.planQuery(SqlQueryExecution.java:542)
	at io.trino.execution.SqlQueryExecution.start(SqlQueryExecution.java:480)
	at io.trino.execution.SqlQueryManager.createQuery(SqlQueryManager.java:281)
	at io.trino.dispatcher.LocalDispatchQuery.startExecution(LocalDispatchQuery.java:153)
	at io.trino.dispatcher.LocalDispatchQuery.lambda$waitForMinimumWorkers$2(LocalDispatchQuery.java:137)
	at io.airlift.concurrent.MoreFutures.lambda$addSuccessCallback$12(MoreFutures.java:570)
	at io.airlift.concurrent.MoreFutures$3.onSuccess(MoreFutures.java:545)
	at com.google.common.util.concurrent.Futures$CallbackListener.run(Futures.java:1137)
	at io.trino.$gen.Trino_466_galaxy_1_u33_g98bedc2ee97____20241212_084654_2.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
	at java.base/java.lang.Thread.run(Thread.java:1575)
Caused by: java.lang.UnsupportedOperationException: undefined
	at io.trino.sql.routine.SqlRoutineCompiler$FieldReferenceCompiler.visitVariableReference(SqlRoutineCompiler.java:575)
	at io.trino.sql.routine.SqlRoutineCompiler$FieldReferenceCompiler.visitVariableReference(SqlRoutineCompiler.java:534)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitVariableReference(RowExpressionCompiler.java:211)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitVariableReference(RowExpressionCompiler.java:87)
	at io.trino.sql.relational.VariableReferenceExpression.accept(VariableReferenceExpression.java:38)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:84)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:79)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.compile(SqlRoutineCompiler.java:480)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitReturn(SqlRoutineCompiler.java:360)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitReturn(SqlRoutineCompiler.java:283)
	at io.trino.sql.routine.ir.IrReturn.accept(IrReturn.java:31)
	at io.trino.sql.routine.ir.IrNodeVisitor.process(IrNodeVisitor.java:20)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitBlock(SqlRoutineCompiler.java:346)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitBlock(SqlRoutineCompiler.java:283)
	at io.trino.sql.routine.ir.IrBlock.accept(IrBlock.java:41)
	at io.trino.sql.routine.ir.IrNodeVisitor.process(IrNodeVisitor.java:20)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitRoutine(SqlRoutineCompiler.java:315)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitRoutine(SqlRoutineCompiler.java:283)
	at io.trino.sql.routine.ir.IrRoutine.accept(IrRoutine.java:35)
	at io.trino.sql.routine.ir.IrNodeVisitor.process(IrNodeVisitor.java:20)
	at io.trino.sql.routine.SqlRoutineCompiler.generateRunMethod(SqlRoutineCompiler.java:230)
	at io.trino.sql.routine.SqlRoutineCompiler.compileClass(SqlRoutineCompiler.java:174)
	at io.trino.sql.routine.SqlRoutineCompiler.compile(SqlRoutineCompiler.java:135)
	at io.trino.metadata.LanguageFunctionManager$QueryFunctions.specialize(LanguageFunctionManager.java:296)
	at io.trino.metadata.LanguageFunctionManager.lambda$specialize$1(LanguageFunctionManager.java:178)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:215)
	at java.base/java.util.concurrent.ConcurrentHashMap$ValueSpliterator.tryAdvance(ConcurrentHashMap.java:3625)
	at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:147)
	at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:588)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:574)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:560)
	at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:265)
	at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:687)
	at io.trino.metadata.LanguageFunctionManager.specialize(LanguageFunctionManager.java:181)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementationInternal(FunctionManager.java:105)
	at io.trino.metadata.FunctionManager.lambda$getScalarFunctionImplementation$0(FunctionManager.java:93)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4903)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3574)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2316)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2189)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2079)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4017)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4898)
	at com.google.common.cache.ForwardingCache.get(ForwardingCache.java:55)
	at io.trino.cache.CacheUtils.uncheckedCacheGet(CacheUtils.java:39)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:93)
	... 45 more
@aalbu aalbu added the bug Something isn't working label Dec 12, 2024
@mosabua
Copy link
Member

mosabua commented Dec 12, 2024

Lets also update the docs when fixing this please .. whatever the rule.. no uppercase allowed or not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

2 participants