elastic / elasticsearch

Free and Open Source, Distributed, RESTful Search Engine
https://www.elastic.co/products/elasticsearch
Other
1.09k stars 24.83k forks source link

ESQL: implicit casting can lead to internal server error #113242

Closed alex-spies closed 1 month ago

alex-spies commented 1 month ago

Found in Serverless, so cannot provide a reproducing query :/

But here's a stack trace!

org.elasticsearch.xpack.esql.core.capabilities.UnresolvedException: Invalid call to dataType on an unresolved object ?event.action
    at org.elasticsearch.xpack.esql.core.expression.UnresolvedAttribute.dataType(UnresolvedAttribute.java:87)
    at org.elasticsearch.xpack.esql.analysis.Analyzer$ImplicitCasting.processIn(Analyzer.java:1073)
    at org.elasticsearch.xpack.esql.analysis.Analyzer$ImplicitCasting.cast(Analyzer.java:977)
    at org.elasticsearch.xpack.esql.analysis.Analyzer$ImplicitCasting.lambda$apply$0(Analyzer.java:972)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$11(Node.java:199)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:193)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:199)
    at org.elasticsearch.xpack.esql.plan.QueryPlan.lambda$transformExpressionsUp$9(QueryPlan.java:119)
    at org.elasticsearch.xpack.esql.plan.QueryPlan.doTransformExpression(QueryPlan.java:125)
    at org.elasticsearch.xpack.esql.plan.QueryPlan.lambda$transformExpressionsUp$10(QueryPlan.java:119)
    at org.elasticsearch.xpack.esql.core.tree.NodeInfo.lambda$transform$0(NodeInfo.java:56)
    at org.elasticsearch.xpack.esql.core.tree.NodeInfo$3.innerTransform(NodeInfo.java:114)
    at org.elasticsearch.xpack.esql.core.tree.NodeInfo.transform(NodeInfo.java:60)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformNodeProps(Node.java:261)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformPropertiesUp$13(Node.java:249)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:193)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.lambda$transformUp$10(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformChildren(Node.java:212)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformUp(Node.java:191)
    at org.elasticsearch.xpack.esql.core.tree.Node.transformPropertiesUp(Node.java:249)
    at org.elasticsearch.xpack.esql.plan.QueryPlan.transformExpressionsUp(QueryPlan.java:119)
    at org.elasticsearch.xpack.esql.analysis.Analyzer$ImplicitCasting.apply(Analyzer.java:972)
    at org.elasticsearch.xpack.esql.analysis.Analyzer$ImplicitCasting.apply(Analyzer.java:969)
    at org.elasticsearch.xpack.esql.core.rule.ParameterizedRuleExecutor.lambda$transform$0(ParameterizedRuleExecutor.java:29)
    at org.elasticsearch.xpack.esql.core.rule.RuleExecutor$Transformation.<init>(RuleExecutor.java:88)
    at org.elasticsearch.xpack.esql.core.rule.RuleExecutor.executeWithInfo(RuleExecutor.java:167)
    at org.elasticsearch.xpack.esql.core.rule.RuleExecutor.execute(RuleExecutor.java:136)
    at org.elasticsearch.xpack.esql.analysis.Analyzer.analyze(Analyzer.java:161)
    at org.elasticsearch.xpack.esql.session.EsqlSession.lambda$analyzedPlan$4(EsqlSession.java:200)
    at org.elasticsearch.xpack.esql.session.EsqlSession.lambda$preAnalyze$10(EsqlSession.java:240)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:247)
    at org.elasticsearch.xpack.esql.session.IndexResolver.lambda$resolveAsMergedMapping$0(IndexResolver.java:82)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:247)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.tasks.TaskManager$1.onResponse(TaskManager.java:203)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.tasks.TaskManager$1.onResponse(TaskManager.java:197)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionListenerImplementations$RunBeforeActionListener.onResponse(ActionListenerImplementations.java:336)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.support.ContextPreservingActionListener.onResponse(ContextPreservingActionListener.java:33)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionListenerImplementations$MappedActionListener.onResponse(ActionListenerImplementations.java:97)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction.doExecuteForked(TransportFieldCapabilitiesAction.java:155)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.fieldcaps.TransportFieldCapabilitiesAction.lambda$executeRequest$0(TransportFieldCapabilitiesAction.java:126)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.action.ActionRunnable$4.doRun(ActionRunnable.java:101)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:27)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.TimedRunnable.doRun(TimedRunnable.java:34)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:992)
    at org.elasticsearch.server@9.0.0/org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:27)
    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:1570)
elasticsearchmachine commented 1 month ago

Pinging @elastic/es-analytical-engine (Team:Analytics)

alex-spies commented 1 month ago

@fang-xing-esql , I think here we get the left side's data type before checking that it is actually resolved.

Does it make sense if you pick this one up since you're the most familiar with this analyzer rule?

alex-spies commented 1 month ago

Reproducer:

row x = 0 | EVAL y = not_existing in (1, 2)
fang-xing-esql commented 1 month ago

@fang-xing-esql , I think here we get the left side's data type before checking that it is actually resolved.

Does it make sense if you pick this one up since you're the most familiar with this analyzer rule?

Yes, I'll take a look, thanks for the reproducer!