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

NULLIF function fails in SQL routines #19820

Closed
guyco33 opened this issue Nov 19, 2023 · 1 comment · Fixed by #21749
Closed

NULLIF function fails in SQL routines #19820

guyco33 opened this issue Nov 19, 2023 · 1 comment · Fixed by #21749
Labels
bug Something isn't working

Comments

@guyco33
Copy link
Member

guyco33 commented Nov 19, 2023

The following query fails on INTERNAL ERROR — COMPILER_ERROR

WITH FUNCTION my_func(x bigint)
    RETURNS bigint
    RETURN nullif(x, 1)
SELECT my_func(nationkey)
FROM tpch.tiny.nation

Query fails only when worker is not running on the coordinator, so it seems to be a serialization issue.

Stack trace:

io.trino.spi.TrinoException: Compiler failed. Possible reasons include: the query may have too many or too complex expressions, or the underlying tables may have too many columns
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitScanFilterAndProject(LocalExecutionPlanner.java:2088)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:1971)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:886)
	at io.trino.sql.planner.plan.ProjectNode.accept(ProjectNode.java:81)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitOutput(LocalExecutionPlanner.java:975)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitOutput(LocalExecutionPlanner.java:886)
	at io.trino.sql.planner.plan.OutputNode.accept(OutputNode.java:82)
	at io.trino.sql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:645)
	at io.trino.sql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:544)
	at io.trino.execution.SqlTaskExecutionFactory.create(SqlTaskExecutionFactory.java:84)
	at io.trino.execution.SqlTask.tryCreateSqlTaskExecution(SqlTask.java:545)
	at io.trino.execution.SqlTask.updateTask(SqlTask.java:497)
	at io.trino.execution.SqlTaskManager.doUpdateTask(SqlTaskManager.java:544)
	at io.trino.execution.SqlTaskManager.lambda$updateTask$9(SqlTaskManager.java:485)
	at io.trino.$gen.Trino_433____20231119_133945_2.call(Unknown Source)
	at io.trino.execution.SqlTaskManager.updateTask(SqlTaskManager.java:485)
	at io.trino.server.TaskResource.createOrUpdateTask(TaskResource.java:153)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:134)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:177)
	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$VoidOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:159)
	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:81)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:478)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:400)
	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:81)
	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:261)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248)
	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:292)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:274)
	at org.glassfish.jersey.internal.Errors.process(Errors.java:244)
	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265)
	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:240)
	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:697)
	at org.glassfish.jersey.servlet.WebComponent.serviceImpl(WebComponent.java:394)
	at org.glassfish.jersey.servlet.WebComponent.service(WebComponent.java:346)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:357)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:311)
	at org.glassfish.jersey.servlet.ServletContainer.service(ServletContainer.java:205)
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:764)
	at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1665)
	at io.airlift.http.server.TraceTokenFilter.doFilter(TraceTokenFilter.java:62)
	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
	at io.airlift.http.server.TimingFilter.doFilter(TimingFilter.java:51)
	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:202)
	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1635)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:527)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:131)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
	at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:822)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:223)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1381)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:176)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:484)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:174)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1303)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:129)
	at org.eclipse.jetty.server.handler.HandlerCollection.handle(HandlerCollection.java:141)
	at org.eclipse.jetty.server.handler.StatisticsHandler.handle(StatisticsHandler.java:173)
	at org.eclipse.jetty.server.handler.HandlerList.handle(HandlerList.java:51)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:122)
	at org.eclipse.jetty.server.Server.handle(Server.java:563)
	at org.eclipse.jetty.server.HttpChannel$RequestDispatchable.dispatch(HttpChannel.java:1598)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:753)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:501)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:287)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:314)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:100)
	at org.eclipse.jetty.io.SelectableChannelEndPoint$1.run(SelectableChannelEndPoint.java:53)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.runTask(AdaptiveExecutionStrategy.java:421)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:390)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:277)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.run(AdaptiveExecutionStrategy.java:199)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:411)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:969)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.doRunJob(QueuedThreadPool.java:1194)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1149)
	at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: java.lang.IllegalArgumentException: Expected operator: EQUAL
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2087)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4019)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4042)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5024)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5031)
	at com.google.common.cache.ForwardingLoadingCache.getUnchecked(ForwardingLoadingCache.java:54)
	at io.trino.sql.gen.ExpressionCompiler.compileCursorProcessor(ExpressionCompiler.java:85)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitScanFilterAndProject(LocalExecutionPlanner.java:2053)
	... 83 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Expected operator: EQUAL
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:97)
	at io.trino.sql.gen.BytecodeUtils.lambda$generateFullInvocation$3(BytecodeUtils.java:220)
	at io.trino.sql.gen.BytecodeUtils.generateFullInvocation(BytecodeUtils.java:256)
	at io.trino.sql.gen.BytecodeUtils.generateFullInvocation(BytecodeUtils.java:213)
	at io.trino.sql.gen.BytecodeGeneratorContext.generateFullCall(BytecodeGeneratorContext.java:101)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitCall(RowExpressionCompiler.java:91)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitCall(RowExpressionCompiler.java:78)
	at io.trino.sql.relational.CallExpression.accept(CallExpression.java:93)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:75)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:70)
	at io.trino.sql.gen.CursorProcessorCompiler.generateProjectMethod(CursorProcessorCompiler.java:290)
	at io.trino.sql.gen.CursorProcessorCompiler.generateMethods(CursorProcessorCompiler.java:86)
	at io.trino.sql.gen.ExpressionCompiler.compileProcessor(ExpressionCompiler.java:157)
	at io.trino.sql.gen.ExpressionCompiler.compile(ExpressionCompiler.java:141)
	at io.trino.sql.gen.ExpressionCompiler.lambda$new$0(ExpressionCompiler.java:70)
	at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:169)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3576)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2318)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2191)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2081)
	... 90 more
Caused by: java.lang.IllegalArgumentException: Expected operator: EQUAL
	at io.trino.sql.relational.SpecialForm.getOperatorDependency(SpecialForm.java:83)
	at io.trino.sql.gen.NullIfCodeGenerator.<init>(NullIfCodeGenerator.java:56)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitSpecialForm(RowExpressionCompiler.java:105)
	at io.trino.sql.gen.RowExpressionCompiler$Visitor.visitSpecialForm(RowExpressionCompiler.java:78)
	at io.trino.sql.relational.SpecialForm.accept(SpecialForm.java:144)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:75)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:70)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.compile(SqlRoutineCompiler.java:473)
	at io.trino.sql.routine.SqlRoutineCompiler$BytecodeVisitor.visitReturn(SqlRoutineCompiler.java:357)
	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.visitRoutine(SqlRoutineCompiler.java:312)
	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.WorkerLanguageFunctionProvider.specialize(WorkerLanguageFunctionProvider.java:60)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementationInternal(FunctionManager.java:107)
	at io.trino.metadata.FunctionManager.lambda$getScalarFunctionImplementation$0(FunctionManager.java:93)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4938)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3576)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2318)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2191)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2081)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4019)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4933)
	at com.google.common.cache.ForwardingCache.get(ForwardingCache.java:55)
	at io.trino.cache.CacheUtils.uncheckedCacheGet(CacheUtils.java:32)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:93)
	... 109 more
@wendigo
Copy link
Contributor

wendigo commented Apr 29, 2024

@guyco33 found it :)

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

Successfully merging a pull request may close this issue.

2 participants