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

feat: Added Rows Returned #13190

Merged
merged 18 commits into from
Mar 3, 2021
Merged

feat: Added Rows Returned #13190

merged 18 commits into from
Mar 3, 2021

Conversation

AAfghahi
Copy link
Member

SUMMARY

SQL Lab shows how many rows have been returned.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Screen Shot 2021-02-17 at 5 01 01 PM
Screen Shot 2021-02-17 at 5 01 16 PM
Screen Shot 2021-02-17 at 5 01 35 PM

These show if you have no Limit, if you have a Limit, or if your results are less than the max limit.

TEST PLAN

ADDITIONAL INFORMATION

@AAfghahi AAfghahi changed the title feature: Added Rows Returned feat: Added Rows Returned Feb 17, 2021
@AAfghahi AAfghahi changed the title feat: Added Rows Returned feat: Added Rows Returned Feb 17, 2021
rowsReturned() {
return (
<div className="ReturnedRows">
{this.state.data && this.state.data.length >= 0 && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can use optional chaining here. Can the length ever be less than 0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I could actually just remove the conditions, since a tighter version of it happens in the render.

<div className="ReturnedRows">
{this.state.data && this.state.data.length >= 0 && (
<span>
{t(`%s rows returned`, this.props.query.results.data.length)}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it feels like this length should be referencing the same length as above?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the query has a rows prop which may be easier than totaling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I originally had this as a drawing from the query function, but when I did that I got an error that said that Query has no property called rows, which is what is being passed into props.query.

However, when I render with this.props.query.rows, it renders perfectly fine, and is responsive to how many lines the SQL result is. I changed it to this because I was tired of my terminal yelling at me.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pull-request-size pull-request-size bot added size/M and removed size/S labels Feb 19, 2021
@AAfghahi
Copy link
Member Author

This is what it would look like if you hit the max display rate:
Screen Shot 2021-02-19 at 3 54 43 PM
Without:

Screen Shot 2021-02-19 at 3 55 07 PM

@codecov-io
Copy link

codecov-io commented Feb 19, 2021

Codecov Report

Merging #13190 (8dc1ffe) into master (892eef1) will decrease coverage by 4.12%.
The diff coverage is 77.03%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master   #13190      +/-   ##
==========================================
- Coverage   77.05%   72.93%   -4.13%     
==========================================
  Files         897      597     -300     
  Lines       45710    21275   -24435     
  Branches     5497     5498       +1     
==========================================
- Hits        35224    15517   -19707     
+ Misses      10362     5631    -4731     
- Partials      124      127       +3     
Flag Coverage Δ
cypress 57.60% <71.69%> (+0.01%) ⬆️
hive ?
javascript 62.76% <55.55%> (+0.26%) ⬆️
mysql ?
postgres ?
presto ?
python ?
sqlite ?

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...erset-frontend/src/SqlLab/components/SouthPane.jsx 82.05% <ø> (ø)
...erset-frontend/src/SqlLab/components/SqlEditor.jsx 55.86% <ø> (-0.15%) ⬇️
...rset-frontend/src/components/ButtonGroup/index.tsx 100.00% <ø> (ø)
...et-frontend/src/components/ErrorBoundary/index.jsx 95.45% <ø> (ø)
...perset-frontend/src/components/FormLabel/index.tsx 100.00% <ø> (ø)
...-frontend/src/components/Select/Select.stories.tsx 0.00% <0.00%> (ø)
superset-frontend/src/components/Select/Select.tsx 90.81% <ø> (ø)
superset-frontend/src/components/Select/styles.tsx 86.30% <ø> (ø)
...et-frontend/src/components/Timer/Timer.stories.tsx 0.00% <0.00%> (ø)
superset-frontend/src/components/Timer/index.tsx 95.83% <ø> (ø)
... and 332 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 892eef1...ab89d5f. Read the comment docs.

Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking good! just a few small comments.

}
return (
<div className="ReturnedRows">
{limitWarning}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bit of a nit, but instead of making limitWarning a react component or null and using it as a boolean, it would be better to use displayLimitReached as the boolean in both cases and have limitWarning always be the icon.

It would read {displayLimitReached && limitWarning} for example and the reader would know that it only shows the limitWarning if the displayLimit is reached, rather than always showing the warning, which will be null if the display limit isn't reached. It's a small nuance, but will help.

}
.LimitMessage{
color: #8E94B0;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're going clean out these less files soon. I'd suggest using the emotion styles instead.

Copy link
Member Author

@AAfghahi AAfghahi Feb 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eschutho changed it to emotion, and also used your updated logic.

New Look (including Sophie's thoughts):
Screen Shot 2021-02-19 at 5 51 49 PM

@AAfghahi AAfghahi force-pushed the return-rows branch 2 times, most recently from eb8a3cc to a9e293d Compare February 19, 2021 22:56
@@ -481,6 +497,27 @@ export default class ResultSet extends React.PureComponent<
return <div className="noControls" />;
}

rowsReturned() {
Copy link
Member

@eschutho eschutho Feb 23, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, but I would rename this renderRowsReturned since it's a function, so thus the verb prefix. Also to be consistent with renderControls

<ReturnedRows>
{query.results?.displayLimitReached && limitWarning}
<span>{t(`%s rows returned`, query.rows)}</span>
{query.results?.displayLimitReached && (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets see if we can put this value into a variable since you're using it twice. You can also declare it in the destructuring on line 501.

`It appears that the number of rows in the query results displayed
was limited on the server side to
the %s limit.`,
query.rows,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is cool. I didn't know that you can do string interpolation in the translate function.

{query.results?.displayLimitReached && limitWarning}
<span>{t(`%s rows returned`, query.rows)}</span>
{query.results?.displayLimitReached && (
<span className="LimitMessage">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually use camel-case (lowercase first letter) for class names.

@@ -100,6 +100,22 @@ const MonospaceDiv = styled.div`
white-space: pre-wrap;
`;

const ReturnedRows = styled.div`
margin-top: 48px;
margin-bottom: -32px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's some weirdness going on with the position: fixed styling of the controls, which is causing these weird margins. Let's see if can remove the position:fixed on the controls. I don't think they are supposed to scroll at all, so we may need to look for a container that has a scroll attribute on the overflow and remove it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eschutho been playing around with this a bit. I got rid of position fixed on the controls, and if do overflow:hidden on the overall container then it replicates the behavior that we want without there being negative margins (I kind of had a theory that you might not like negative margin :) )

What I am currently doing is looking at how to target the overall container.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I think I fixed all of it with the last commit! This was a good dive into the various components in the South Pane.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like:
Screen Shot 2021-02-23 at 12 22 58 PM

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that looks great! also, correct on the negative margins. :)

}
.limitMessage {
color: #8e94b0;
margin-left: 8px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we try to use the themeProvider here for the spacings and colors?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! I couldn't find the right orange color though, should I add it in?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's ask @Steejay if the existing orange works: FF7F44

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eschutho @AAfghahi existing works. nearly identical.

@@ -481,6 +495,28 @@ export default class ResultSet extends React.PureComponent<
return <div className="noControls" />;
}

renderRowsReturned() {
const { results, rows } = this.props.query;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will this.props.query always have a value?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup! It will only render if query.results exists.

@eschutho
Copy link
Member

just so I don't forget, let's follow up on the display alert in this ticket.. does this PR include #10330 too?

@AAfghahi
Copy link
Member Author

just so I don't forget, let's follow up on the display alert in this ticket.. does this PR include #10330 too?

Portions of it, the portions that are not included are the admin portions and the part that requires a migration.

@AAfghahi AAfghahi force-pushed the return-rows branch 2 times, most recently from ff73170 to e5ed831 Compare March 1, 2021 22:57
Copy link
Member

@eschutho eschutho left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good! I'll let @yousoph or @Steejay do a visual review.

@yousoph
Copy link
Member

yousoph commented Mar 3, 2021

Looked at this with @AAfghahi today, it was looking good to me 👍

@hughhhh hughhhh self-requested a review March 3, 2021 15:17
@hughhhh hughhhh merged commit 9c9862f into apache:master Mar 3, 2021
@hughhhh hughhhh deleted the return-rows branch March 3, 2021 15:17
allanco91 pushed a commit to allanco91/superset that referenced this pull request May 21, 2021
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.2.0 labels Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels preset-io size/M 🚢 1.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants