Skip to content

Commit 5961e58

Browse files
committed
fix comments
1 parent 5f838b5 commit 5961e58

File tree

3 files changed

+28
-54
lines changed

3 files changed

+28
-54
lines changed

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/PaimonLakeCatalog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import java.util.List;
4444
import java.util.Map;
4545

46-
import static org.apache.fluss.lake.paimon.utils.FlussToPaimonTableChangeConverter.convert;
46+
import static org.apache.fluss.lake.paimon.utils.PaimonConversions.toPaimonSchemaChanges;
4747
import static org.apache.fluss.metadata.TableDescriptor.BUCKET_COLUMN_NAME;
4848
import static org.apache.fluss.metadata.TableDescriptor.OFFSET_COLUMN_NAME;
4949
import static org.apache.fluss.metadata.TableDescriptor.TIMESTAMP_COLUMN_NAME;
@@ -113,7 +113,7 @@ public void alterTable(TablePath tablePath, List<TableChange> tableChanges)
113113
try {
114114
Identifier paimonPath = toPaimonIdentifier(tablePath);
115115
List<SchemaChange> paimonSchemaChanges =
116-
convert(tableChanges, this::getFlussPropertyKeyToPaimon);
116+
toPaimonSchemaChanges(tableChanges, this::getFlussPropertyKeyToPaimon);
117117
alterTable(paimonPath, paimonSchemaChanges);
118118
} catch (Catalog.ColumnAlreadyExistException | Catalog.ColumnNotExistException e) {
119119
// shouldn't happen before we support schema change

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/utils/FlussToPaimonTableChangeConverter.java

Lines changed: 0 additions & 52 deletions
This file was deleted.

fluss-lake/fluss-lake-paimon/src/main/java/org/apache/fluss/lake/paimon/utils/PaimonConversions.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import org.apache.fluss.lake.paimon.source.FlussRowAsPaimonRow;
2121
import org.apache.fluss.metadata.ResolvedPartitionSpec;
22+
import org.apache.fluss.metadata.TableChange;
2223
import org.apache.fluss.metadata.TablePath;
2324
import org.apache.fluss.record.ChangeType;
2425
import org.apache.fluss.row.GenericRow;
@@ -28,13 +29,16 @@
2829
import org.apache.paimon.data.BinaryRow;
2930
import org.apache.paimon.data.BinaryRowWriter;
3031
import org.apache.paimon.data.BinaryString;
32+
import org.apache.paimon.schema.SchemaChange;
3133
import org.apache.paimon.types.DataType;
3234
import org.apache.paimon.types.RowKind;
3335
import org.apache.paimon.types.RowType;
3436

3537
import javax.annotation.Nullable;
3638

39+
import java.util.ArrayList;
3740
import java.util.List;
41+
import java.util.function.Function;
3842

3943
/** Utils for conversion between Paimon and Fluss. */
4044
public class PaimonConversions {
@@ -106,4 +110,26 @@ public static Object toPaimonLiteral(DataType dataType, Object flussLiteral) {
106110
return org.apache.paimon.data.InternalRow.createFieldGetter(dataType, 0)
107111
.getFieldOrNull(flussRowAsPaimonRow);
108112
}
113+
114+
public static List<SchemaChange> toPaimonSchemaChanges(
115+
List<TableChange> tableChanges, Function<String, String> optionKeyTransformer) {
116+
List<SchemaChange> schemaChanges = new ArrayList<>(tableChanges.size());
117+
118+
for (TableChange tableChange : tableChanges) {
119+
if (tableChange instanceof TableChange.SetOption) {
120+
TableChange.SetOption setOption = (TableChange.SetOption) tableChange;
121+
schemaChanges.add(
122+
SchemaChange.setOption(
123+
optionKeyTransformer.apply(setOption.getKey()), setOption.getValue()));
124+
} else if (tableChange instanceof TableChange.ResetOption) {
125+
TableChange.ResetOption resetOption = (TableChange.ResetOption) tableChange;
126+
schemaChanges.add(SchemaChange.removeOption(optionKeyTransformer.apply(resetOption.getKey())));
127+
} else {
128+
throw new UnsupportedOperationException(
129+
"Unsupported table change: " + tableChange.getClass());
130+
}
131+
}
132+
133+
return schemaChanges;
134+
}
109135
}

0 commit comments

Comments
 (0)