Skip to content

Commit 9013f5a

Browse files
authored
[flink] Supports Flink Materialized Table (#862)
1 parent 6bdf031 commit 9013f5a

File tree

21 files changed

+3787
-29
lines changed

21 files changed

+3787
-29
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.flink.table.catalog;
19+
20+
import org.apache.flink.annotation.PublicEvolving;
21+
import org.apache.flink.table.api.Schema;
22+
import org.apache.flink.table.api.TableSchema;
23+
import org.apache.flink.table.factories.DynamicTableFactory;
24+
25+
import java.util.Map;
26+
import java.util.Optional;
27+
28+
/**
29+
* A common parent that describes the <i>unresolved</i> metadata of a table or view in a catalog.
30+
*
31+
* <p>Copy from Apache Flink, modified the TableKind enum to add MATERIALIZED_TABLE.
32+
*
33+
* @see CatalogTable
34+
* @see CatalogView
35+
*/
36+
@PublicEvolving
37+
public interface CatalogBaseTable {
38+
39+
/** The kind of {@link CatalogBaseTable}. */
40+
@PublicEvolving
41+
enum TableKind {
42+
TABLE,
43+
MATERIALIZED_TABLE,
44+
VIEW
45+
}
46+
47+
/** The kind of table this {@link CatalogBaseTable} describes. */
48+
TableKind getTableKind();
49+
50+
/**
51+
* Returns a map of string-based options.
52+
*
53+
* <p>In case of {@link CatalogTable}, these options may determine the kind of connector and its
54+
* configuration for accessing the data in the external system. See {@link DynamicTableFactory}
55+
* for more information. If a {@link CatalogTable} should not be serializable, an implementation
56+
* can simply throw a runtime exception in this method.
57+
*/
58+
Map<String, String> getOptions();
59+
60+
/**
61+
* @deprecated This method returns the deprecated {@link TableSchema} class. The old class was a
62+
* hybrid of resolved and unresolved schema information. It has been replaced by the new
63+
* {@link Schema} which is always unresolved and will be resolved by the framework later.
64+
*/
65+
@Deprecated
66+
default TableSchema getSchema() {
67+
return null;
68+
}
69+
70+
/**
71+
* Returns the schema of the table or view.
72+
*
73+
* <p>The schema can reference objects from other catalogs and will be resolved and validated by
74+
* the framework when accessing the table or view.
75+
*
76+
* @see ResolvedCatalogTable
77+
* @see ResolvedCatalogView
78+
*/
79+
default Schema getUnresolvedSchema() {
80+
final TableSchema oldSchema = getSchema();
81+
if (oldSchema == null) {
82+
throw new UnsupportedOperationException(
83+
"A CatalogBaseTable must implement getUnresolvedSchema().");
84+
}
85+
return oldSchema.toSchema();
86+
}
87+
88+
/**
89+
* Get comment of the table or view.
90+
*
91+
* @return comment of the table/view.
92+
*/
93+
String getComment();
94+
95+
/**
96+
* Get a deep copy of the CatalogBaseTable instance.
97+
*
98+
* @return a copy of the CatalogBaseTable instance
99+
*/
100+
CatalogBaseTable copy();
101+
102+
/**
103+
* Get a brief description of the table or view.
104+
*
105+
* @return an optional short description of the table/view
106+
*/
107+
Optional<String> getDescription();
108+
109+
/**
110+
* Get a detailed description of the table or view.
111+
*
112+
* @return an optional long description of the table/view
113+
*/
114+
Optional<String> getDetailedDescription();
115+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.flink.table.catalog;
19+
20+
/**
21+
* Dummy placeholder to resolve compatibility issue of CatalogMaterializedTable(introduced in flink
22+
* 1.20).
23+
*/
24+
public interface CatalogMaterializedTable {
25+
26+
/** Dummy LogicalRefreshMode placeholder. */
27+
enum LogicalRefreshMode {}
28+
29+
/** Dummy RefreshMode placeholder. */
30+
enum RefreshMode {}
31+
32+
/** Dummy RefreshStatus placeholder. */
33+
enum RefreshStatus {}
34+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.flink.table.catalog;
19+
20+
/**
21+
* Dummy placeholder to resolve compatibility issue of CatalogMaterializedTable(introduced in flink
22+
* 1.20).
23+
*/
24+
public interface IntervalFreshness {
25+
26+
/** Dummy TimeUnit placeholder. */
27+
enum TimeUnit {}
28+
}

0 commit comments

Comments
 (0)