forked from apache/flink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FLINK-36789][table-common] Update FunctionHint and ArgumentHint with…
… traits
- Loading branch information
Showing
14 changed files
with
395 additions
and
167 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
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
95 changes: 95 additions & 0 deletions
95
...ble/flink-table-common/src/main/java/org/apache/flink/table/annotation/ArgumentTrait.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,95 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.flink.table.annotation; | ||
|
||
import org.apache.flink.annotation.PublicEvolving; | ||
import org.apache.flink.table.types.inference.StaticArgumentTrait; | ||
|
||
import java.util.Arrays; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* Declares traits for {@link ArgumentHint}. They enable basic validation by the framework. | ||
* | ||
* <p>Some traits have dependencies to other traits, which is why this enum reflects a hierarchy in | ||
* which {@link #SCALAR}, {@link #TABLE_AS_ROW}, and {@link #TABLE_AS_SET} are the top-level roots. | ||
*/ | ||
@PublicEvolving | ||
public enum ArgumentTrait { | ||
|
||
/** | ||
* An argument that accepts a scalar value. For example: f(1), f(true), f('Some string'). | ||
* | ||
* <p>It's the default if no {@link ArgumentHint} is provided. | ||
*/ | ||
SCALAR(StaticArgumentTrait.SCALAR), | ||
|
||
/** | ||
* An argument that accepts a table "as row" (i.e. with row semantics). This trait only applies | ||
* to {@code ProcessTableFunction} (PTF). | ||
* | ||
* <p>For scalability, input tables are distributed into virtual processors. Each virtual | ||
* processor executes a PTF instance and has access only to a share of the entire table. The | ||
* argument declaration decides about the size of the share and co-location of data. | ||
* | ||
* <p>A table with row semantics assumes that there is no correlation between rows and each row | ||
* can be processed independently. The framework is free in how to distribute rows among virtual | ||
* processors and each virtual processor has access only to the currently processed row. | ||
*/ | ||
TABLE_AS_ROW(StaticArgumentTrait.TABLE_AS_ROW), | ||
|
||
/** | ||
* An argument that accepts a table "as set" (i.e. with set semantics). This trait only applies | ||
* to {@code ProcessTableFunction} (PTF). | ||
* | ||
* <p>For scalability, input tables are distributed into virtual processors. Each virtual | ||
* processor executes a PTF instance and has access only to a share of the entire table. The | ||
* argument declaration decides about the size of the share and co-location of data. | ||
* | ||
* <p>A table with set semantics assumes that there is a correlation between rows. When calling | ||
* the function, the PARTITION BY clause defines the columns for correlation. The framework | ||
* ensures that all rows belonging to same set are co-located. A PTF instance is able to access | ||
* all rows belonging to the same set. In other words: The virtual processor is scoped under a | ||
* key context. | ||
*/ | ||
TABLE_AS_SET(StaticArgumentTrait.TABLE_AS_SET), | ||
|
||
/** | ||
* Defines that a PARTITION BY clause is optional for {@link #TABLE_AS_SET}. By default, it is | ||
* mandatory for improving the parallel execution by distributing the table by key. | ||
*/ | ||
OPTIONAL_PARTITION_BY(StaticArgumentTrait.OPTIONAL_PARTITION_BY, TABLE_AS_SET); | ||
|
||
private final StaticArgumentTrait staticTrait; | ||
private final Set<ArgumentTrait> requirements; | ||
|
||
ArgumentTrait(StaticArgumentTrait staticTrait, ArgumentTrait... requirements) { | ||
this.staticTrait = staticTrait; | ||
this.requirements = Arrays.stream(requirements).collect(Collectors.toSet()); | ||
} | ||
|
||
public Set<ArgumentTrait> getRequirements() { | ||
return requirements; | ||
} | ||
|
||
public StaticArgumentTrait toStaticTrait() { | ||
return staticTrait; | ||
} | ||
} |
Oops, something went wrong.