4545/** A Paimon implementation of {@link LakeCatalog}. */
4646public class PaimonLakeCatalog implements LakeCatalog {
4747
48+ private static final LinkedHashMap <String , DataType > SYSTEM_COLUMNS = new LinkedHashMap <>();
49+
50+ static {
51+ // We need __bucket system column to filter out the given bucket
52+ // for paimon bucket-unaware append only table.
53+ // It's not required for paimon bucket-aware table like primary key table
54+ // and bucket-aware append only table, but we always add the system column
55+ // for consistent behavior
56+ SYSTEM_COLUMNS .put (BUCKET_COLUMN_NAME , DataTypes .INT ());
57+ SYSTEM_COLUMNS .put (OFFSET_COLUMN_NAME , DataTypes .BIGINT ());
58+ SYSTEM_COLUMNS .put (TIMESTAMP_COLUMN_NAME , DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ());
59+ }
60+
4861 private final Catalog paimonCatalog ;
4962
5063 // for fluss config
@@ -127,20 +140,11 @@ private Schema toPaimonSchema(TableDescriptor tableDescriptor) {
127140 options .set (CoreOptions .BUCKET , CoreOptions .BUCKET .defaultValue ());
128141 }
129142
130- Map <String , DataType > systemColumns = new LinkedHashMap <>();
131- if (!tableDescriptor .hasPrimaryKey ()) {
132- // for log table, need to set bucket, offset and timestamp as system metadata columns
133- systemColumns .put (BUCKET_COLUMN_NAME , DataTypes .INT ());
134- systemColumns .put (OFFSET_COLUMN_NAME , DataTypes .BIGINT ());
135- // we use timestamp_ltz type
136- systemColumns .put (TIMESTAMP_COLUMN_NAME , DataTypes .TIMESTAMP_WITH_LOCAL_TIME_ZONE ());
137- }
138-
139143 // set schema
140144 for (com .alibaba .fluss .metadata .Schema .Column column :
141145 tableDescriptor .getSchema ().getColumns ()) {
142146 String columnName = column .getName ();
143- if (systemColumns .containsKey (columnName )) {
147+ if (SYSTEM_COLUMNS .containsKey (columnName )) {
144148 throw new InvalidTableException (
145149 "Column "
146150 + columnName
@@ -153,7 +157,7 @@ private Schema toPaimonSchema(TableDescriptor tableDescriptor) {
153157 }
154158
155159 // add system metadata columns to schema
156- for (Map .Entry <String , DataType > systemColumn : systemColumns .entrySet ()) {
160+ for (Map .Entry <String , DataType > systemColumn : SYSTEM_COLUMNS .entrySet ()) {
157161 schemaBuilder .column (systemColumn .getKey (), systemColumn .getValue ());
158162 }
159163
@@ -186,7 +190,7 @@ private void setFlussPropertyToPaimon(String key, String value, Options options)
186190 }
187191
188192 @ Override
189- public void close () throws Exception {
193+ public void close () {
190194 IOUtils .closeQuietly (paimonCatalog , "paimon catalog" );
191195 }
192196}
0 commit comments