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-12711][table] Separate function implementation and definition
This closes apache#8661.
- Loading branch information
Showing
32 changed files
with
1,300 additions
and
454 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
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
89 changes: 89 additions & 0 deletions
89
...able-common/src/main/java/org/apache/flink/table/functions/BuiltInFunctionDefinition.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,89 @@ | ||
/* | ||
* 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.functions; | ||
|
||
import org.apache.flink.annotation.Internal; | ||
import org.apache.flink.util.Preconditions; | ||
|
||
/** | ||
* Definition of a built-in function. It enables unique identification across different | ||
* modules by reference equality. | ||
* | ||
* <p>Compared to regular {@link FunctionDefinition}, built-in functions have a default name. | ||
* | ||
* <p>Equality is defined by reference equality. | ||
*/ | ||
@Internal | ||
public final class BuiltInFunctionDefinition implements FunctionDefinition { | ||
|
||
private final String name; | ||
|
||
private final FunctionKind kind; | ||
|
||
private BuiltInFunctionDefinition( | ||
String name, | ||
FunctionKind kind) { | ||
this.name = Preconditions.checkNotNull(name, "Name must not be null."); | ||
this.kind = Preconditions.checkNotNull(kind, "Kind must not be null."); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
@Override | ||
public FunctionKind getKind() { | ||
return kind; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return name; | ||
} | ||
|
||
// -------------------------------------------------------------------------------------------- | ||
|
||
/** | ||
* Builder for fluent definition of built-in functions. | ||
*/ | ||
public static class Builder { | ||
|
||
private String name; | ||
|
||
private FunctionKind kind; | ||
|
||
public Builder() { | ||
// default constructor to allow a fluent definition | ||
} | ||
|
||
public Builder name(String name) { | ||
this.name = name; | ||
return this; | ||
} | ||
|
||
public Builder kind(FunctionKind kind) { | ||
this.kind = kind; | ||
return this; | ||
} | ||
|
||
public BuiltInFunctionDefinition build() { | ||
return new BuiltInFunctionDefinition(name, kind); | ||
} | ||
} | ||
} |
Oops, something went wrong.