Skip to content

Commit 140f865

Browse files
When embedding Seafowl query of exported queries, select from the destinationTable
The point of exporting a query from Splitgraph to Seafowl is that once the result is in Seafowl, we can just select from the destinationTable and forget about the original query (which might not even be compatible with Seafowl). So make sure that when we're embedding an exported query, we only render the query in the embedded Splitgraph query editor, and for the embedded Seafowl Console, we render a query that simply selects from the destinationTable.
1 parent f0dc316 commit 140f865

File tree

2 files changed

+26
-2
lines changed

2 files changed

+26
-2
lines changed

examples/nextjs-import-airbyte-github-export-seafowl/components/EmbeddedQuery/EmbeddedQuery.tsx

+20-2
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const ExportEmbedPreviewTableOrQuery = <
2424
importedRepository,
2525
exportInput,
2626
makeQuery,
27+
makeSeafowlQuery,
2728
makeMatchInputToExported,
2829
}: {
2930
exportInput: ExportInputShape;
@@ -33,6 +34,12 @@ export const ExportEmbedPreviewTableOrQuery = <
3334
splitgraphRepository: string;
3435
}
3536
) => string;
37+
makeSeafowlQuery?: (
38+
tableOrQueryInput: ExportInputShape & {
39+
splitgraphNamespace: string;
40+
splitgraphRepository: string;
41+
}
42+
) => string;
3643
makeMatchInputToExported: (
3744
tableOrQueryInput: ExportInputShape
3845
) => (exported: ExportTable) => boolean;
@@ -79,7 +86,10 @@ export const ExportEmbedPreviewTableOrQuery = <
7986
return {
8087
anchor: "Open in Console",
8188
href: makeSeafowlQueryHref(
82-
makeQuery({ ...exportInput, ...importedRepository })
89+
(makeSeafowlQuery ?? makeQuery)({
90+
...exportInput,
91+
...importedRepository,
92+
})
8393
),
8494
};
8595
}
@@ -158,7 +168,15 @@ export const ExportEmbedPreviewTableOrQuery = <
158168
display: selectedTab === "splitgraph" ? "none" : "block",
159169
}}
160170
>
161-
<SeafowlEmbeddedQuery {...embedProps} />
171+
<SeafowlEmbeddedQuery
172+
{...embedProps}
173+
makeQuery={
174+
makeSeafowlQuery
175+
? () =>
176+
makeSeafowlQuery({ ...exportInput, ...importedRepository })
177+
: embedProps.makeQuery
178+
}
179+
/>
162180
</div>
163181
)}
164182
</div>

examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,13 @@ const ExportPreview = ({
323323
key={`export-query-preview-${exportQuery.destinationTable}-${exportQuery.destinationSchema}`}
324324
exportInput={exportQuery}
325325
importedRepository={{ splitgraphNamespace, splitgraphRepository }}
326+
// This is the query we run on Splitgraph that we exported to Seafowl
326327
makeQuery={({ sourceQuery }) => sourceQuery}
328+
// But once it's exported, we can just select from its table in Seafowl (and
329+
// besides, the sourceQuery might not be compatible with Seafowl anyway)
330+
makeSeafowlQuery={({ destinationSchema, destinationTable }) =>
331+
`SELECT * FROM "${destinationSchema}"."${destinationTable}";`
332+
}
327333
makeMatchInputToExported={(exportQueryInput) =>
328334
(exportTable: ExportTable) => {
329335
return (

0 commit comments

Comments
 (0)