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(sqllab): add headers when copying results to clipboard #23720

Merged
merged 4 commits into from
Apr 18, 2023

Conversation

villebro
Copy link
Member

@villebro villebro commented Apr 18, 2023

SUMMARY

When copying SQL Lab results from the query history to the clipboard, the headers are not included in the payload. This PR adds the headers. While updating the tests I noticed that we were missing test cases for what the columns array actually looks like; it's usually columns: { name: string }[], not columns: string[]. I therefore updated one of the tests to use the object-based columns array instead of the string-based one.

AFTER

Now when you copy this:
image

You get this (the headers may appear to be off, but it's because they're tab separated, which isn't appropriately reflected in the code block):

ds	gender	name	num	state	num_boys	num_girls
1965-01-01 00:00:00.000000	boy	Aaron	369	CA	369	0
1965-01-01 00:00:00.000000	girl	Amy	494	CA	0	494
1965-01-01 00:00:00.000000	girl	Andrea	607	CA	0	607
1965-01-01 00:00:00.000000	boy	Andrew	933	CA	933	0
1965-01-01 00:00:00.000000	girl	Angela	1066	CA	0	1066
1965-01-01 00:00:00.000000	girl	Anna	564	CA	0	564
1965-01-01 00:00:00.000000	boy	Anthony	1928	CA	1928	0
1965-01-01 00:00:00.000000	girl	Barbara	922	CA	0	922
1965-01-01 00:00:00.000000	boy	Bradley	395	CA	395	0
1965-01-01 00:00:00.000000	girl	Brenda	961	CA	0	961

BEFORE

Previously you got this:

1965-01-01 00:00:00.000000	boy	Aaron	369	CA	369	0
1965-01-01 00:00:00.000000	girl	Amy	494	CA	0	494
1965-01-01 00:00:00.000000	girl	Andrea	607	CA	0	607
1965-01-01 00:00:00.000000	boy	Andrew	933	CA	933	0
1965-01-01 00:00:00.000000	girl	Angela	1066	CA	0	1066
1965-01-01 00:00:00.000000	girl	Anna	564	CA	0	564
1965-01-01 00:00:00.000000	boy	Anthony	1928	CA	1928	0
1965-01-01 00:00:00.000000	girl	Barbara	922	CA	0	922
1965-01-01 00:00:00.000000	boy	Bradley	395	CA	395	0
1965-01-01 00:00:00.000000	girl	Brenda	961	CA	0	961

TESTING INSTRUCTIONS

  1. Run a query in SQL Lab
  2. Go to Query History
  3. Click "View" results
  4. Click "Copy to clipboard"

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

Copy link
Member

@kgabryje kgabryje left a comment

Choose a reason for hiding this comment

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

LGTM. CC @yousoph for visibility

@pull-request-size pull-request-size bot added size/M and removed size/S labels Apr 18, 2023
@codecov
Copy link

codecov bot commented Apr 18, 2023

Codecov Report

Merging #23720 (95d854b) into master (b39edc1) will increase coverage by 1.80%.
The diff coverage is 75.00%.

❗ Current head 95d854b differs from pull request most recent head d431f6a. Consider uploading reports for the commit d431f6a to get more accurate results

@@            Coverage Diff             @@
##           master   #23720      +/-   ##
==========================================
+ Coverage   66.30%   68.10%   +1.80%     
==========================================
  Files        1922     1922              
  Lines       74048    74047       -1     
  Branches     8104     8104              
==========================================
+ Hits        49094    50427    +1333     
+ Misses      22882    21545    -1337     
- Partials     2072     2075       +3     
Flag Coverage Δ
javascript 54.14% <75.00%> (+0.01%) ⬆️

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

Impacted Files Coverage Δ
...s/superset-ui-core/src/components/SafeMarkdown.tsx 85.71% <0.00%> (+19.04%) ⬆️
...ackages/superset-ui-core/src/utils/featureFlags.ts 100.00% <ø> (ø)
...frontend/src/SqlLab/components/SqlEditor/index.jsx 58.28% <ø> (+1.60%) ⬆️
.../features/databases/DatabaseModal/ExtraOptions.tsx 70.37% <ø> (ø)
...end/src/features/databases/DatabaseModal/index.tsx 45.36% <ø> (-0.12%) ⬇️
superset-frontend/src/utils/hostNamesConfig.js 73.33% <ø> (ø)
superset/config.py 91.86% <ø> (ø)
superset-frontend/src/utils/common.js 100.00% <100.00%> (ø)

... and 93 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@villebro villebro merged commit 37a78b1 into apache:master Apr 18, 2023
sebastianliebscher pushed a commit to sebastianliebscher/superset that referenced this pull request Apr 28, 2023
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 3.0.0 labels Mar 13, 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 size/M 🚢 3.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants