Skip to content

Commit

Permalink
When embedding Seafowl query of exported queries, select from the des…
Browse files Browse the repository at this point in the history
…tinationTable

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.
  • Loading branch information
milesrichardson committed Jun 23, 2023
1 parent f0dc316 commit f171fa4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const ExportEmbedPreviewTableOrQuery = <
importedRepository,
exportInput,
makeQuery,
makeSeafowlQuery,
makeMatchInputToExported,
}: {
exportInput: ExportInputShape;
Expand All @@ -33,6 +34,12 @@ export const ExportEmbedPreviewTableOrQuery = <
splitgraphRepository: string;
}
) => string;
makeSeafowlQuery?: (
tableOrQueryInput: ExportInputShape & {
splitgraphNamespace: string;
splitgraphRepository: string;
}
) => string;
makeMatchInputToExported: (
tableOrQueryInput: ExportInputShape
) => (exported: ExportTable) => boolean;
Expand Down Expand Up @@ -158,7 +165,15 @@ export const ExportEmbedPreviewTableOrQuery = <
display: selectedTab === "splitgraph" ? "none" : "block",
}}
>
<SeafowlEmbeddedQuery {...embedProps} />
<SeafowlEmbeddedQuery
{...embedProps}
makeQuery={
makeSeafowlQuery
? () =>
makeSeafowlQuery({ ...exportInput, ...importedRepository })
: embedProps.makeQuery
}
/>
</div>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,13 @@ const ExportPreview = ({
key={`export-query-preview-${exportQuery.destinationTable}-${exportQuery.destinationSchema}`}
exportInput={exportQuery}
importedRepository={{ splitgraphNamespace, splitgraphRepository }}
// This is the query we run on Splitgraph that we exported to Seafowl
makeQuery={({ sourceQuery }) => sourceQuery}
// But once it's exported, we can just select from its table in Seafowl (and
// besides, the sourceQuery might not be compatible with Seafowl anyway)
makeSeafowlQuery={({ destinationSchema, destinationTable }) =>
`SELECT * FROM "${destinationSchema}"."${destinationTable}";`
}
makeMatchInputToExported={(exportQueryInput) =>
(exportTable: ExportTable) => {
return (
Expand Down

0 comments on commit f171fa4

Please sign in to comment.