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

DATE_DIFF() with just two args fails with NPE #108383

Closed
bpintea opened this issue May 7, 2024 · 1 comment · Fixed by #108834
Closed

DATE_DIFF() with just two args fails with NPE #108383

bpintea opened this issue May 7, 2024 · 1 comment · Fixed by #108834
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)

Comments

@bpintea
Copy link
Contributor

bpintea commented May 7, 2024

Description

row date_diff("year", "2021-12-12") and row date_diff("2021-12-12", "2022-12-12") will both NPE.

Caused by: java.lang.NullPointerException
	at java.base/java.util.Objects.requireNonNull(Objects.java:233)
	at java.base/java.util.ImmutableCollections.listFromTrustedArray(ImmutableCollections.java:215)
	at java.base/java.util.List.of(List.java:972)
	at org.elasticsearch.xpack.esql.expression.function.scalar.date.DateDiff.<init>(DateDiff.java:165)
	at org.elasticsearch.xpack.ql.expression.function.FunctionRegistry.lambda$def$8(FunctionRegistry.java:262)
	at org.elasticsearch.xpack.ql.expression.function.FunctionRegistry.lambda$def$3(FunctionRegistry.java:172)
	at org.elasticsearch.xpack.ql.expression.function.FunctionResolutionStrategy.buildResolved(FunctionResolutionStrategy.java:27)
	at org.elasticsearch.xpack.ql.expression.function.UnresolvedFunction.buildResolved(UnresolvedFunction.java:81)
	at org.elasticsearch.xpack.esql.analysis.Analyzer$ResolveFunctions.resolveFunction(Analyzer.java:757)
	at org.elasticsearch.xpack.esql.analysis.Analyzer$ResolveFunctions.lambda$rule$0(Analyzer.java:739)
	at org.elasticsearch.xpack.ql.tree.Node.lambda$transformDown$9(Node.java:185)
	at org.elasticsearch.xpack.ql.tree.Node.transformDown(Node.java:176)
	at org.elasticsearch.xpack.ql.tree.Node.lambda$transformDown$8(Node.java:179)
	at org.elasticsearch.xpack.ql.tree.Node.transformChildren(Node.java:211)
	at org.elasticsearch.xpack.ql.tree.Node.transformDown(Node.java:179)
	at org.elasticsearch.xpack.ql.tree.Node.transformDown(Node.java:185)
	at org.elasticsearch.xpack.ql.plan.QueryPlan.lambda$transformExpressionsOnly$3(QueryPlan.java:87)
	at org.elasticsearch.xpack.ql.plan.QueryPlan.doTransformExpression(QueryPlan.java:113)
	at org.elasticsearch.xpack.ql.plan.QueryPlan.doTransformExpression(QueryPlan.java:125)
	at org.elasticsearch.xpack.ql.plan.QueryPlan.lambda$transformExpressionsOnly$4(QueryPlan.java:87)
	at org.elasticsearch.xpack.ql.tree.NodeInfo.lambda$transform$0(NodeInfo.java:56)
	at org.elasticsearch.xpack.ql.tree.NodeInfo$2.innerTransform(NodeInfo.java:92)
	at org.elasticsearch.xpack.ql.tree.NodeInfo.transform(NodeInfo.java:60)
	at org.elasticsearch.xpack.ql.tree.Node.transformNodeProps(Node.java:260)
	at org.elasticsearch.xpack.ql.tree.Node.transformPropertiesOnly(Node.java:240)
	at org.elasticsearch.xpack.ql.plan.QueryPlan.transformExpressionsOnly(QueryPlan.java:87)
	at org.elasticsearch.xpack.esql.analysis.Analyzer$ResolveFunctions.rule(Analyzer.java:737)
	at org.elasticsearch.xpack.esql.analysis.Analyzer$ResolveFunctions.rule(Analyzer.java:733)
	at org.elasticsearch.xpack.ql.analyzer.AnalyzerRules$ParameterizedAnalyzerRule.lambda$apply$0(AnalyzerRules.java:103)
	at org.elasticsearch.xpack.ql.tree.Node.lambda$transformUp$11(Node.java:198)
	at org.elasticsearch.xpack.ql.tree.Node.transformUp(Node.java:192)
	at org.elasticsearch.xpack.ql.tree.Node.transformUp(Node.java:198)
	at org.elasticsearch.xpack.ql.analyzer.AnalyzerRules$ParameterizedAnalyzerRule.apply(AnalyzerRules.java:103)
	at org.elasticsearch.xpack.ql.analyzer.AnalyzerRules$ParameterizedAnalyzerRule.apply(AnalyzerRules.java:95)
	at org.elasticsearch.xpack.ql.rule.ParameterizedRuleExecutor.lambda$transform$0(ParameterizedRuleExecutor.java:29)
	at org.elasticsearch.xpack.ql.rule.RuleExecutor$Transformation.<init>(RuleExecutor.java:88)
	at org.elasticsearch.xpack.ql.rule.RuleExecutor.executeWithInfo(RuleExecutor.java:167)
	at org.elasticsearch.xpack.ql.rule.RuleExecutor.execute(RuleExecutor.java:136)
	at org.elasticsearch.xpack.esql.analysis.Analyzer.analyze(Analyzer.java:142)
	at org.elasticsearch.xpack.esql.session.EsqlSession.lambda$analyzedPlan$2(EsqlSession.java:157)
	at org.elasticsearch.xpack.esql.session.EsqlSession.lambda$preAnalyze$8(EsqlSession.java:196)
	at org.elasticsearch.server@8.15.0-SNAPSHOT/org.elasticsearch.action.ActionListenerImplementations$ResponseWrappingActionListener.onResponse(ActionListenerImplementations.java:245)
	... 22 more
"

@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label May 7, 2024
@elasticsearchmachine
Copy link
Collaborator

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

not-napoleon added a commit that referenced this issue May 21, 2024
Resolves #108383

I didn't see a good place to add a test for this; if there is one, let me know and I'm happy to add it.

This fixes a bug where we had incorrectly marked date_diff as having an optional argument, which resulted in an NPE when that argument was not provided. In fact, all three of date_diff's arguments are required. After this change, failing to provide one will cause a parse exception, as one would expect.
not-napoleon added a commit to not-napoleon/elasticsearch that referenced this issue May 21, 2024
Resolves elastic#108383

I didn't see a good place to add a test for this; if there is one, let me know and I'm happy to add it.

This fixes a bug where we had incorrectly marked date_diff as having an optional argument, which resulted in an NPE when that argument was not provided. In fact, all three of date_diff's arguments are required. After this change, failing to provide one will cause a parse exception, as one would expect.
elasticsearchmachine pushed a commit that referenced this issue May 21, 2024
…8874)

Resolves #108383

I didn't see a good place to add a test for this; if there is one, let me know and I'm happy to add it.

This fixes a bug where we had incorrectly marked date_diff as having an optional argument, which resulted in an NPE when that argument was not provided. In fact, all three of date_diff's arguments are required. After this change, failing to provide one will cause a parse exception, as one would expect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Analytics/ES|QL AKA ESQL >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants