Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add load/export support for Arrow IPC Stream #2625

Merged
merged 1 commit into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions packages/e2e-tests/tests/export.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ import fsExtra from "fs-extra"

const tempDir = os.tmpdir()
const formats = [
{label: "ZNG", expectedSize: 3744},
{label: "ZSON", expectedSize: 15137},
{label: "ZJSON", expectedSize: 18007},
{label: "Zeek", expectedSize: 9772},
{label: "Arrow IPC Stream", expectedSize: 46512},
{label: "CSV", expectedSize: 12208},
{label: "JSON", expectedSize: 13659},
{label: "NDJSON", expectedSize: 13657},
{label: "CSV", expectedSize: 12208},
{label: "Zeek", expectedSize: 9772},
{label: "ZJSON", expectedSize: 18007},
{label: "ZNG", expectedSize: 3744},
{label: "ZSON", expectedSize: 15137},
]

test.describe("Export tests", () => {
Expand Down
9 changes: 6 additions & 3 deletions packages/zealot/src/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ export type ClientOpts = {
}

export type ResponseFormat =
| "zng"
| "ndjson"
| "arrows"
| "csv"
| "json"
| "ndjson"
| "zeek"
| "zjson"
| "zng"
| "zson"
| "zeek"

export type QueryOpts = {
format: ResponseFormat
Expand Down Expand Up @@ -64,6 +65,7 @@ export type LoadOpts = {
}
export type LoadFormat =
| "auto"
| "arrows"
| "csv"
| "json"
| "line"
Expand All @@ -75,6 +77,7 @@ export type LoadFormat =

export type LoadContentType =
| "*/*"
| "application/vnd.apache.arrow.stream"
| "text/csv"
| "application/json"
| "application/x-line"
Expand Down
8 changes: 5 additions & 3 deletions packages/zealot/src/client/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,14 @@ export function parseContent(resp: Response | NodeResponse) {

export function accept(format: ResponseFormat) {
const formats = {
zng: "application/x-zng",
ndjson: "application/x-ndjson",
arrows: "application/vnd.apache.arrow.stream",
csv: "text/csv",
json: "application/json",
ndjson: "application/x-ndjson",
zeek: "application/x-zeek",
zjson: "application/x-zjson",
zng: "application/x-zng",
zson: "application/x-zson",
zeek: "application/x-zeek",
}
const value = formats[format]
if (!value) {
Expand Down Expand Up @@ -72,6 +73,7 @@ export function getLoadContentType(
): LoadContentType | null {
if (!format) return null
if (format === "auto") return "*/*"
if (format === "arrows") return "application/vnd.apache.arrow.stream"
if (format === "csv") return "text/csv"
if (format === "json") return "application/json"
if (format === "line") return "application/x-line"
Expand Down
1 change: 1 addition & 0 deletions src/components/data-format-select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export function DataFormatSelect(props: JSX.IntrinsicElements["select"]) {
return (
<SelectInput {...props}>
<option value="auto">Auto-detect</option>
<option value="arrows">Arrow IPC Stream</option>
<option value="csv">CSV</option>
<option value="json">JSON</option>
<option value="line">Line</option>
Expand Down
4 changes: 4 additions & 0 deletions src/js/components/ExportModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@ const ExportModal = ({onClose}) => {
setFormat(e.target.value)
}}
>
<RadioItem>
<input type="radio" id="arrows" value="arrows" name="format" />
<label htmlFor="arrows">Arrow IPC Stream</label>
</RadioItem>
<RadioItem>
<input type="radio" id="csv" value="csv" name="format" />
<label htmlFor="csv">CSV</label>
Expand Down
2 changes: 1 addition & 1 deletion src/js/flows/exportResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function cutColumns(program, columns) {

export function prepareProgram(format, program, columns) {
let p = cutColumns(program, columns)
if (format === "csv") p += " | fuse"
if (format === "csv" || format === "arrows") p += " | fuse"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add Parquet while you're here?

Suggested change
if (format === "csv" || format === "arrows") p += " | fuse"
if (format === "arrows" || format === "csv" || format === "parquet") p += " | fuse"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nwt: As much as I'd love to, I've been holding off on adding support for Parquet export in the app. As described in #2591 and brimdata/super#4215, failures mid-export currently aren't being shown to the user and so there's a hazard of the user having incomplete output and not knowing about it. Granted, this seems to be a general problem with API interactions for both query and load and hence affects other formats as well (#2606, #2554). But in testing with various data I found it was way too easy to trigger the "union type unsupported" with Parquet export in particular, so that's been my rationale for holding it back. I know you've been doing more work with Parquet due to the new Arrow library so I've been waiting for the dust to settle on that before revisiting the topic, since I wondered if maybe the union support might magically appear. 😄 If you feel strongly about getting Parquet export in sooner I could surely change my tune since there's no perfect answers here. On the whole I see this topic of absent error messages during API interactions as a Zui v1.0 release blocker, so it will definitely not be forgotten as a priority.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As much as I'd love to, I've been holding off on adding support for Parquet export in the app.

That's fine. I don't feel strongly about this.

I know you've been doing more work with Parquet due to the new Arrow library so I've been waiting for the dust to settle on that before revisiting the topic, since I wondered if maybe the union support might magically appear.

I'm afraid it won't since the Parquet format itself doesn't support unions.

return p
}

Expand Down