@loaders.gl/scan 5.0.0-alpha.4 → 5.0.0-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/iceberg.cjs CHANGED
@@ -6829,6 +6829,12 @@ function serializeArrowType(arrowType) {
6829
6829
  type: "list",
6830
6830
  children: [serializeArrowField(listField)]
6831
6831
  };
6832
+ case arrow2.LargeList:
6833
+ const largeListType = arrowType;
6834
+ return {
6835
+ type: "large-list",
6836
+ children: [serializeArrowField(largeListType.valueField)]
6837
+ };
6832
6838
  case arrow2.FixedSizeList:
6833
6839
  const fixedSizeList = arrowType;
6834
6840
  return {
@@ -6842,6 +6848,15 @@ function serializeArrowType(arrowType) {
6842
6848
  type: "struct",
6843
6849
  children: structType.children.map((arrowField) => serializeArrowField(arrowField))
6844
6850
  };
6851
+ case arrow2.SparseUnion:
6852
+ case arrow2.DenseUnion:
6853
+ const unionType = arrowType;
6854
+ return {
6855
+ type: unionType instanceof arrow2.DenseUnion ? "dense-union" : "sparse-union",
6856
+ typeIds: unionType.typeIds,
6857
+ children: unionType.children.map((arrowField) => serializeArrowField(arrowField)),
6858
+ typeIdToChildIndex: { ...unionType.typeIdToChildIndex }
6859
+ };
6845
6860
  case arrow2.Dictionary:
6846
6861
  const dictionaryType = arrowType;
6847
6862
  return {
@@ -6870,6 +6885,10 @@ function deserializeArrowType(dataType, options) {
6870
6885
  const field = deserializeArrowField(dataType.children[0], options);
6871
6886
  return new arrow2.List(field);
6872
6887
  }
6888
+ case "large-list": {
6889
+ const field = deserializeArrowField(dataType.children[0], options);
6890
+ return new arrow2.LargeList(field);
6891
+ }
6873
6892
  case "fixed-size-list": {
6874
6893
  const child = deserializeArrowField(dataType.children[0], options);
6875
6894
  return new arrow2.FixedSizeList(dataType.listSize, child);
@@ -6882,6 +6901,13 @@ function deserializeArrowType(dataType, options) {
6882
6901
  );
6883
6902
  return new arrow2.Struct(children);
6884
6903
  }
6904
+ case "sparse-union":
6905
+ case "dense-union": {
6906
+ const children = dataType.children.map(
6907
+ (arrowField) => deserializeArrowField(arrowField, options)
6908
+ );
6909
+ return dataType.type === "dense-union" ? new arrow2.DenseUnion(dataType.typeIds, children) : new arrow2.SparseUnion(dataType.typeIds, children);
6910
+ }
6885
6911
  case "dictionary": {
6886
6912
  return new arrow2.Dictionary(
6887
6913
  deserializeArrowType(dataType.dictionary, options),
@@ -7519,8 +7545,85 @@ var init_deprecated = __esm({
7519
7545
  }
7520
7546
  });
7521
7547
 
7522
- // ../schema-utils/src/index.ts
7548
+ // ../schema/src/metadata.ts
7549
+ function getMetadataValue(metadata, key) {
7550
+ return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
7551
+ }
7552
+ function setMetadataValue(metadata, key, value) {
7553
+ if (metadata instanceof Map) {
7554
+ metadata.set(key, value);
7555
+ } else {
7556
+ metadata[key] = value;
7557
+ }
7558
+ }
7559
+ function getGeoMetadata(metadata) {
7560
+ if (!metadata) {
7561
+ return null;
7562
+ }
7563
+ const stringifiedGeoMetadata = getMetadataValue(metadata, "geo");
7564
+ const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata(stringifiedGeoMetadata);
7565
+ if (!geoMetadata) {
7566
+ return null;
7567
+ }
7568
+ for (const column of Object.values(geoMetadata.columns || {})) {
7569
+ if (column && typeof column === "object" && typeof column.encoding === "string") {
7570
+ column.encoding = column.encoding.toLowerCase();
7571
+ }
7572
+ }
7573
+ return geoMetadata;
7574
+ }
7575
+ function unpackGeoMetadata(metadata) {
7576
+ const geoMetadata = getGeoMetadata(metadata);
7577
+ if (!geoMetadata) {
7578
+ return;
7579
+ }
7580
+ const { version: version2, primary_column: primaryColumn, columns } = geoMetadata;
7581
+ if (version2) {
7582
+ setMetadataValue(metadata, "geo.version", version2);
7583
+ }
7584
+ if (primaryColumn) {
7585
+ setMetadataValue(metadata, "geo.primary_column", primaryColumn);
7586
+ }
7587
+ setMetadataValue(metadata, "geo.columns", Object.keys(columns || {}).join(","));
7588
+ }
7589
+ function unpackJSONStringMetadata(metadata, metadataKey) {
7590
+ const stringifiedMetadata = getMetadataValue(metadata, metadataKey);
7591
+ const json = stringifiedMetadata && parseJSONStringMetadata(stringifiedMetadata);
7592
+ for (const [key, value] of Object.entries(json || {})) {
7593
+ setMetadataValue(
7594
+ metadata,
7595
+ `${metadataKey}.${key}`,
7596
+ typeof value === "string" ? value : JSON.stringify(value)
7597
+ );
7598
+ }
7599
+ }
7600
+ function parseJSONStringMetadata(stringifiedMetadata) {
7601
+ if (!stringifiedMetadata) {
7602
+ return null;
7603
+ }
7604
+ try {
7605
+ const metadata = JSON.parse(stringifiedMetadata);
7606
+ return metadata && typeof metadata === "object" ? metadata : null;
7607
+ } catch {
7608
+ return null;
7609
+ }
7610
+ }
7611
+ var init_metadata = __esm({
7612
+ "../schema/src/metadata.ts"() {
7613
+ "use strict";
7614
+ }
7615
+ });
7616
+
7617
+ // ../schema/src/index.ts
7523
7618
  var init_src4 = __esm({
7619
+ "../schema/src/index.ts"() {
7620
+ "use strict";
7621
+ init_metadata();
7622
+ }
7623
+ });
7624
+
7625
+ // ../schema-utils/src/index.ts
7626
+ var init_src5 = __esm({
7524
7627
  "../schema-utils/src/index.ts"() {
7525
7628
  "use strict";
7526
7629
  init_convert_arrow_schema();
@@ -8116,35 +8219,26 @@ var init_arrow_table_transport = __esm({
8116
8219
  "../arrow/src/lib/utils/arrow-table-transport.ts"() {
8117
8220
  "use strict";
8118
8221
  arrow7 = __toESM(require("apache-arrow"), 1);
8119
- init_src4();
8222
+ init_src5();
8120
8223
  init_split_arrow_buffers();
8121
8224
  }
8122
8225
  });
8123
8226
 
8124
8227
  // ../gis/src/lib/geoarrow/metadata-utils.ts
8125
- function getMetadataValue(metadata, key) {
8126
- return metadata instanceof Map ? metadata.get(key) || null : metadata[key] || null;
8127
- }
8128
- function setMetadataValue(metadata, key, value) {
8129
- if (metadata instanceof Map) {
8130
- metadata.set(key, value);
8131
- } else {
8132
- metadata[key] = value;
8133
- }
8134
- }
8135
8228
  var init_metadata_utils = __esm({
8136
8229
  "../gis/src/lib/geoarrow/metadata-utils.ts"() {
8137
8230
  "use strict";
8231
+ init_src4();
8138
8232
  }
8139
8233
  });
8140
8234
 
8141
8235
  // ../gis/src/lib/geoarrow/geoparquet-metadata.ts
8142
- function getGeoMetadata(metadata) {
8236
+ function getGeoMetadata2(metadata) {
8143
8237
  if (!metadata) {
8144
8238
  return null;
8145
8239
  }
8146
8240
  const stringifiedGeoMetadata = getMetadataValue(metadata, "geo");
8147
- const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata(stringifiedGeoMetadata);
8241
+ const geoMetadata = stringifiedGeoMetadata && parseJSONStringMetadata2(stringifiedGeoMetadata);
8148
8242
  if (!geoMetadata) {
8149
8243
  return null;
8150
8244
  }
@@ -8155,32 +8249,7 @@ function getGeoMetadata(metadata) {
8155
8249
  }
8156
8250
  return geoMetadata;
8157
8251
  }
8158
- function unpackGeoMetadata(metadata) {
8159
- const geoMetadata = getGeoMetadata(metadata);
8160
- if (!geoMetadata) {
8161
- return;
8162
- }
8163
- const { version: version2, primary_column, columns } = geoMetadata;
8164
- if (version2) {
8165
- setMetadataValue(metadata, "geo.version", version2);
8166
- }
8167
- if (primary_column) {
8168
- setMetadataValue(metadata, "geo.primary_column", primary_column);
8169
- }
8170
- setMetadataValue(metadata, "geo.columns", Object.keys(columns || {}).join(","));
8171
- }
8172
- function unpackJSONStringMetadata(metadata, metadataKey) {
8173
- const stringifiedMetadata = getMetadataValue(metadata, metadataKey);
8174
- const json = stringifiedMetadata && parseJSONStringMetadata(stringifiedMetadata);
8175
- for (const [key, value] of Object.entries(json || {})) {
8176
- setMetadataValue(
8177
- metadata,
8178
- `${metadataKey}.${key}`,
8179
- typeof value === "string" ? value : JSON.stringify(value)
8180
- );
8181
- }
8182
- }
8183
- function parseJSONStringMetadata(stringifiedMetadata) {
8252
+ function parseJSONStringMetadata2(stringifiedMetadata) {
8184
8253
  if (!stringifiedMetadata) {
8185
8254
  return null;
8186
8255
  }
@@ -8202,16 +8271,15 @@ var init_geoparquet_metadata = __esm({
8202
8271
  });
8203
8272
 
8204
8273
  // ../gis/src/index.ts
8205
- var init_src5 = __esm({
8274
+ var init_src6 = __esm({
8206
8275
  "../gis/src/index.ts"() {
8207
8276
  "use strict";
8208
- init_metadata_utils();
8209
8277
  init_geoparquet_metadata();
8210
8278
  }
8211
8279
  });
8212
8280
 
8213
8281
  // ../arrow/src/index.ts
8214
- var init_src6 = __esm({
8282
+ var init_src7 = __esm({
8215
8283
  "../arrow/src/index.ts"() {
8216
8284
  "use strict";
8217
8285
  init_indexed_arrow_table();
@@ -8455,10 +8523,11 @@ function getGeoArrowMetadataFromGeoParquetField(field, columnMetadata) {
8455
8523
  if (!extensionName) {
8456
8524
  return null;
8457
8525
  }
8458
- if (normalizedEncoding === "wkb" && field.type !== "binary") {
8526
+ const isBinaryGeospatialEncoding = normalizedEncoding === "wkb" || normalizedEncoding === "geometry" || normalizedEncoding === "geography";
8527
+ if (isBinaryGeospatialEncoding && !isBinaryFieldType(field.type)) {
8459
8528
  return null;
8460
8529
  }
8461
- if (normalizedEncoding !== "wkb" && (field.type === "binary" || field.type === "utf8")) {
8530
+ if (!isBinaryGeospatialEncoding && (isBinaryFieldType(field.type) || isStringFieldType(field.type))) {
8462
8531
  return null;
8463
8532
  }
8464
8533
  const extensionMetadata = {};
@@ -8472,18 +8541,34 @@ function getGeoArrowMetadataFromGeoParquetField(field, columnMetadata) {
8472
8541
  if (columnMetadata.edges && columnMetadata.edges !== "planar") {
8473
8542
  extensionMetadata.edges = columnMetadata.edges;
8474
8543
  }
8544
+ if (normalizedEncoding === "geography" && !extensionMetadata.edges) {
8545
+ extensionMetadata.edges = "spherical";
8546
+ }
8547
+ for (const [metadataKey, metadataValue] of Object.entries(columnMetadata)) {
8548
+ if (metadataValue !== void 0 && metadataValue !== null && !["encoding", "geometry_types", "crs", "edges"].includes(metadataKey)) {
8549
+ extensionMetadata[metadataKey] = metadataValue;
8550
+ }
8551
+ }
8475
8552
  return Object.keys(extensionMetadata).length > 0 ? { extensionName, extensionMetadata } : { extensionName };
8476
8553
  }
8554
+ function isBinaryFieldType(fieldType) {
8555
+ return typeof fieldType === "string" && (fieldType === "binary" || fieldType === "binary-view");
8556
+ }
8557
+ function isStringFieldType(fieldType) {
8558
+ return typeof fieldType === "string" && (fieldType === "utf8" || fieldType === "utf8-view");
8559
+ }
8477
8560
  var arrow8, GEOARROW_EXTENSION_NAME_KEY, GEOARROW_EXTENSION_METADATA_KEY, GEOPARQUET_TO_GEOARROW_ENCODINGS;
8478
8561
  var init_geospatial_metadata = __esm({
8479
8562
  "../parquet/src/lib/geo/geospatial-metadata.ts"() {
8480
8563
  "use strict";
8481
8564
  arrow8 = __toESM(require("apache-arrow"), 1);
8482
- init_src5();
8565
+ init_src4();
8483
8566
  GEOARROW_EXTENSION_NAME_KEY = "ARROW:extension:name";
8484
8567
  GEOARROW_EXTENSION_METADATA_KEY = "ARROW:extension:metadata";
8485
8568
  GEOPARQUET_TO_GEOARROW_ENCODINGS = {
8486
8569
  wkb: "geoarrow.wkb",
8570
+ geometry: "geoarrow.wkb",
8571
+ geography: "geoarrow.wkb",
8487
8572
  point: "geoarrow.point",
8488
8573
  linestring: "geoarrow.linestring",
8489
8574
  polygon: "geoarrow.polygon",
@@ -8509,7 +8594,7 @@ async function getSchemaFromParquetReader(reader) {
8509
8594
  var init_get_parquet_schema = __esm({
8510
8595
  "../parquet/src/lib/parsers/get-parquet-schema.ts"() {
8511
8596
  "use strict";
8512
- init_src5();
8597
+ init_src4();
8513
8598
  init_convert_schema_from_parquet();
8514
8599
  init_geospatial_metadata();
8515
8600
  }
@@ -8621,7 +8706,7 @@ function doLongitudeIntervalsIntersect(firstWest, firstEast, secondWest, secondE
8621
8706
  var init_geoparquet_covering = __esm({
8622
8707
  "../parquet/src/lib/geo/geoparquet-covering.ts"() {
8623
8708
  "use strict";
8624
- init_src5();
8709
+ init_src4();
8625
8710
  }
8626
8711
  });
8627
8712
 
@@ -15345,7 +15430,7 @@ var init_parse_bson = __esm({
15345
15430
  });
15346
15431
 
15347
15432
  // ../bson/src/index.ts
15348
- var init_src7 = __esm({
15433
+ var init_src8 = __esm({
15349
15434
  "../bson/src/index.ts"() {
15350
15435
  "use strict";
15351
15436
  init_bson_writer();
@@ -15754,7 +15839,7 @@ var PARQUET_LOGICAL_TYPES, kMillisPerDay;
15754
15839
  var init_types = __esm({
15755
15840
  "../parquet/src/parquetjs/schema/types.ts"() {
15756
15841
  "use strict";
15757
- init_src7();
15842
+ init_src8();
15758
15843
  init_binary_utils();
15759
15844
  PARQUET_LOGICAL_TYPES = {
15760
15845
  BOOLEAN: {
@@ -23175,10 +23260,10 @@ var _preloadParquetSourceLoader, _createMetadataDataSource, ParquetSourceLoaderB
23175
23260
  var init_parquet_source_loader = __esm({
23176
23261
  "../parquet/src/parquet-source-loader.ts"() {
23177
23262
  "use strict";
23178
- init_src6();
23263
+ init_src7();
23179
23264
  init_src2();
23180
- init_src4();
23181
23265
  init_src5();
23266
+ init_src6();
23182
23267
  init_get_parquet_schema();
23183
23268
  init_geoparquet_covering();
23184
23269
  init_parquet_bloom_filter();
@@ -23361,7 +23446,7 @@ var init_parquet_source_loader = __esm({
23361
23446
  );
23362
23447
  const projectedColumns = normalizeColumns(readOptions.columns, initialization.schema);
23363
23448
  const predicateColumns = physicalPlan.predicate ? getParquetPredicateColumns(physicalPlan.predicate) : [];
23364
- const geoMetadata = readOptions.bbox ? getGeoMetadata(initialization.schema.metadata) : void 0;
23449
+ const geoMetadata = readOptions.bbox ? getGeoMetadata2(initialization.schema.metadata) : void 0;
23365
23450
  const geometryColumn = readOptions.bbox ? readOptions.geometryColumn || (geoMetadata == null ? void 0 : geoMetadata.primary_column) : void 0;
23366
23451
  const filterColumns = [
23367
23452
  .../* @__PURE__ */ new Set([...predicateColumns, ...geometryColumn ? [geometryColumn] : []])