Skip to content

Commit efbe636

Browse files
committed
add required filed to cieberg datatypes classes
1 parent f074436 commit efbe636

File tree

2 files changed

+47
-5
lines changed

2 files changed

+47
-5
lines changed

iceberg/tests/iceberg_engine/check_datatypes.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@
1313

1414

1515
ALL_DATATYPES = [
16-
IcebergIntegerType(),
17-
IcebergLongType(),
18-
IcebergDoubleType(),
19-
IcebergFloatType(),
20-
IcebergBooleanType(),
16+
IcebergIntegerType(required=True),
17+
IcebergLongType(required=True),
18+
IcebergDoubleType(required=True),
19+
IcebergFloatType(required=True),
20+
IcebergBooleanType(required=True),
2121
IcebergTimestampType(),
2222
IcebergTimestamptzType(),
2323
IcebergDateType(),

iceberg/tests/steps/datatypes.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class IcebergIntegerType(BaseIcebergTypeTest):
3535
iceberg_type = IntegerType()
3636
arrow_type = pa.int32()
3737

38+
def __init__(self, required=False):
39+
self.required = required
40+
3841
def generate(self):
3942
return random.randint(0, 10000)
4043

@@ -44,6 +47,9 @@ class IcebergLongType(BaseIcebergTypeTest):
4447
iceberg_type = LongType()
4548
arrow_type = pa.int64()
4649

50+
def __init__(self, required=False):
51+
self.required = required
52+
4753
def generate(self):
4854
return random.randint(0, 10000)
4955

@@ -53,6 +59,9 @@ class IcebergDoubleType(BaseIcebergTypeTest):
5359
iceberg_type = DoubleType()
5460
arrow_type = pa.float64()
5561

62+
def __init__(self, required=False):
63+
self.required = required
64+
5665
def generate(self):
5766
return random.uniform(0, 100)
5867

@@ -62,6 +71,9 @@ class IcebergFloatType(BaseIcebergTypeTest):
6271
iceberg_type = FloatType()
6372
arrow_type = pa.float32()
6473

74+
def __init__(self, required=False):
75+
self.required = required
76+
6577
def generate(self):
6678
return random.uniform(0, 100)
6779

@@ -71,6 +83,9 @@ class IcebergBooleanType(BaseIcebergTypeTest):
7183
iceberg_type = BooleanType()
7284
arrow_type = pa.bool_()
7385

86+
def __init__(self, required=False):
87+
self.required = required
88+
7489
def generate(self):
7590
return random.choice([True, False])
7691

@@ -80,6 +95,9 @@ class IcebergTimestampType(BaseIcebergTypeTest):
8095
iceberg_type = TimestampType()
8196
arrow_type = pa.timestamp("us")
8297

98+
def __init__(self, required=False):
99+
self.required = required
100+
83101
def generate(self):
84102
return random.randint(0, 100000000)
85103

@@ -94,6 +112,9 @@ class IcebergTimestamptzType(BaseIcebergTypeTest):
94112
iceberg_type = TimestamptzType()
95113
arrow_type = pa.timestamp("us", tz="UTC")
96114

115+
def __init__(self, required=False):
116+
self.required = required
117+
97118
def generate(self):
98119
return random.randint(0, 10000)
99120

@@ -107,6 +128,9 @@ class IcebergDateType(BaseIcebergTypeTest):
107128
iceberg_type = DateType()
108129
arrow_type = pa.date32()
109130

131+
def __init__(self, required=False):
132+
self.required = required
133+
110134
def generate(self):
111135
return random.randint(0, 10000)
112136

@@ -120,6 +144,9 @@ class IcebergStringType(BaseIcebergTypeTest):
120144
iceberg_type = StringType()
121145
arrow_type = pa.string()
122146

147+
def __init__(self, required=False):
148+
self.required = required
149+
123150
def generate(self):
124151
return random.choice(["test", "test2", "test3"])
125152

@@ -133,6 +160,9 @@ class IcebergFixedStringType(BaseIcebergTypeTest):
133160
iceberg_type = FixedType(length=10)
134161
arrow_type = pa.binary(10)
135162

163+
def __init__(self, required=False):
164+
self.required = required
165+
136166
def generate(self):
137167
# Generate exactly 10 bytes for fixed-length binary
138168
return bytes([i % 256 for i in range(10)])
@@ -148,6 +178,9 @@ class IcebergUUIDType(BaseIcebergTypeTest):
148178
iceberg_type = UUIDType()
149179
arrow_type = pa.binary(16)
150180

181+
def __init__(self, required=False):
182+
self.required = required
183+
151184
def generate(self):
152185
return uuid.uuid4().bytes
153186

@@ -162,6 +195,9 @@ class IcebergBinaryType(BaseIcebergTypeTest):
162195
iceberg_type = BinaryType()
163196
arrow_type = pa.binary()
164197

198+
def __init__(self, required=False):
199+
self.required = required
200+
165201
def generate(self):
166202
return random.choice(["test", "test2", "test3"])
167203

@@ -175,6 +211,9 @@ class IcebergDecimalType(BaseIcebergTypeTest):
175211
iceberg_type = DecimalType(38, 18)
176212
arrow_type = pa.decimal128(38, 18)
177213

214+
def __init__(self, required=False):
215+
self.required = required
216+
178217
def generate(self):
179218
return Decimal(random.randint(0, 10000)) / Decimal(100)
180219

@@ -184,6 +223,9 @@ class IcebergTimeType(BaseIcebergTypeTest):
184223
iceberg_type = TimeType()
185224
arrow_type = pa.time64("us")
186225

226+
def __init__(self, required=False):
227+
self.required = required
228+
187229
def generate(self):
188230
return random.randint(0, 100000000)
189231

0 commit comments

Comments
 (0)