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 dataset connection ID and dataset name to dataset insertion query #176

Merged
merged 2 commits into from
Apr 10, 2024
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
25 changes: 9 additions & 16 deletions cypress/e2e/snowflake/fork.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,20 @@ describe('fork', () => {
cy.get('textarea').type('select 0 as lat, 0 as lon', { force: true })
cy.get(`button:contains("${copy.execute}")`).click()
cy.get('div:contains("1 rows")', { timeout: 20000 }).should('be.visible')
cy.window().then(async (win) => {
if (!Cypress.env('CI')) {
originalColor = await getColorAtMapCenter(win)
expect(originalColor).to.be.a('string')
}
})

cy.get('span[title="Dataset setting"]').click()
cy.get('input#dekart-dataset-name-input').should('be.visible')
const randomDatasetName = `test-${Math.floor(Math.random() * 1000000)}`
cy.get('input#dekart-dataset-name-input').type(randomDatasetName)
cy.get('button#dekart-save-dataset-name-button').click()
cy.get(`span:contains("${randomDatasetName}")`).should('be.visible')
cy.get('button#dekart-save-button').should('contain', 'Save')
cy.get('button#dekart-save-button').click()
cy.get('button#dekart-save-button').should('not.contain', 'Save*')
cy.get('button#dekart-save-button').should('contain', 'Save')
cy.get('button#dekart-fork-button').click()
cy.get('#dekart-query-status-message').should('be.empty')
cy.get(`button:contains("${copy.execute}")`).should('be.enabled')
cy.get(`button:contains("${copy.execute}")`).click()
cy.get('span:contains("Fork of Untitled")').should('be.visible')
cy.get('div:contains("1 rows")', { timeout: 20000 }).should('be.visible')
cy.window().then(async (win) => {
if (!Cypress.env('CI')) {
const color = await getColorAtMapCenter(win)
expect(color).to.be.a('string')
expect(color).to.equal(originalColor)
}
})
cy.get(`span:contains("${randomDatasetName}")`).should('be.visible')
})
})
2 changes: 2 additions & 0 deletions src/client/DatasetSettingsModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ function ModalFooter ({ saving, setSaving, name, datasetId }) {
<div className={styles.modalFooter}>
<Button
disabled={saving}
id='dekart-save-dataset-name-button'
onClick={() => {
setSaving(true)
dispatch(updateDatasetName(datasetId, name))
Expand Down Expand Up @@ -89,6 +90,7 @@ export default function DatasetSettingsModal () {
value={name}
onChange={(e) => setName(e.target.value)}
disabled={saving}
id='dekart-dataset-name-input'
/>
</div>
</Modal>
Expand Down
27 changes: 22 additions & 5 deletions src/server/dekart/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ func (s Server) commitReportWithDatasets(ctx context.Context, report *proto.Repo
}
for i, dataset := range datasets {
datasetId := newDatasetIds[i]
var connectionId *string
if dataset.ConnectionId != "" {
connectionId = &dataset.ConnectionId
}
var queryId *string
var fileId *string
if dataset.QueryId != "" {
Expand All @@ -153,12 +157,24 @@ func (s Server) commitReportWithDatasets(ctx context.Context, report *proto.Repo
id,
query_text,
query_source,
query_source_id
query_source_id,
job_status,
job_result_id,
job_error,
total_rows,
bytes_processed,
result_size
) select
$1,
query_text,
query_source,
query_source_id
query_source_id,
job_status,
job_result_id,
job_error,
total_rows,
bytes_processed,
result_size
from queries where id=$2`,
newQueryID,
dataset.QueryId,
Expand Down Expand Up @@ -196,13 +212,14 @@ func (s Server) commitReportWithDatasets(ctx context.Context, report *proto.Repo
}
}
_, err = tx.ExecContext(ctx, `
INSERT INTO datasets (id, report_id, query_id, file_id, created_at)
VALUES($1, $2, $3, $4, $5)`,
INSERT INTO datasets (id, report_id, query_id, file_id, name, connection_id)
VALUES($1, $2, $3, $4, $5, $6)`,
datasetId,
report.Id,
queryId,
fileId,
time.Unix(dataset.CreatedAt, 0),
dataset.Name,
connectionId,
)
if err != nil {
log.Debug().Err(err).Send()
Expand Down
Loading