-
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: add lambda syntax to grammar (#6868)
* feat: add lambda syntax to grammar * change g4 * spacing
- Loading branch information
1 parent
03ad537
commit dd3f365
Showing
24 changed files
with
811 additions
and
15 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
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
45 changes: 45 additions & 0 deletions
45
ksqldb-engine/src/main/java/io/confluent/ksql/engine/rewrite/LambdaContext.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,45 @@ | ||
/* | ||
* 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.engine.rewrite; | ||
|
||
import io.confluent.ksql.util.KsqlException; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashSet; | ||
import java.util.List; | ||
import java.util.Objects; | ||
|
||
public class LambdaContext { | ||
private final List<String> lambdaArguments; | ||
|
||
public LambdaContext(final List<String> lambdaArguments) { | ||
this.lambdaArguments = new ArrayList<>( | ||
Objects.requireNonNull(lambdaArguments, "lambdaArguments")); | ||
} | ||
|
||
public void addLambdaArguments(final List<String> newArguments) { | ||
final int previousLambdaArgumentsLength = lambdaArguments.size(); | ||
lambdaArguments.addAll(newArguments); | ||
if (new HashSet<>(lambdaArguments).size() | ||
< previousLambdaArgumentsLength + newArguments.size()) { | ||
throw new KsqlException("Duplicate lambda arguments are not allowed."); | ||
} | ||
} | ||
|
||
public List<String> getLambdaArguments() { | ||
return lambdaArguments; | ||
} | ||
} |
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
Oops, something went wrong.