From f171fa41636952d39c7923f7d4d23cc0ace8e2aa Mon Sep 17 00:00:00 2001 From: Miles Richardson Date: Fri, 23 Jun 2023 04:17:19 +0100 Subject: [PATCH] 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. --- .../components/EmbeddedQuery/EmbeddedQuery.tsx | 17 ++++++++++++++++- .../ImportExportStepper/ExportPanel.tsx | 6 ++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/examples/nextjs-import-airbyte-github-export-seafowl/components/EmbeddedQuery/EmbeddedQuery.tsx b/examples/nextjs-import-airbyte-github-export-seafowl/components/EmbeddedQuery/EmbeddedQuery.tsx index ccc9053..92ac38b 100644 --- a/examples/nextjs-import-airbyte-github-export-seafowl/components/EmbeddedQuery/EmbeddedQuery.tsx +++ b/examples/nextjs-import-airbyte-github-export-seafowl/components/EmbeddedQuery/EmbeddedQuery.tsx @@ -24,6 +24,7 @@ export const ExportEmbedPreviewTableOrQuery = < importedRepository, exportInput, makeQuery, + makeSeafowlQuery, makeMatchInputToExported, }: { exportInput: ExportInputShape; @@ -33,6 +34,12 @@ export const ExportEmbedPreviewTableOrQuery = < splitgraphRepository: string; } ) => string; + makeSeafowlQuery?: ( + tableOrQueryInput: ExportInputShape & { + splitgraphNamespace: string; + splitgraphRepository: string; + } + ) => string; makeMatchInputToExported: ( tableOrQueryInput: ExportInputShape ) => (exported: ExportTable) => boolean; @@ -158,7 +165,15 @@ export const ExportEmbedPreviewTableOrQuery = < display: selectedTab === "splitgraph" ? "none" : "block", }} > - + + makeSeafowlQuery({ ...exportInput, ...importedRepository }) + : embedProps.makeQuery + } + /> )} diff --git a/examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx b/examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx index 264609b..716cbc2 100644 --- a/examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx +++ b/examples/nextjs-import-airbyte-github-export-seafowl/components/ImportExportStepper/ExportPanel.tsx @@ -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 (