@loaders.gl/core 5.0.0-beta.6 → 5.0.0-beta.8
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/arrow-geometry/geojson-table.cjs +26 -15
- package/dist/arrow-geometry/geojson-table.cjs.map +2 -2
- package/dist/arrow-geometry/geojson-table.d.ts +8 -1
- package/dist/arrow-geometry/geojson-table.d.ts.map +1 -1
- package/dist/arrow-geometry/geojson-table.js +18 -9
- package/dist/arrow-geometry/geojson-table.js.map +1 -1
- package/dist/cluster-source.cjs +78 -8
- package/dist/cluster-source.cjs.map +3 -3
- package/dist/dist.dev.js +354 -319
- package/dist/dist.min.js +3 -3
- package/dist/federated-table-scan-source.cjs +187 -179
- package/dist/federated-table-scan-source.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.cjs.map +2 -2
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.d.ts.map +1 -1
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js +4 -8
- package/dist/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.js.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.cjs.map +2 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.d.ts.map +1 -1
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js +3 -2
- package/dist/geoarrow/mesharrow/arrow-fixed-size-list-utils.js.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs +44 -2
- package/dist/geoarrow/metadata/geoarrow-metadata.cjs.map +4 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.d.ts.map +1 -1
- package/dist/geoarrow/metadata/geoarrow-metadata.js +3 -4
- package/dist/geoarrow/metadata/geoarrow-metadata.js.map +1 -1
- package/dist/index.cjs +351 -281
- package/dist/index.cjs.map +3 -3
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/api/create-data-source.d.ts +14 -9
- package/dist/lib/api/create-data-source.d.ts.map +1 -1
- package/dist/lib/api/create-data-source.js +55 -45
- package/dist/lib/api/create-data-source.js.map +1 -1
- package/dist/lib/api/encode.d.ts +1 -1
- package/dist/lib/api/encode.d.ts.map +1 -1
- package/dist/lib/api/encode.js +11 -2
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/load-in-batches.d.ts +3 -2
- package/dist/lib/api/load-in-batches.d.ts.map +1 -1
- package/dist/lib/api/load-in-batches.js.map +1 -1
- package/dist/lib/api/load-loader.d.ts +3 -3
- package/dist/lib/api/load-loader.d.ts.map +1 -1
- package/dist/lib/api/load-loader.js +14 -18
- package/dist/lib/api/load-loader.js.map +1 -1
- package/dist/lib/api/load.d.ts +7 -3
- package/dist/lib/api/load.d.ts.map +1 -1
- package/dist/lib/api/load.js +11 -64
- package/dist/lib/api/load.js.map +1 -1
- package/dist/lib/api/parse-file.d.ts +5 -3
- package/dist/lib/api/parse-file.d.ts.map +1 -1
- package/dist/lib/api/parse-file.js +12 -7
- package/dist/lib/api/parse-file.js.map +1 -1
- package/dist/lib/api/parse-in-batches.d.ts +5 -3
- package/dist/lib/api/parse-in-batches.d.ts.map +1 -1
- package/dist/lib/api/parse-in-batches.js +14 -3
- package/dist/lib/api/parse-in-batches.js.map +1 -1
- package/dist/lib/api/parse-sync.d.ts +5 -3
- package/dist/lib/api/parse-sync.d.ts.map +1 -1
- package/dist/lib/api/parse-sync.js +8 -6
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.d.ts +5 -3
- package/dist/lib/api/parse.d.ts.map +1 -1
- package/dist/lib/api/parse.js +26 -15
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/select-loader.d.ts +4 -2
- package/dist/lib/api/select-loader.d.ts.map +1 -1
- package/dist/lib/api/select-loader.js +43 -40
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/api/select-source.d.ts.map +1 -1
- package/dist/lib/api/select-source.js +1 -1
- package/dist/lib/api/select-source.js.map +1 -1
- package/dist/lib/init.js +1 -1
- package/dist/lib/loader-utils/loggers.d.ts +2 -37
- package/dist/lib/loader-utils/loggers.d.ts.map +1 -1
- package/dist/lib/loader-utils/loggers.js +2 -63
- package/dist/lib/loader-utils/loggers.js.map +1 -1
- package/dist/lib/loader-utils/native-arrow.d.ts +11 -0
- package/dist/lib/loader-utils/native-arrow.d.ts.map +1 -0
- package/dist/lib/loader-utils/native-arrow.js +52 -0
- package/dist/lib/loader-utils/native-arrow.js.map +1 -0
- package/dist/lib/loader-utils/option-defaults.js +2 -2
- package/dist/lib/loader-utils/option-defaults.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.d.ts.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +21 -10
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/loader-utils/index.cjs +143 -42
- package/dist/loader-utils/index.cjs.map +3 -3
- package/dist/loader-utils/index.d.ts +2 -2
- package/dist/loader-utils/index.d.ts.map +1 -1
- package/dist/loader-utils/index.js +1 -1
- package/dist/loader-utils/index.js.map +1 -1
- package/dist/loader-utils/json-loader.js +1 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts +24 -1
- package/dist/loader-utils/lib/log-utils/log.d.ts.map +1 -1
- package/dist/loader-utils/lib/log-utils/log.js +32 -1
- package/dist/loader-utils/lib/log-utils/log.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts +5 -0
- package/dist/loader-utils/lib/scan-utils/logical-table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js +13 -5
- package/dist/loader-utils/lib/scan-utils/logical-table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts +5 -1
- package/dist/loader-utils/lib/scan-utils/table-query.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-query.js +6 -0
- package/dist/loader-utils/lib/scan-utils/table-query.js.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts +6 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.d.ts.map +1 -1
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js +27 -20
- package/dist/loader-utils/lib/scan-utils/table-scan-batch.js.map +1 -1
- package/dist/loader-utils/lib/sources/data-source.js +3 -3
- package/dist/loader-utils/lib/sources/data-source.js.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.d.ts.map +1 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js +15 -1
- package/dist/loader-utils/lib/worker-loader-utils/parse-with-worker.js.map +1 -1
- package/dist/loader-utils/loader-types.d.ts +102 -27
- package/dist/loader-utils/loader-types.d.ts.map +1 -1
- package/dist/loader-utils/loader-types.js.map +1 -1
- package/dist/loader-utils/source-types.d.ts +5 -5
- package/dist/loader-utils/source-types.d.ts.map +1 -1
- package/dist/loader-utils/source-types.js +5 -1
- package/dist/loader-utils/source-types.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker-node.js +1 -1
- package/dist/null-worker.js +1 -1
- package/dist/polyfills/index.cjs +3 -2
- package/dist/polyfills/index.d.ts.map +1 -1
- package/dist/polyfills/index.js +2 -2
- package/dist/polyfills/index.js.map +1 -1
- package/dist/scan/arrow-execution/expressions.cjs +110 -0
- package/dist/scan/arrow-execution/expressions.cjs.map +7 -0
- package/dist/scan/arrow-execution/expressions.d.ts +9 -0
- package/dist/scan/arrow-execution/expressions.d.ts.map +1 -0
- package/dist/scan/arrow-execution/expressions.js +60 -0
- package/dist/scan/arrow-execution/expressions.js.map +1 -0
- package/dist/scan/arrow-execution/filter-arrow-table.cjs +15 -3
- package/dist/scan/arrow-execution/filter-arrow-table.cjs.map +2 -2
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts +2 -0
- package/dist/scan/arrow-execution/filter-arrow-table.d.ts.map +1 -1
- package/dist/scan/arrow-execution/filter-arrow-table.js +10 -2
- package/dist/scan/arrow-execution/filter-arrow-table.js.map +1 -1
- package/dist/scan/index.cjs +21 -6
- package/dist/scan/index.cjs.map +2 -2
- package/dist/scan/index.d.ts +2 -1
- package/dist/scan/index.d.ts.map +1 -1
- package/dist/scan/index.js +1 -1
- package/dist/scan/index.js.map +1 -1
- package/dist/scan/parse-sql-predicate.cjs +3 -294
- package/dist/scan/parse-sql-predicate.cjs.map +3 -3
- package/dist/scan/parse-sql-predicate.d.ts +1 -7
- package/dist/scan/parse-sql-predicate.d.ts.map +1 -1
- package/dist/scan/parse-sql-predicate.js +5 -307
- package/dist/scan/parse-sql-predicate.js.map +1 -1
- package/dist/scan/query-progressive.cjs +191 -0
- package/dist/scan/query-progressive.cjs.map +7 -0
- package/dist/scan/query-progressive.d.ts +39 -0
- package/dist/scan/query-progressive.d.ts.map +1 -0
- package/dist/scan/query-progressive.js +174 -0
- package/dist/scan/query-progressive.js.map +1 -0
- package/dist/scan/query.cjs +143 -22
- package/dist/scan/query.cjs.map +3 -3
- package/dist/scan/query.d.ts +27 -9
- package/dist/scan/query.d.ts.map +1 -1
- package/dist/scan/query.js +180 -18
- package/dist/scan/query.js.map +1 -1
- package/dist/schema-utils/index.cjs +262 -241
- package/dist/schema-utils/index.cjs.map +2 -2
- package/dist/schema-utils/index.d.ts +1 -0
- package/dist/schema-utils/index.d.ts.map +1 -1
- package/dist/schema-utils/index.js +1 -0
- package/dist/schema-utils/index.js.map +1 -1
- package/dist/schema-utils/lib/schema/deduce-table-schema.js +4 -2
- package/dist/schema-utils/lib/schema/deduce-table-schema.js.map +1 -1
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts +28 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.d.ts.map +1 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js +26 -0
- package/dist/schema-utils/lib/table/tables/convert-arrow-table-wrapper.js.map +1 -0
- package/dist/schema-utils/lib/table/tables/row-utils.js +2 -2
- package/dist/schema-utils/lib/table/tables/row-utils.js.map +1 -1
- package/dist/vector-table-scan-source.cjs +12 -4
- package/dist/vector-table-scan-source.cjs.map +1 -1
- package/dist/worker-utils/index.cjs +49 -9
- package/dist/worker-utils/index.cjs.map +3 -3
- package/dist/worker-utils/lib/env-utils/version.js +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.d.ts.map +1 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js +2 -1
- package/dist/worker-utils/lib/library-utils/library-utils.js.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.d.ts.map +1 -1
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js +8 -7
- package/dist/worker-utils/lib/process-utils/child-process-proxy.js.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.d.ts.map +1 -1
- package/dist/worker-utils/lib/worker-api/get-worker-url.js +5 -2
- package/dist/worker-utils/lib/worker-api/get-worker-url.js.map +1 -1
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js +1 -6
- package/dist/worker-utils/lib/worker-utils/get-loadable-worker-url.js.map +1 -1
- package/package.json +8 -7
- package/src/arrow-geometry/geojson-table.ts +27 -17
- package/src/geoarrow/lib/feature-collection-converters/convert-geometry-column-to-binary-feature-collection.ts +4 -11
- package/src/geoarrow/mesharrow/arrow-fixed-size-list-utils.ts +3 -2
- package/src/geoarrow/metadata/geoarrow-metadata.ts +3 -4
- package/src/index.ts +1 -1
- package/src/lib/api/create-data-source.ts +136 -58
- package/src/lib/api/encode.ts +14 -3
- package/src/lib/api/load-in-batches.ts +15 -7
- package/src/lib/api/load-loader.ts +21 -20
- package/src/lib/api/load.ts +49 -121
- package/src/lib/api/parse-file.ts +42 -23
- package/src/lib/api/parse-in-batches.ts +49 -12
- package/src/lib/api/parse-sync.ts +37 -19
- package/src/lib/api/parse.ts +51 -30
- package/src/lib/api/select-loader.ts +56 -53
- package/src/lib/api/select-source.ts +7 -1
- package/src/lib/loader-utils/loggers.ts +2 -70
- package/src/lib/loader-utils/native-arrow.ts +70 -0
- package/src/lib/loader-utils/option-defaults.ts +2 -2
- package/src/lib/loader-utils/option-utils.ts +21 -10
- package/src/loader-utils/index.ts +2 -1
- package/src/loader-utils/lib/log-utils/log.ts +39 -1
- package/src/loader-utils/lib/scan-utils/logical-table-query.ts +18 -8
- package/src/loader-utils/lib/scan-utils/table-query.ts +10 -1
- package/src/loader-utils/lib/scan-utils/table-scan-batch.ts +36 -25
- package/src/loader-utils/lib/sources/data-source.ts +3 -3
- package/src/loader-utils/lib/worker-loader-utils/parse-with-worker.ts +16 -1
- package/src/loader-utils/loader-types.ts +168 -43
- package/src/loader-utils/source-types.ts +12 -6
- package/src/polyfills/index.ts +3 -3
- package/src/scan/arrow-execution/expressions.ts +86 -0
- package/src/scan/arrow-execution/filter-arrow-table.ts +19 -3
- package/src/scan/index.ts +7 -1
- package/src/scan/parse-sql-predicate.ts +8 -367
- package/src/scan/query-progressive.ts +231 -0
- package/src/scan/query.ts +247 -24
- package/src/schema-utils/index.ts +5 -0
- package/src/schema-utils/lib/schema/deduce-table-schema.ts +4 -2
- package/src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts +58 -0
- package/src/schema-utils/lib/table/tables/row-utils.ts +2 -2
- package/src/worker-utils/lib/library-utils/library-utils.ts +2 -1
- package/src/worker-utils/lib/process-utils/child-process-proxy.ts +8 -7
- package/src/worker-utils/lib/worker-api/get-worker-url.ts +4 -3
- package/src/worker-utils/lib/worker-utils/get-loadable-worker-url.ts +1 -6
- package/dist/scan/parse-sql-query.cjs +0 -70
- package/dist/scan/parse-sql-query.cjs.map +0 -7
- package/dist/scan/parse-sql-query.d.ts +0 -5
- package/dist/scan/parse-sql-query.d.ts.map +0 -1
- package/dist/scan/parse-sql-query.js +0 -49
- package/dist/scan/parse-sql-query.js.map +0 -1
- package/dist/scan/parse-sql-select.cjs +0 -215
- package/dist/scan/parse-sql-select.cjs.map +0 -7
- package/dist/scan/parse-sql-select.d.ts +0 -38
- package/dist/scan/parse-sql-select.d.ts.map +0 -1
- package/dist/scan/parse-sql-select.js +0 -208
- package/dist/scan/parse-sql-select.js.map +0 -1
- package/src/scan/parse-sql-query.ts +0 -53
- package/src/scan/parse-sql-select.ts +0 -220
|
@@ -43,6 +43,8 @@ __export(index_exports, {
|
|
|
43
43
|
TableBatchBuilder: () => TableBatchBuilder,
|
|
44
44
|
TableConverter: () => TableConverter,
|
|
45
45
|
convert: () => convert,
|
|
46
|
+
convertArrowTable: () => convertArrowTable,
|
|
47
|
+
convertArrowTableBatch: () => convertArrowTableBatch,
|
|
46
48
|
convertArrowToSchema: () => convertArrowToSchema,
|
|
47
49
|
convertArrowToTable: () => convertArrowToTable2,
|
|
48
50
|
convertBatch: () => convertBatch,
|
|
@@ -718,127 +720,8 @@ function deserializeArrowDictionaryKeyType(keyType) {
|
|
|
718
720
|
}
|
|
719
721
|
}
|
|
720
722
|
|
|
721
|
-
// src/schema-utils/lib/
|
|
722
|
-
|
|
723
|
-
switch (table.shape) {
|
|
724
|
-
case "array-row-table":
|
|
725
|
-
case "object-row-table":
|
|
726
|
-
return deduceSchemaFromRows(table.data);
|
|
727
|
-
case "geojson-table":
|
|
728
|
-
return deduceSchemaFromGeoJSON(table.features);
|
|
729
|
-
case "columnar-table":
|
|
730
|
-
return deduceSchemaFromColumns(table.data);
|
|
731
|
-
case "arrow-table":
|
|
732
|
-
default:
|
|
733
|
-
throw new Error("Deduce schema");
|
|
734
|
-
}
|
|
735
|
-
}
|
|
736
|
-
function deduceSchemaFromColumns(columnarTable) {
|
|
737
|
-
const fields = [];
|
|
738
|
-
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
739
|
-
const field = deduceFieldFromColumn(column, columnName);
|
|
740
|
-
fields.push(field);
|
|
741
|
-
}
|
|
742
|
-
return { fields, metadata: {} };
|
|
743
|
-
}
|
|
744
|
-
function deduceSchemaFromRows(rowTable) {
|
|
745
|
-
if (!rowTable.length) {
|
|
746
|
-
throw new Error("deduce from empty table");
|
|
747
|
-
}
|
|
748
|
-
const fields = [];
|
|
749
|
-
const row0 = rowTable[0];
|
|
750
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
751
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
752
|
-
}
|
|
753
|
-
return { fields, metadata: {} };
|
|
754
|
-
}
|
|
755
|
-
function deduceSchemaFromGeoJSON(features) {
|
|
756
|
-
if (!features.length) {
|
|
757
|
-
throw new Error("deduce from empty table");
|
|
758
|
-
}
|
|
759
|
-
const fields = [];
|
|
760
|
-
const row0 = features[0].properties || {};
|
|
761
|
-
for (const [columnName, value] of Object.entries(row0)) {
|
|
762
|
-
fields.push(deduceFieldFromValue(value, columnName));
|
|
763
|
-
}
|
|
764
|
-
return { fields, metadata: {} };
|
|
765
|
-
}
|
|
766
|
-
function deduceFieldFromColumn(column, name) {
|
|
767
|
-
if (ArrayBuffer.isView(column)) {
|
|
768
|
-
const type = getDataTypeFromArray(column);
|
|
769
|
-
return {
|
|
770
|
-
name,
|
|
771
|
-
type: type.type || "null",
|
|
772
|
-
nullable: type.nullable
|
|
773
|
-
// metadata: {}
|
|
774
|
-
};
|
|
775
|
-
}
|
|
776
|
-
if (Array.isArray(column) && column.length > 0) {
|
|
777
|
-
const value = column[0];
|
|
778
|
-
const type = getDataTypeFromValue(value);
|
|
779
|
-
return {
|
|
780
|
-
name,
|
|
781
|
-
type,
|
|
782
|
-
nullable: true
|
|
783
|
-
// metadata: {},
|
|
784
|
-
};
|
|
785
|
-
}
|
|
786
|
-
throw new Error("empty table");
|
|
787
|
-
}
|
|
788
|
-
function deduceFieldFromValue(value, name) {
|
|
789
|
-
const type = getDataTypeFromValue(value);
|
|
790
|
-
return {
|
|
791
|
-
name,
|
|
792
|
-
type,
|
|
793
|
-
nullable: true
|
|
794
|
-
// metadata: {}
|
|
795
|
-
};
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// src/schema-utils/lib/table/tables/make-table.ts
|
|
799
|
-
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
800
|
-
function makeTableFromData(data) {
|
|
801
|
-
let table;
|
|
802
|
-
switch (getTableShapeFromData(data)) {
|
|
803
|
-
case "array-row-table":
|
|
804
|
-
table = { shape: "array-row-table", data };
|
|
805
|
-
break;
|
|
806
|
-
case "object-row-table":
|
|
807
|
-
table = { shape: "object-row-table", data };
|
|
808
|
-
break;
|
|
809
|
-
case "columnar-table":
|
|
810
|
-
table = { shape: "columnar-table", data };
|
|
811
|
-
break;
|
|
812
|
-
case "arrow-table":
|
|
813
|
-
table = { shape: "arrow-table", data };
|
|
814
|
-
break;
|
|
815
|
-
default:
|
|
816
|
-
throw new Error("table");
|
|
817
|
-
}
|
|
818
|
-
const schema = deduceTableSchema(table);
|
|
819
|
-
return { ...table, schema };
|
|
820
|
-
}
|
|
821
|
-
function getTableShapeFromData(data) {
|
|
822
|
-
if (data instanceof arrow2.Table) {
|
|
823
|
-
return "arrow-table";
|
|
824
|
-
}
|
|
825
|
-
if (Array.isArray(data)) {
|
|
826
|
-
if (data.length === 0) {
|
|
827
|
-
throw new Error("cannot deduce type of empty table");
|
|
828
|
-
}
|
|
829
|
-
const firstRow = data[0];
|
|
830
|
-
if (Array.isArray(firstRow)) {
|
|
831
|
-
return "array-row-table";
|
|
832
|
-
}
|
|
833
|
-
if (firstRow && typeof firstRow === "object") {
|
|
834
|
-
return "object-row-table";
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
if (data && typeof data === "object") {
|
|
838
|
-
return "columnar-table";
|
|
839
|
-
}
|
|
840
|
-
throw new Error("invalid table");
|
|
841
|
-
}
|
|
723
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table.ts
|
|
724
|
+
var arrow3 = __toESM(require("apache-arrow"), 1);
|
|
842
725
|
|
|
843
726
|
// src/schema-utils/lib/table/tables/table-accessors.ts
|
|
844
727
|
function isTable(table) {
|
|
@@ -1093,57 +976,82 @@ function* makeObjectRowIterator(table, target = {}) {
|
|
|
1093
976
|
}
|
|
1094
977
|
}
|
|
1095
978
|
|
|
1096
|
-
// src/schema-utils/lib/
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
let objectRows;
|
|
1100
|
-
let features;
|
|
1101
|
-
let shape = null;
|
|
1102
|
-
let schema;
|
|
1103
|
-
for await (const batch of batchIterator) {
|
|
1104
|
-
shape = shape || batch.shape;
|
|
1105
|
-
schema = schema || batch.schema;
|
|
1106
|
-
switch (batch.shape) {
|
|
1107
|
-
case "array-row-table":
|
|
1108
|
-
arrayRows = arrayRows || [];
|
|
1109
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1110
|
-
const row = batch.data[rowIndex];
|
|
1111
|
-
arrayRows.push(row);
|
|
1112
|
-
}
|
|
1113
|
-
break;
|
|
1114
|
-
case "object-row-table":
|
|
1115
|
-
objectRows = objectRows || [];
|
|
1116
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1117
|
-
const row = batch.data[rowIndex];
|
|
1118
|
-
objectRows.push(row);
|
|
1119
|
-
}
|
|
1120
|
-
break;
|
|
1121
|
-
case "geojson-table":
|
|
1122
|
-
features = features || [];
|
|
1123
|
-
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1124
|
-
const row = batch.features[rowIndex];
|
|
1125
|
-
features.push(row);
|
|
1126
|
-
}
|
|
1127
|
-
break;
|
|
1128
|
-
case "columnar-table":
|
|
1129
|
-
case "arrow-table":
|
|
1130
|
-
default:
|
|
1131
|
-
throw new Error("shape");
|
|
1132
|
-
}
|
|
1133
|
-
}
|
|
1134
|
-
if (!shape) {
|
|
1135
|
-
return null;
|
|
1136
|
-
}
|
|
1137
|
-
switch (shape) {
|
|
979
|
+
// src/schema-utils/lib/schema/deduce-table-schema.ts
|
|
980
|
+
function deduceTableSchema(table) {
|
|
981
|
+
switch (table.shape) {
|
|
1138
982
|
case "array-row-table":
|
|
1139
|
-
return { shape: "array-row-table", data: arrayRows, schema };
|
|
1140
983
|
case "object-row-table":
|
|
1141
|
-
return
|
|
984
|
+
return deduceSchemaFromRows(table.data);
|
|
1142
985
|
case "geojson-table":
|
|
1143
|
-
return
|
|
986
|
+
return deduceSchemaFromGeoJSON(table.features);
|
|
987
|
+
case "columnar-table":
|
|
988
|
+
return deduceSchemaFromColumns(table.data);
|
|
989
|
+
case "arrow-table":
|
|
1144
990
|
default:
|
|
1145
|
-
|
|
991
|
+
throw new Error("Deduce schema");
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
function deduceSchemaFromColumns(columnarTable) {
|
|
995
|
+
const fields = [];
|
|
996
|
+
for (const [columnName, column] of Object.entries(columnarTable)) {
|
|
997
|
+
const field = deduceFieldFromColumn(column, columnName);
|
|
998
|
+
fields.push(field);
|
|
999
|
+
}
|
|
1000
|
+
return { fields, metadata: {} };
|
|
1001
|
+
}
|
|
1002
|
+
function deduceSchemaFromRows(rowTable) {
|
|
1003
|
+
if (!rowTable.length) {
|
|
1004
|
+
throw new Error("deduce from empty table");
|
|
1005
|
+
}
|
|
1006
|
+
const fields = [];
|
|
1007
|
+
const row0 = rowTable[0];
|
|
1008
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
1009
|
+
const name = Array.isArray(row0) ? `column${Number(columnName) + 1}` : columnName;
|
|
1010
|
+
fields.push(deduceFieldFromValue(value, name));
|
|
1011
|
+
}
|
|
1012
|
+
return { fields, metadata: {} };
|
|
1013
|
+
}
|
|
1014
|
+
function deduceSchemaFromGeoJSON(features) {
|
|
1015
|
+
if (!features.length) {
|
|
1016
|
+
throw new Error("deduce from empty table");
|
|
1017
|
+
}
|
|
1018
|
+
const fields = [];
|
|
1019
|
+
const row0 = features[0].properties || {};
|
|
1020
|
+
for (const [columnName, value] of Object.entries(row0)) {
|
|
1021
|
+
fields.push(deduceFieldFromValue(value, columnName));
|
|
1146
1022
|
}
|
|
1023
|
+
return { fields, metadata: {} };
|
|
1024
|
+
}
|
|
1025
|
+
function deduceFieldFromColumn(column, name) {
|
|
1026
|
+
if (ArrayBuffer.isView(column)) {
|
|
1027
|
+
const type = getDataTypeFromArray(column);
|
|
1028
|
+
return {
|
|
1029
|
+
name,
|
|
1030
|
+
type: type.type || "null",
|
|
1031
|
+
nullable: type.nullable
|
|
1032
|
+
// metadata: {}
|
|
1033
|
+
};
|
|
1034
|
+
}
|
|
1035
|
+
if (Array.isArray(column) && column.length > 0) {
|
|
1036
|
+
const value = column[0];
|
|
1037
|
+
const type = getDataTypeFromValue(value);
|
|
1038
|
+
return {
|
|
1039
|
+
name,
|
|
1040
|
+
type,
|
|
1041
|
+
nullable: true
|
|
1042
|
+
// metadata: {},
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
throw new Error("empty table");
|
|
1046
|
+
}
|
|
1047
|
+
function deduceFieldFromValue(value, name) {
|
|
1048
|
+
const type = getDataTypeFromValue(value);
|
|
1049
|
+
return {
|
|
1050
|
+
name,
|
|
1051
|
+
type,
|
|
1052
|
+
nullable: true
|
|
1053
|
+
// metadata: {}
|
|
1054
|
+
};
|
|
1147
1055
|
}
|
|
1148
1056
|
|
|
1149
1057
|
// src/schema-utils/lib/table/tables/table-column.ts
|
|
@@ -1152,14 +1060,87 @@ function makeColumnFromField(field, length) {
|
|
|
1152
1060
|
return new ArrayType(length);
|
|
1153
1061
|
}
|
|
1154
1062
|
|
|
1155
|
-
// src/schema-utils/lib/table/tables/convert-
|
|
1156
|
-
|
|
1063
|
+
// src/schema-utils/lib/table/tables/convert-table.ts
|
|
1064
|
+
function convertTable(table, shape) {
|
|
1065
|
+
switch (shape) {
|
|
1066
|
+
case "object-row-table":
|
|
1067
|
+
return convertToObjectRowTable(table);
|
|
1068
|
+
case "array-row-table":
|
|
1069
|
+
return convertToArrayRowTable(table);
|
|
1070
|
+
case "columnar-table":
|
|
1071
|
+
return convertToColumnarTable(table);
|
|
1072
|
+
case "arrow-table":
|
|
1073
|
+
return convertToArrowTable(table);
|
|
1074
|
+
default:
|
|
1075
|
+
throw new Error(shape);
|
|
1076
|
+
}
|
|
1077
|
+
}
|
|
1078
|
+
function convertToColumnarTable(table) {
|
|
1079
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
1080
|
+
const fields = schema.fields;
|
|
1081
|
+
if (table.shape === "columnar-table") {
|
|
1082
|
+
return { ...table, schema };
|
|
1083
|
+
}
|
|
1084
|
+
const length = getTableLength(table);
|
|
1085
|
+
const columns = {};
|
|
1086
|
+
for (const field of fields) {
|
|
1087
|
+
const column = makeColumnFromField(field, length);
|
|
1088
|
+
columns[field.name] = column;
|
|
1089
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1090
|
+
column[rowIndex] = getTableCell(table, rowIndex, field.name);
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
return {
|
|
1094
|
+
shape: "columnar-table",
|
|
1095
|
+
schema,
|
|
1096
|
+
data: columns
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
function convertToArrayRowTable(table) {
|
|
1100
|
+
if (table.shape === "array-row-table") {
|
|
1101
|
+
return table;
|
|
1102
|
+
}
|
|
1103
|
+
const length = getTableLength(table);
|
|
1104
|
+
const data = new Array(length);
|
|
1105
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1106
|
+
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1107
|
+
}
|
|
1108
|
+
return {
|
|
1109
|
+
shape: "array-row-table",
|
|
1110
|
+
schema: table.schema,
|
|
1111
|
+
data
|
|
1112
|
+
};
|
|
1113
|
+
}
|
|
1114
|
+
function convertToObjectRowTable(table) {
|
|
1115
|
+
if (table.shape === "object-row-table") {
|
|
1116
|
+
return table;
|
|
1117
|
+
}
|
|
1118
|
+
const length = getTableLength(table);
|
|
1119
|
+
const data = new Array(length);
|
|
1120
|
+
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1121
|
+
data[rowIndex] = getTableRowAsObject(table, rowIndex);
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
shape: "object-row-table",
|
|
1125
|
+
schema: table.schema,
|
|
1126
|
+
data
|
|
1127
|
+
};
|
|
1128
|
+
}
|
|
1129
|
+
function convertToArrowTable(table) {
|
|
1130
|
+
const schema = table.schema || deduceTableSchema(table);
|
|
1131
|
+
const arrowTable = convertTableToArrow({ ...table, schema });
|
|
1132
|
+
return {
|
|
1133
|
+
shape: "arrow-table",
|
|
1134
|
+
schema,
|
|
1135
|
+
data: arrowTable
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1157
1138
|
|
|
1158
1139
|
// src/schema-utils/lib/table/batches/make-arrow-batch-iterator.ts
|
|
1159
|
-
var
|
|
1140
|
+
var arrow2 = __toESM(require("apache-arrow"), 1);
|
|
1160
1141
|
function* makeArrowTableBatchIterator(table, options) {
|
|
1161
1142
|
for (const batch of makeArrowRecordBatchIterator(table, options)) {
|
|
1162
|
-
const arrowTable = new
|
|
1143
|
+
const arrowTable = new arrow2.Table([batch]);
|
|
1163
1144
|
yield {
|
|
1164
1145
|
...batch,
|
|
1165
1146
|
shape: "arrow-table",
|
|
@@ -1176,12 +1157,12 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
1176
1157
|
const numColumns = getTableNumCols(table);
|
|
1177
1158
|
const batchSize = options?.batchSize || length;
|
|
1178
1159
|
const builders = arrowSchema?.fields.map(
|
|
1179
|
-
(arrowField) =>
|
|
1160
|
+
(arrowField) => arrow2.makeBuilder({
|
|
1180
1161
|
type: arrowField.type,
|
|
1181
1162
|
nullValues: [null, void 0]
|
|
1182
1163
|
})
|
|
1183
1164
|
);
|
|
1184
|
-
const structField = new
|
|
1165
|
+
const structField = new arrow2.Struct(arrowSchema.fields);
|
|
1185
1166
|
let batchLength = 0;
|
|
1186
1167
|
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1187
1168
|
for (let columnIndex = 0; columnIndex < numColumns; ++columnIndex) {
|
|
@@ -1192,15 +1173,15 @@ function* makeArrowRecordBatchIterator(table, options) {
|
|
|
1192
1173
|
batchLength++;
|
|
1193
1174
|
if (batchLength >= batchSize) {
|
|
1194
1175
|
const datas = builders.map((builder) => builder.flush());
|
|
1195
|
-
const structData = new
|
|
1196
|
-
yield new
|
|
1176
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1177
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1197
1178
|
batchLength = 0;
|
|
1198
1179
|
}
|
|
1199
1180
|
}
|
|
1200
1181
|
if (batchLength > 0) {
|
|
1201
1182
|
const datas = builders.map((builder) => builder.flush());
|
|
1202
|
-
const structData = new
|
|
1203
|
-
yield new
|
|
1183
|
+
const structData = new arrow2.Data(structField, 0, batchLength, 0, void 0, datas);
|
|
1184
|
+
yield new arrow2.RecordBatch(arrowSchema, structData);
|
|
1204
1185
|
batchLength = 0;
|
|
1205
1186
|
}
|
|
1206
1187
|
builders.map((builder) => builder.finish());
|
|
@@ -1217,7 +1198,7 @@ function convertTableToArrow(table, options) {
|
|
|
1217
1198
|
// fall through
|
|
1218
1199
|
default:
|
|
1219
1200
|
const arrowBatchIterator = makeArrowRecordBatchIterator(table, options);
|
|
1220
|
-
return new
|
|
1201
|
+
return new arrow3.Table(arrowBatchIterator);
|
|
1221
1202
|
}
|
|
1222
1203
|
}
|
|
1223
1204
|
function convertArrowToTable(arrowTable, shape) {
|
|
@@ -1280,80 +1261,118 @@ function convertArrowToGeoJSONTable(arrowTable) {
|
|
|
1280
1261
|
};
|
|
1281
1262
|
}
|
|
1282
1263
|
|
|
1283
|
-
// src/schema-utils/lib/table/tables/convert-table.ts
|
|
1284
|
-
function
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1264
|
+
// src/schema-utils/lib/table/tables/convert-arrow-table-wrapper.ts
|
|
1265
|
+
function convertArrowTable(table, shape) {
|
|
1266
|
+
if (shape === table.shape) {
|
|
1267
|
+
return table;
|
|
1268
|
+
}
|
|
1269
|
+
const converted = convertArrowToTable(table.data, shape);
|
|
1270
|
+
return {
|
|
1271
|
+
...table,
|
|
1272
|
+
...converted,
|
|
1273
|
+
schema: table.schema ?? converted.schema
|
|
1274
|
+
};
|
|
1275
|
+
}
|
|
1276
|
+
function convertArrowTableBatch(batch, shape) {
|
|
1277
|
+
return convertArrowTable(batch, shape);
|
|
1278
|
+
}
|
|
1279
|
+
|
|
1280
|
+
// src/schema-utils/lib/table/tables/make-table.ts
|
|
1281
|
+
var arrow4 = __toESM(require("apache-arrow"), 1);
|
|
1282
|
+
function makeTableFromData(data) {
|
|
1283
|
+
let table;
|
|
1284
|
+
switch (getTableShapeFromData(data)) {
|
|
1288
1285
|
case "array-row-table":
|
|
1289
|
-
|
|
1286
|
+
table = { shape: "array-row-table", data };
|
|
1287
|
+
break;
|
|
1288
|
+
case "object-row-table":
|
|
1289
|
+
table = { shape: "object-row-table", data };
|
|
1290
|
+
break;
|
|
1290
1291
|
case "columnar-table":
|
|
1291
|
-
|
|
1292
|
+
table = { shape: "columnar-table", data };
|
|
1293
|
+
break;
|
|
1292
1294
|
case "arrow-table":
|
|
1293
|
-
|
|
1295
|
+
table = { shape: "arrow-table", data };
|
|
1296
|
+
break;
|
|
1294
1297
|
default:
|
|
1295
|
-
throw new Error(
|
|
1298
|
+
throw new Error("table");
|
|
1296
1299
|
}
|
|
1300
|
+
const schema = deduceTableSchema(table);
|
|
1301
|
+
return { ...table, schema };
|
|
1297
1302
|
}
|
|
1298
|
-
function
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
if (table.shape === "columnar-table") {
|
|
1302
|
-
return { ...table, schema };
|
|
1303
|
+
function getTableShapeFromData(data) {
|
|
1304
|
+
if (data instanceof arrow4.Table) {
|
|
1305
|
+
return "arrow-table";
|
|
1303
1306
|
}
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1307
|
+
if (Array.isArray(data)) {
|
|
1308
|
+
if (data.length === 0) {
|
|
1309
|
+
throw new Error("cannot deduce type of empty table");
|
|
1310
|
+
}
|
|
1311
|
+
const firstRow = data[0];
|
|
1312
|
+
if (Array.isArray(firstRow)) {
|
|
1313
|
+
return "array-row-table";
|
|
1314
|
+
}
|
|
1315
|
+
if (firstRow && typeof firstRow === "object") {
|
|
1316
|
+
return "object-row-table";
|
|
1311
1317
|
}
|
|
1312
1318
|
}
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
schema,
|
|
1316
|
-
data: columns
|
|
1317
|
-
};
|
|
1318
|
-
}
|
|
1319
|
-
function convertToArrayRowTable(table) {
|
|
1320
|
-
if (table.shape === "array-row-table") {
|
|
1321
|
-
return table;
|
|
1322
|
-
}
|
|
1323
|
-
const length = getTableLength(table);
|
|
1324
|
-
const data = new Array(length);
|
|
1325
|
-
for (let rowIndex = 0; rowIndex < length; rowIndex++) {
|
|
1326
|
-
data[rowIndex] = getTableRowAsArray(table, rowIndex);
|
|
1319
|
+
if (data && typeof data === "object") {
|
|
1320
|
+
return "columnar-table";
|
|
1327
1321
|
}
|
|
1328
|
-
|
|
1329
|
-
shape: "array-row-table",
|
|
1330
|
-
schema: table.schema,
|
|
1331
|
-
data
|
|
1332
|
-
};
|
|
1322
|
+
throw new Error("invalid table");
|
|
1333
1323
|
}
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1324
|
+
|
|
1325
|
+
// src/schema-utils/lib/table/batches/make-table-from-batches.ts
|
|
1326
|
+
async function makeTableFromBatches(batchIterator) {
|
|
1327
|
+
let arrayRows;
|
|
1328
|
+
let objectRows;
|
|
1329
|
+
let features;
|
|
1330
|
+
let shape = null;
|
|
1331
|
+
let schema;
|
|
1332
|
+
for await (const batch of batchIterator) {
|
|
1333
|
+
shape = shape || batch.shape;
|
|
1334
|
+
schema = schema || batch.schema;
|
|
1335
|
+
switch (batch.shape) {
|
|
1336
|
+
case "array-row-table":
|
|
1337
|
+
arrayRows = arrayRows || [];
|
|
1338
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1339
|
+
const row = batch.data[rowIndex];
|
|
1340
|
+
arrayRows.push(row);
|
|
1341
|
+
}
|
|
1342
|
+
break;
|
|
1343
|
+
case "object-row-table":
|
|
1344
|
+
objectRows = objectRows || [];
|
|
1345
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1346
|
+
const row = batch.data[rowIndex];
|
|
1347
|
+
objectRows.push(row);
|
|
1348
|
+
}
|
|
1349
|
+
break;
|
|
1350
|
+
case "geojson-table":
|
|
1351
|
+
features = features || [];
|
|
1352
|
+
for (let rowIndex = 0; rowIndex < getTableLength(batch); rowIndex++) {
|
|
1353
|
+
const row = batch.features[rowIndex];
|
|
1354
|
+
features.push(row);
|
|
1355
|
+
}
|
|
1356
|
+
break;
|
|
1357
|
+
case "columnar-table":
|
|
1358
|
+
case "arrow-table":
|
|
1359
|
+
default:
|
|
1360
|
+
throw new Error("shape");
|
|
1361
|
+
}
|
|
1337
1362
|
}
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1363
|
+
if (!shape) {
|
|
1364
|
+
return null;
|
|
1365
|
+
}
|
|
1366
|
+
switch (shape) {
|
|
1367
|
+
case "array-row-table":
|
|
1368
|
+
return { shape: "array-row-table", data: arrayRows, schema };
|
|
1369
|
+
case "object-row-table":
|
|
1370
|
+
return { shape: "object-row-table", data: objectRows, schema };
|
|
1371
|
+
case "geojson-table":
|
|
1372
|
+
return { shape: "geojson-table", type: "FeatureCollection", features, schema };
|
|
1373
|
+
default:
|
|
1374
|
+
return null;
|
|
1342
1375
|
}
|
|
1343
|
-
return {
|
|
1344
|
-
shape: "object-row-table",
|
|
1345
|
-
schema: table.schema,
|
|
1346
|
-
data
|
|
1347
|
-
};
|
|
1348
|
-
}
|
|
1349
|
-
function convertToArrowTable(table) {
|
|
1350
|
-
const schema = table.schema || deduceTableSchema(table);
|
|
1351
|
-
const arrowTable = convertTableToArrow({ ...table, schema });
|
|
1352
|
-
return {
|
|
1353
|
-
shape: "arrow-table",
|
|
1354
|
-
schema,
|
|
1355
|
-
data: arrowTable
|
|
1356
|
-
};
|
|
1357
1376
|
}
|
|
1358
1377
|
|
|
1359
1378
|
// src/schema-utils/lib/table/tables/table-converter/convert-tables.ts
|
|
@@ -1415,7 +1434,7 @@ function convertToObjectRow(arrayRow, headers) {
|
|
|
1415
1434
|
}
|
|
1416
1435
|
} else {
|
|
1417
1436
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
1418
|
-
const columnName = `column
|
|
1437
|
+
const columnName = `column${i + 1}`;
|
|
1419
1438
|
objectRow[columnName] = arrayRow[i];
|
|
1420
1439
|
}
|
|
1421
1440
|
}
|
|
@@ -1437,7 +1456,7 @@ function convertToArrayRow(objectRow, headers) {
|
|
|
1437
1456
|
function inferHeadersFromArrayRow(arrayRow) {
|
|
1438
1457
|
const headers = [];
|
|
1439
1458
|
for (let i = 0; i < arrayRow.length; i++) {
|
|
1440
|
-
const columnName = `column
|
|
1459
|
+
const columnName = `column${i + 1}`;
|
|
1441
1460
|
headers.push(columnName);
|
|
1442
1461
|
}
|
|
1443
1462
|
return headers;
|
|
@@ -3363,6 +3382,8 @@ function getAttributeStorageKey(attribute) {
|
|
|
3363
3382
|
TableBatchBuilder,
|
|
3364
3383
|
TableConverter,
|
|
3365
3384
|
convert,
|
|
3385
|
+
convertArrowTable,
|
|
3386
|
+
convertArrowTableBatch,
|
|
3366
3387
|
convertArrowToSchema,
|
|
3367
3388
|
convertArrowToTable,
|
|
3368
3389
|
convertBatch,
|