-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement correct logic for nested lambdas and more complex lam…
…bda expressions (#7056) * feat: implement correct logic for nested lambdas and more complex lambda expressions * qtt * update qtt and add more comments to clarify code
- Loading branch information
1 parent
5c6e9cf
commit 1a042cd
Showing
13 changed files
with
1,069 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
ksqldb-execution/src/main/java/io/confluent/ksql/execution/codegen/TypeContextUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* Copyright 2021 Confluent Inc. | ||
* | ||
* Licensed under the Confluent Community License (the "License"); you may not use | ||
* this file except in compliance with the License. You may obtain a copy of the | ||
* License at | ||
* | ||
* http://www.confluent.io/confluent-community-license | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OF ANY KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations under the License. | ||
*/ | ||
|
||
package io.confluent.ksql.execution.codegen; | ||
|
||
import io.confluent.ksql.execution.expression.tree.Expression; | ||
import io.confluent.ksql.execution.expression.tree.LambdaFunctionCall; | ||
|
||
public final class TypeContextUtil { | ||
private TypeContextUtil() { | ||
|
||
} | ||
|
||
/** | ||
* Returns a copy of the appropriate context to use when processing an expression subtree. | ||
* A copy is required to prevent different subtrees from getting a context that's been | ||
* modified by another subtree. For non-lambdas we want to use the parent context because | ||
* there may be valid overlapping lambda parameter names in different child nodes. For | ||
* lambdas, we want to use the updateContext which has the type information the lambda | ||
* expression body needs. | ||
* | ||
* @param expression the current expression we're processing | ||
* @param parentContext the context passed into the parent node of the expression | ||
* @param updatedContext the context that has been updated as we processed other child | ||
* nodes | ||
* @return a copy of either parent or current type context to be passed to the child | ||
*/ | ||
public static TypeContext contextForExpression( | ||
final Expression expression, | ||
final TypeContext parentContext, | ||
final TypeContext updatedContext | ||
) { | ||
if (expression instanceof LambdaFunctionCall) { | ||
return updatedContext.getCopy(); | ||
} else { | ||
return parentContext.getCopy(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.