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

Array cast failing after version bump #18456

Closed
padraic00 opened this issue Jul 28, 2023 · 1 comment · Fixed by #20429
Closed

Array cast failing after version bump #18456

padraic00 opened this issue Jul 28, 2023 · 1 comment · Fixed by #20429

Comments

@padraic00
Copy link

Finding inconsistent behavior between versions when casting between types Array(JSON) and Array(DOUBLE).

Trino 418

Final cast from type Array(JSON) to Array(DOUBLE) succeeds:

with
    a as (select
              raw_json_string,
              cast(json_parse(raw_json_string) as MAP (VARCHAR, JSON)) as map
          from
              (values ('{"a":{"price":1},"b":{"price":2}}')) as t(raw_json_string)),
    b as (select
              a.*,
              transform_values(a.map, (k, v) -> json_extract(v, '$.price')) as transformed_map
          from
              a),
    c as (select b.*, map_values(b.transformed_map) as values_from_map from b)
select
    c.*,
    cast(values_from_map as array(DOUBLE)) as values_as_double
from
    c;

Returns:

+---------------------------------+------------------------------+---------------+---------------+----------------+
|raw_json_string                  |map                           |transformed_map|values_from_map|values_as_double|
+---------------------------------+------------------------------+---------------+---------------+----------------+
|{"a":{"price":1},"b":{"price":2}}|{a={"price":1}, b={"price":2}}|{a=1, b=2}     |{1,2}          |{1,2}           |
+---------------------------------+------------------------------+---------------+---------------+----------------+

Trino 421

Same query fails with the following error:

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:2109)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:1992)
	...
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2085)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4011)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4034)

Full stack trace posted at the end

Work around in Trino 421

Pushing the cast to double into the tranform_values call fixes this:

with
    a as (select
              raw_json_string,
              cast(json_parse(raw_json_string) as MAP (VARCHAR, JSON)) as map
          from
                  (values ('{"a":{"price":1},"b":{"price":2}}')) as t(raw_json_string)),
    b as (select
              a.*,
              transform_values(a.map, (k, v) -> cast(json_extract(v, '$.price') as DOUBLE)) as transformed_map
          from
              a),
    c as (select b.*, map_values(b.transformed_map) as values_from_map from b)
select
    c.*
from
    c;

Returns

+---------------------------------+------------------------------+---------------+---------------+
|raw_json_string                  |map                           |transformed_map|values_from_map|
+---------------------------------+------------------------------+---------------+---------------+
|{"a":{"price":1},"b":{"price":2}}|{a={"price":1}, b={"price":2}}|{a=1.0, b=2.0} |{1,2}          |
+---------------------------------+------------------------------+---------------+---------------+

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:2109)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:1992)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.ProjectNode.accept(ProjectNode.java:81)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitScanFilterAndProject(LocalExecutionPlanner.java:2039)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:1992)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.ProjectNode.accept(ProjectNode.java:81)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitAggregation(LocalExecutionPlanner.java:1927)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitAggregation(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.AggregationNode.accept(AggregationNode.java:221)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.createLocalExchange(LocalExecutionPlanner.java:3694)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitExchange(LocalExecutionPlanner.java:3593)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitExchange(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.ExchangeNode.accept(ExchangeNode.java:245)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitAggregation(LocalExecutionPlanner.java:1927)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitAggregation(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.AggregationNode.accept(AggregationNode.java:221)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitScanFilterAndProject(LocalExecutionPlanner.java:2039)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:1992)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitProject(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.ProjectNode.accept(ProjectNode.java:81)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitOutput(LocalExecutionPlanner.java:994)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitOutput(LocalExecutionPlanner.java:905)
	at io.trino.sql.planner.plan.OutputNode.accept(OutputNode.java:82)
	at io.trino.sql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:628)
	at io.trino.sql.planner.LocalExecutionPlanner.plan(LocalExecutionPlanner.java:534)
	at io.trino.execution.SqlTaskExecutionFactory.create(SqlTaskExecutionFactory.java:84)
	at io.trino.execution.SqlTask.tryCreateSqlTaskExecution(SqlTask.java:541)
	at io.trino.execution.SqlTask.updateTask(SqlTask.java:493)
	at io.trino.execution.SqlTaskManager.doUpdateTask(SqlTaskManager.java:532)
	at io.trino.execution.SqlTaskManager.lambda$updateTask$9(SqlTaskManager.java:476)
	at io.trino.$gen.Trino_421____20230726_142348_2.call(Unknown Source)
	at io.trino.execution.SqlTaskManager.updateTask(SqlTaskManager.java:476)
	at io.trino.server.TaskResource.createOrUpdateTask(TaskResource.java:153)
	at jdk.internal.reflect.GeneratedMethodAccessor357.invoke(Unknown Source)
	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.lambda$handle$0(HttpChannel.java:505)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:762)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:497)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:282)
	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:416)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.consumeTask(AdaptiveExecutionStrategy.java:385)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.tryProduce(AdaptiveExecutionStrategy.java:272)
	at org.eclipse.jetty.util.thread.strategy.AdaptiveExecutionStrategy.lambda$new$0(AdaptiveExecutionStrategy.java:140)
	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:833)
Caused by: com.google.common.util.concurrent.UncheckedExecutionException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2085)
	at com.google.common.cache.LocalCache.get(LocalCache.java:4011)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4034)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5010)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:5017)
	at com.google.common.cache.ForwardingLoadingCache.getUnchecked(ForwardingLoadingCache.java:54)
	at io.trino.sql.gen.PageFunctionCompiler.compileProjection(PageFunctionCompiler.java:170)
	at io.trino.sql.gen.ExpressionCompiler.lambda$compilePageProcessor$3(ExpressionCompiler.java:115)
	at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
	at java.base/java.util.Spliterators$ArraySpliterator.forEachRemaining(Spliterators.java:992)
	at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
	at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
	at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
	at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
	at io.trino.sql.gen.ExpressionCompiler.compilePageProcessor(ExpressionCompiler.java:116)
	at io.trino.sql.gen.ExpressionCompiler.compilePageProcessor(ExpressionCompiler.java:104)
	at io.trino.sql.planner.LocalExecutionPlanner$Visitor.visitScanFilterAndProject(LocalExecutionPlanner.java:2093)
	... 100 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:96)
	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:86)
	at io.trino.sql.gen.RowExpressionCompiler.compile(RowExpressionCompiler.java:75)
	at io.trino.sql.gen.BytecodeGeneratorContext.lambda$argumentCompiler$1(BytecodeGeneratorContext.java:106)
	at io.trino.sql.gen.BytecodeUtils.generateFullInvocation(BytecodeUtils.java:245)
	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:86)
	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.PageFunctionCompiler.generateEvaluateMethod(PageFunctionCompiler.java:360)
	at io.trino.sql.gen.PageFunctionCompiler.definePageProjectWorkClass(PageFunctionCompiler.java:245)
	at io.trino.sql.gen.PageFunctionCompiler.compileProjectionInternal(PageFunctionCompiler.java:193)
	at io.trino.sql.gen.PageFunctionCompiler.lambda$new$0(PageFunctionCompiler.java:127)
	at com.google.common.cache.CacheLoader$FunctionToCacheLoader.load(CacheLoader.java:169)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3570)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2312)
	at com.google.common.cache.LocalCache$Segment.lockedGetOrLoad(LocalCache.java:2189)
	at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2079)
	... 117 more
Caused by: java.lang.RuntimeException: java.lang.RuntimeException: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at io.trino.metadata.InternalFunctionBundle.getScalarFunctionImplementation(InternalFunctionBundle.java:134)
	at io.trino.metadata.GlobalFunctionCatalog.getScalarFunctionImplementation(GlobalFunctionCatalog.java:177)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementationInternal(FunctionManager.java:103)
	at io.trino.metadata.FunctionManager.lambda$getScalarFunctionImplementation$0(FunctionManager.java:92)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4924)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3570)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2312)
	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:4011)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4919)
	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:92)
	... 143 more
Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementation(FunctionManager.java:96)
	at io.trino.metadata.InternalFunctionDependencies.getCastImplementationSignature(InternalFunctionDependencies.java:182)
	at io.trino.operator.annotations.CastImplementationDependency.getImplementation(CastImplementationDependency.java:62)
	at io.trino.operator.annotations.ScalarImplementationDependency.resolve(ScalarImplementationDependency.java:58)
	at io.trino.operator.ParametricFunctionHelpers.bindDependencies(ParametricFunctionHelpers.java:34)
	at io.trino.operator.scalar.annotations.ParametricScalarImplementation.specialize(ParametricScalarImplementation.java:184)
	at io.trino.operator.scalar.ParametricScalar.specialize(ParametricScalar.java:144)
	at io.trino.metadata.InternalFunctionBundle.specializeScalarFunction(InternalFunctionBundle.java:143)
	at io.trino.metadata.InternalFunctionBundle.lambda$getScalarFunctionImplementation$1(InternalFunctionBundle.java:130)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4924)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3570)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2312)
	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:4011)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4919)
	at com.google.common.cache.ForwardingCache.get(ForwardingCache.java:55)
	at io.trino.cache.CacheUtils.uncheckedCacheGet(CacheUtils.java:32)
	at io.trino.metadata.InternalFunctionBundle.getScalarFunctionImplementation(InternalFunctionBundle.java:127)
	... 156 more
Caused by: java.lang.IllegalArgumentException: target and filter types do not match: (BlockBuilder,double)void, (Slice)Double
	at java.base/java.lang.invoke.MethodHandleStatics.newIllegalArgumentException(MethodHandleStatics.java:175)
	at java.base/java.lang.invoke.MethodHandles.collectArgumentsChecks(MethodHandles.java:5768)
	at java.base/java.lang.invoke.MethodHandles.collectArguments(MethodHandles.java:5748)
	at io.trino.spi.function.ScalarFunctionAdapter.adaptReturn(ScalarFunctionAdapter.java:225)
	at io.trino.spi.function.ScalarFunctionAdapter.adapt(ScalarFunctionAdapter.java:177)
	at io.trino.operator.scalar.ChoicesSpecializedSqlScalarFunction.getScalarFunctionImplementation(ChoicesSpecializedSqlScalarFunction.java:113)
	at io.trino.metadata.InternalFunctionBundle.getScalarFunctionImplementation(InternalFunctionBundle.java:136)
	at io.trino.metadata.GlobalFunctionCatalog.getScalarFunctionImplementation(GlobalFunctionCatalog.java:177)
	at io.trino.metadata.FunctionManager.getScalarFunctionImplementationInternal(FunctionManager.java:103)
	at io.trino.metadata.FunctionManager.lambda$getScalarFunctionImplementation$0(FunctionManager.java:92)
	at com.google.common.cache.LocalCache$LocalManualCache$1.load(LocalCache.java:4924)
	at com.google.common.cache.LocalCache$LoadingValueReference.loadFuture(LocalCache.java:3570)
	at com.google.common.cache.LocalCache$Segment.loadSync(LocalCache.java:2312)
	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:4011)
	at com.google.common.cache.LocalCache$LocalManualCache.get(LocalCache.java:4919)
	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:92)
	... 174 more
@pettyjamesm
Copy link
Member

cc: @dain - this looks like another bug introduced by #18094 which is still present after #18473. ScalarFunctionAdapter.adaptReturn is trying to use BLOCK_BUILDER return convention but still has a boxed Double as the return type from the JsonOperators.castToDouble method handle instead of the primitive that the target#writeDouble(BlockBuilder, double) handle expects.

dain added a commit to dain/trino that referenced this issue Jan 20, 2024
When adapting a nullable function to a BLOCK_BUILDER return, a null must
be appended when the function return value is null.

Fixes trinodb#18456

Co-authored-by: Dain Sundstrom <[email protected]>
dain added a commit that referenced this issue Jan 20, 2024
When adapting a nullable function to a BLOCK_BUILDER return, a null must
be appended when the function return value is null.

Fixes #18456

Co-authored-by: Dain Sundstrom <[email protected]>
abusk pushed a commit to abusk/trino that referenced this issue Jan 22, 2024
When adapting a nullable function to a BLOCK_BUILDER return, a null must
be appended when the function return value is null.

Fixes trinodb#18456

Co-authored-by: Dain Sundstrom <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants