@truto/truto-jsonata 1.0.53 → 1.0.54
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/README.md +34 -0
- package/dist/browser/index.js +5256 -2574
- package/dist/browser/index.js.map +167 -119
- package/dist/cjs/index.cjs +5256 -2574
- package/dist/cjs/index.cjs.map +167 -119
- package/dist/esm/index.js +153 -21
- package/dist/esm/index.js.map +5 -4
- package/dist/functions/jsonToParquet.d.ts +6 -0
- package/package.json +9 -7
package/README.md
CHANGED
|
@@ -926,6 +926,40 @@ expression5.evaluate({ emptyData }).then(result => {
|
|
|
926
926
|
|
|
927
927
|
</details>
|
|
928
928
|
|
|
929
|
+
<details>
|
|
930
|
+
<summary> jsonToParquet(rows, options?)</summary>
|
|
931
|
+
|
|
932
|
+
Converts a single object or an array of objects to **Apache Parquet** and returns an **`ArrayBuffer`** (for example S3/GCS uploads or sync job V4 datastore `content`). Implemented with **[hyparquet-writer](https://www.npmjs.com/package/hyparquet-writer)** ([`parquetWriteBuffer`](https://github.com/hyparam/hyparquet-writer)) so it stays suitable for **Cloudflare Workers** and other environments without Node-only Parquet stacks.
|
|
933
|
+
|
|
934
|
+
**Input**
|
|
935
|
+
|
|
936
|
+
- **rows**: One `Record` or an array of records. `null` / `undefined` entries in an array are removed. If nothing is left, the result is an empty `ArrayBuffer`.
|
|
937
|
+
- **options** _(optional)_: Only the fields below are passed through; anything else is ignored. Omitted keys use [hyparquet-writer defaults](https://github.com/hyparam/hyparquet-writer) (for example default compression).
|
|
938
|
+
|
|
939
|
+
| Option | Type | Description |
|
|
940
|
+
|--------|------|-------------|
|
|
941
|
+
| **codec** | `'SNAPPY'` \| `'GZIP'` \| `'ZSTD'` \| `'UNCOMPRESSED'` | Column compression codec. Matches hyparquet-writer / Parquet codecs. When omitted, the writer’s default applies (typically `SNAPPY`). |
|
|
942
|
+
| **rowGroupSize** | `number` \| `number[]` | Rows per row group. A single number fixes the size; an array can define a tiered layout (see hyparquet-writer `ParquetWriteOptions`). |
|
|
943
|
+
|
|
944
|
+
Nested objects and arrays are stored with Parquet’s **JSON** logical type (UTF-8 JSON text). Primitive columns are inferred where possible (`BOOLEAN`, `INT32` / `INT64` / `DOUBLE`, `STRING`, timestamps for `Date`, etc.).
|
|
945
|
+
|
|
946
|
+
**Example:**
|
|
947
|
+
|
|
948
|
+
```javascript
|
|
949
|
+
import trutoJsonata from '@truto/truto-jsonata';
|
|
950
|
+
|
|
951
|
+
const rows = [{ id: '1', count: 42 }, { id: '2', count: 7 }];
|
|
952
|
+
const options = { codec: 'UNCOMPRESSED', rowGroupSize: 1000 };
|
|
953
|
+
const expression = trutoJsonata('$jsonToParquet(rows, options)');
|
|
954
|
+
expression.evaluate({ rows, options }).then((buf) => {
|
|
955
|
+
// buf instanceof ArrayBuffer
|
|
956
|
+
});
|
|
957
|
+
```
|
|
958
|
+
|
|
959
|
+
**References:** [hyparquet-writer on npm](https://www.npmjs.com/package/hyparquet-writer) · [hyparquet-writer on GitHub](https://github.com/hyparam/hyparquet-writer)
|
|
960
|
+
|
|
961
|
+
</details>
|
|
962
|
+
|
|
929
963
|
<details>
|
|
930
964
|
<summary> getMimeType(fileName)</summary>
|
|
931
965
|
|