Skip to content

Commit

Permalink
Merge branch 'joe_explain_zero_rows_warning' into 'master'
Browse files Browse the repository at this point in the history
feat (UI): Display warning when a plan returns zero rows

See merge request postgres-ai/database-lab!943
  • Loading branch information
Bogdan Tsechoev committed Dec 9, 2024
2 parents f4706d4 + ec72050 commit 6632429
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ export const JoeSessionCommandWrapper = (props) => {
bottomSpace: {
...styles.bottomSpace,
},
warningContainer: {
marginTop: theme.spacing(2)
}
}),
{ index: 1 },
)
Expand Down
19 changes: 19 additions & 0 deletions ui/packages/platform/src/pages/JoeSessionCommand/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import Permissions from 'utils/permissions';
import format from 'utils/format';

import { TabPanel } from './TabPanel';
import Alert from "@mui/material/Alert";

const hashLinkVisualizePrefix = 'visualize-';

Expand Down Expand Up @@ -139,6 +140,19 @@ class JoeSessionCommand extends Component {
return !!data && data.command === 'explain';
};

planHasNoRows = () => {
if (!this.isExplain()) return false;
const data = this.getCommandData();
const planExecJson = data && data.planExecJson;
if (!planExecJson) return false;

const planExecJsonParsed = JSON.parse(planExecJson);
if (!Array.isArray(planExecJsonParsed) || planExecJsonParsed.length === 0) return false;

const plan = planExecJsonParsed[0] && planExecJsonParsed[0]["Plan"];
return plan && plan["Actual Rows"] === 0;
}

showExternalVisualization = (type) => {
const data = this.getCommandData();

Expand Down Expand Up @@ -351,6 +365,11 @@ class JoeSessionCommand extends Component {
</div>
}

{this.planHasNoRows() && <div className={classes.warningContainer}>
<Alert severity="warning">Query returned 0 rows. This may not reflect production performance or use the same query plan. If you expect results, try adjusting parameters (e.g., different ID values).
</Alert>
</div>}

<div>
<h4>Author:</h4>
<p>
Expand Down

0 comments on commit 6632429

Please sign in to comment.