-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2763 from finos/flexible-table
Allow `bytes` and `string` for JSON/CSV input data with `format` option
- Loading branch information
Showing
11 changed files
with
317 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// ┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ | ||
// ┃ ██████ ██████ ██████ █ █ █ █ █ █▄ ▀███ █ ┃ | ||
// ┃ ▄▄▄▄▄█ █▄▄▄▄▄ ▄▄▄▄▄█ ▀▀▀▀▀█▀▀▀▀▀ █ ▀▀▀▀▀█ ████████▌▐███ ███▄ ▀█ █ ▀▀▀▀▀ ┃ | ||
// ┃ █▀▀▀▀▀ █▀▀▀▀▀ █▀██▀▀ ▄▄▄▄▄ █ ▄▄▄▄▄█ ▄▄▄▄▄█ ████████▌▐███ █████▄ █ ▄▄▄▄▄ ┃ | ||
// ┃ █ ██████ █ ▀█▄ █ ██████ █ ███▌▐███ ███████▄ █ ┃ | ||
// ┣━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┫ | ||
// ┃ Copyright (c) 2017, the Perspective Authors. ┃ | ||
// ┃ ╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌ ┃ | ||
// ┃ This file is part of the Perspective library, distributed under the terms ┃ | ||
// ┃ of the [Apache License 2.0](https://www.apache.org/licenses/LICENSE-2.0). ┃ | ||
// ┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛ | ||
|
||
import { test, expect } from "@finos/perspective-test"; | ||
import perspective from "../perspective_client"; | ||
|
||
const CSV = "x,y,z\n1,2,3\n4,5,6"; | ||
|
||
test.describe("CSV Constructors", function () { | ||
test("Handles String format", async function () { | ||
const table = await perspective.table(CSV); | ||
const v = await table.view(); | ||
const json = await v.to_json(); | ||
expect(json).toEqual([ | ||
{ x: 1, y: 2, z: 3 }, | ||
{ x: 4, y: 5, z: 6 }, | ||
]); | ||
}); | ||
|
||
test("Handles String format with explicit format option", async function () { | ||
const table = await perspective.table(CSV, { | ||
format: "csv", | ||
}); | ||
const v = await table.view(); | ||
const json = await v.to_json(); | ||
expect(json).toEqual([ | ||
{ x: 1, y: 2, z: 3 }, | ||
{ x: 4, y: 5, z: 6 }, | ||
]); | ||
}); | ||
|
||
test("Handles ArrayBuffer format", async function () { | ||
var enc = new TextEncoder(); | ||
const table = await perspective.table(enc.encode(CSV).buffer, { | ||
format: "csv", | ||
}); | ||
const v = await table.view(); | ||
const json = await v.to_json(); | ||
expect(json).toEqual([ | ||
{ x: 1, y: 2, z: 3 }, | ||
{ x: 4, y: 5, z: 6 }, | ||
]); | ||
}); | ||
|
||
test("Handles UInt8Arry format", async function () { | ||
var enc = new TextEncoder(); | ||
const table = await perspective.table(enc.encode(CSV), { | ||
format: "csv", | ||
}); | ||
const v = await table.view(); | ||
const json = await v.to_json(); | ||
expect(json).toEqual([ | ||
{ x: 1, y: 2, z: 3 }, | ||
{ x: 4, y: 5, z: 6 }, | ||
]); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.