Skip to content

Commit 8dfc0fe

Browse files
committed
fix(test): Register extensions in tests
1 parent a08dbac commit 8dfc0fe

File tree

2 files changed

+10
-19
lines changed

2 files changed

+10
-19
lines changed

lib/src/main/java/io/cloudquery/helper/ArrowHelper.java

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -264,30 +264,12 @@ private static Column getColumn(Field field) {
264264
boolean isIncrementalKey =
265265
Objects.equals(field.getMetadata().get(CQ_EXTENSION_INCREMENTAL), "true");
266266

267-
ArrowType fieldType = field.getType();
268-
String extensionName =
269-
field.getMetadata().get(ArrowType.ExtensionType.EXTENSION_METADATA_KEY_NAME);
270-
String extensionMetadata =
271-
field.getMetadata().get(ArrowType.ExtensionType.EXTENSION_METADATA_KEY_METADATA);
272-
273-
// We need to scan our extension types manually because of
274-
// https://github.com/apache/arrow/issues/38891
275-
if (JSONType.EXTENSION_NAME.equals(extensionName)
276-
&& JSONType.INSTANCE.serialize().equals(extensionMetadata)
277-
&& JSONType.INSTANCE.storageType().equals(fieldType)) {
278-
fieldType = JSONType.INSTANCE;
279-
} else if (UUIDType.EXTENSION_NAME.equals(extensionName)
280-
&& UUIDType.INSTANCE.serialize().equals(extensionMetadata)
281-
&& UUIDType.INSTANCE.storageType().equals(fieldType)) {
282-
fieldType = UUIDType.INSTANCE;
283-
}
284-
285267
return Column.builder()
286268
.name(field.getName())
287269
.unique(isUnique)
288270
.primaryKey(isPrimaryKey)
289271
.incrementalKey(isIncrementalKey)
290-
.type(fieldType)
272+
.type(field.getType())
291273
.build();
292274
}
293275

lib/src/test/java/io/cloudquery/helper/ArrowHelperTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import io.cloudquery.schema.Column;
88
import io.cloudquery.schema.Resource;
99
import io.cloudquery.schema.Table;
10+
import io.cloudquery.types.Extensions;
1011
import io.cloudquery.types.JSONType;
1112
import io.cloudquery.types.UUIDType;
1213
import java.io.IOException;
@@ -128,6 +129,8 @@ public class ArrowHelperTest {
128129

129130
@Test
130131
public void testToArrowSchema() {
132+
Extensions.registerExtensions();
133+
131134
Schema arrowSchema = ArrowHelper.toArrowSchema(TEST_TABLE);
132135

133136
for (Column col : TEST_TABLE.getColumns()) {
@@ -197,6 +200,8 @@ public void testToArrowSchema() {
197200

198201
@Test
199202
public void testFromArrowSchema() {
203+
Extensions.registerExtensions();
204+
200205
List<Field> fields =
201206
List.of(
202207
Field.nullable("string_column1", ArrowType.Utf8.INSTANCE),
@@ -218,6 +223,8 @@ public void testFromArrowSchema() {
218223

219224
@Test
220225
public void testRoundTripTableEncoding() throws IOException {
226+
Extensions.registerExtensions();
227+
221228
ByteString byteString = ArrowHelper.encode(TEST_TABLE);
222229
Table table = ArrowHelper.decode(byteString);
223230

@@ -237,6 +244,8 @@ public void testRoundTripTableEncoding() throws IOException {
237244

238245
@Test
239246
public void testRoundTripResourceEncoding() throws Exception {
247+
Extensions.registerExtensions();
248+
240249
Resource resource = Resource.builder().table(TEST_TABLE).build();
241250
resource.set("pk", "test_pk");
242251
resource.set("big_int", -1024L);

0 commit comments

Comments
 (0)