Skip to content

Commit ad3b4e1

Browse files
MehulBatrapolyzos
authored andcommitted
[lake/iceberg] Implement IcebergLakeCatalog for PK Tables (apache#1372)
1 parent 0a8b03b commit ad3b4e1

File tree

5 files changed

+642
-4
lines changed

5 files changed

+642
-4
lines changed

fluss-lake/fluss-lake-iceberg/pom.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
<artifactId>iceberg-core</artifactId>
3939
<version>${iceberg.version}</version>
4040
</dependency>
41-
4241
<dependency>
4342
<groupId>com.alibaba.fluss</groupId>
4443
<artifactId>fluss-common</artifactId>
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
/*
2+
* Copyright (c) 2025 Alibaba Group Holding Ltd.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.alibaba.fluss.lake.iceberg;
18+
19+
import com.alibaba.fluss.types.ArrayType;
20+
import com.alibaba.fluss.types.BigIntType;
21+
import com.alibaba.fluss.types.BinaryType;
22+
import com.alibaba.fluss.types.BooleanType;
23+
import com.alibaba.fluss.types.BytesType;
24+
import com.alibaba.fluss.types.CharType;
25+
import com.alibaba.fluss.types.DataTypeVisitor;
26+
import com.alibaba.fluss.types.DateType;
27+
import com.alibaba.fluss.types.DecimalType;
28+
import com.alibaba.fluss.types.DoubleType;
29+
import com.alibaba.fluss.types.FloatType;
30+
import com.alibaba.fluss.types.IntType;
31+
import com.alibaba.fluss.types.LocalZonedTimestampType;
32+
import com.alibaba.fluss.types.MapType;
33+
import com.alibaba.fluss.types.RowType;
34+
import com.alibaba.fluss.types.SmallIntType;
35+
import com.alibaba.fluss.types.StringType;
36+
import com.alibaba.fluss.types.TimeType;
37+
import com.alibaba.fluss.types.TimestampType;
38+
import com.alibaba.fluss.types.TinyIntType;
39+
40+
import org.apache.iceberg.types.Type;
41+
import org.apache.iceberg.types.Types;
42+
43+
/** Convert from Fluss's data type to Iceberg's data type. */
44+
public class FlussDataTypeToIcebergDataType implements DataTypeVisitor<Type> {
45+
46+
public static final FlussDataTypeToIcebergDataType INSTANCE =
47+
new FlussDataTypeToIcebergDataType();
48+
49+
@Override
50+
public Type visit(CharType charType) {
51+
return Types.StringType.get();
52+
}
53+
54+
@Override
55+
public Type visit(StringType stringType) {
56+
return Types.StringType.get();
57+
}
58+
59+
@Override
60+
public Type visit(BooleanType booleanType) {
61+
return Types.BooleanType.get();
62+
}
63+
64+
@Override
65+
public Type visit(BinaryType binaryType) {
66+
return Types.BinaryType.get();
67+
}
68+
69+
@Override
70+
public Type visit(BytesType bytesType) {
71+
return Types.BinaryType.get();
72+
}
73+
74+
@Override
75+
public Type visit(DecimalType decimalType) {
76+
return Types.DecimalType.of(decimalType.getPrecision(), decimalType.getScale());
77+
}
78+
79+
@Override
80+
public Type visit(TinyIntType tinyIntType) {
81+
return Types.IntegerType.get();
82+
}
83+
84+
@Override
85+
public Type visit(SmallIntType smallIntType) {
86+
return Types.IntegerType.get();
87+
}
88+
89+
@Override
90+
public Type visit(IntType intType) {
91+
return Types.IntegerType.get();
92+
}
93+
94+
@Override
95+
public Type visit(BigIntType bigIntType) {
96+
return Types.LongType.get();
97+
}
98+
99+
@Override
100+
public Type visit(FloatType floatType) {
101+
return Types.FloatType.get();
102+
}
103+
104+
@Override
105+
public Type visit(DoubleType doubleType) {
106+
return Types.DoubleType.get();
107+
}
108+
109+
@Override
110+
public Type visit(DateType dateType) {
111+
return Types.DateType.get();
112+
}
113+
114+
@Override
115+
public Type visit(TimeType timeType) {
116+
return Types.TimeType.get();
117+
}
118+
119+
@Override
120+
public Type visit(TimestampType timestampType) {
121+
return Types.TimestampType.withoutZone();
122+
}
123+
124+
@Override
125+
public Type visit(LocalZonedTimestampType localZonedTimestampType) {
126+
return Types.TimestampType.withZone();
127+
}
128+
129+
@Override
130+
public Type visit(ArrayType arrayType) {
131+
throw new UnsupportedOperationException("Unsupported array type");
132+
}
133+
134+
@Override
135+
public Type visit(MapType mapType) {
136+
throw new UnsupportedOperationException("Unsupported map type");
137+
}
138+
139+
@Override
140+
public Type visit(RowType rowType) {
141+
throw new UnsupportedOperationException("Unsupported row type");
142+
}
143+
}

0 commit comments

Comments
 (0)