@@ -27,8 +27,11 @@ import {
27
27
QueryState ,
28
28
styled ,
29
29
t ,
30
+ tn ,
30
31
useTheme ,
31
32
usePrevious ,
33
+ css ,
34
+ getNumberFormatter ,
32
35
} from '@superset-ui/core' ;
33
36
import ErrorMessageWithStackTrace from 'src/components/ErrorMessage/ErrorMessageWithStackTrace' ;
34
37
import {
@@ -42,6 +45,9 @@ import { mountExploreUrl } from 'src/explore/exploreUtils';
42
45
import { postFormData } from 'src/explore/exploreUtils/formData' ;
43
46
import ProgressBar from 'src/components/ProgressBar' ;
44
47
import Loading from 'src/components/Loading' ;
48
+ import Card from 'src/components/Card' ;
49
+ import Label from 'src/components/Label' ;
50
+ import { Tooltip } from 'src/components/Tooltip' ;
45
51
import FilterableTable from 'src/components/FilterableTable' ;
46
52
import CopyToClipboard from 'src/components/CopyToClipboard' ;
47
53
import { addDangerToast } from 'src/components/MessageToasts/actions' ;
@@ -55,6 +61,7 @@ import {
55
61
reRunQuery ,
56
62
} from 'src/SqlLab/actions/sqlLab' ;
57
63
import { URL_PARAMS } from 'src/constants' ;
64
+ import Icons from 'src/components/Icons' ;
58
65
import ExploreCtasResultsButton from '../ExploreCtasResultsButton' ;
59
66
import ExploreResultsButton from '../ExploreResultsButton' ;
60
67
import HighlightedSql from '../HighlightedSql' ;
@@ -76,6 +83,7 @@ export interface ResultSetProps {
76
83
query : QueryResponse ;
77
84
search ?: boolean ;
78
85
showSql ?: boolean ;
86
+ showSqlInline ?: boolean ;
79
87
visualize ?: boolean ;
80
88
user : UserWithPermissionsAndRoles ;
81
89
defaultQueryLimit : number ;
@@ -110,7 +118,7 @@ const MonospaceDiv = styled.div`
110
118
111
119
const ReturnedRows = styled . div `
112
120
font-size : ${ ( { theme } ) => theme . typography . sizes . s } px;
113
- line-height: ${ ( { theme } ) => theme . gridUnit * 6 } px ;
121
+ line-height : 1 ;
114
122
` ;
115
123
116
124
const ResultSetControls = styled . div `
@@ -124,10 +132,8 @@ const ResultSetButtons = styled.div`
124
132
padding-right : ${ ( { theme } ) => 2 * theme . gridUnit } px;
125
133
` ;
126
134
127
- const LimitMessage = styled . span `
128
- color: ${ ( { theme } ) => theme . colors . secondary . light1 } ;
129
- margin-left: ${ ( { theme } ) => theme . gridUnit * 2 } px;
130
- ` ;
135
+ const ROWS_CHIP_WIDTH = 100 ;
136
+ const GAP = 8 ;
131
137
132
138
const ResultSet = ( {
133
139
cache = false ,
@@ -138,6 +144,7 @@ const ResultSet = ({
138
144
query,
139
145
search = true ,
140
146
showSql = false ,
147
+ showSqlInline = false ,
141
148
visualize = true ,
142
149
user,
143
150
defaultQueryLimit,
@@ -296,7 +303,7 @@ const ResultSet = ({
296
303
297
304
const renderRowsReturned = ( ) => {
298
305
const { results, rows, queryLimit, limitingFactor } = query ;
299
- let limitMessage ;
306
+ let limitMessage = '' ;
300
307
const limitReached = results ?. displayLimitReached ;
301
308
const limit = queryLimit || results . query . limit ;
302
309
const isAdmin = ! ! user ?. roles ?. Admin ;
@@ -339,7 +346,7 @@ const ResultSet = ({
339
346
{ rows } ,
340
347
) ;
341
348
}
342
-
349
+ const formattedRowCount = getNumberFormatter ( ) ( rows ) ;
343
350
const rowsReturnedMessage = t ( '%(rows)d rows returned' , {
344
351
rows,
345
352
} ) ;
@@ -349,10 +356,27 @@ const ResultSet = ({
349
356
return (
350
357
< ReturnedRows >
351
358
{ ! limitReached && ! shouldUseDefaultDropdownAlert && (
352
- < span title = { tooltipText } >
353
- { rowsReturnedMessage }
354
- < LimitMessage > { limitMessage } </ LimitMessage >
355
- </ span >
359
+ < Tooltip
360
+ id = "sqllab-rowcount-tooltip"
361
+ title = { tooltipText }
362
+ placement = "left"
363
+ >
364
+ < Label
365
+ css = { css `
366
+ line-height : ${ theme . typography . sizes . l } px;
367
+ ` }
368
+ >
369
+ { limitMessage && (
370
+ < Icons . ExclamationCircleOutlined
371
+ css = { css `
372
+ font-size : ${ theme . typography . sizes . m } px;
373
+ margin-right : ${ theme . gridUnit } px;
374
+ ` }
375
+ />
376
+ ) }
377
+ { tn ( '%s row' , '%s rows' , rows , formattedRowCount ) }
378
+ </ Label >
379
+ </ Tooltip >
356
380
) }
357
381
{ ! limitReached && shouldUseDefaultDropdownAlert && (
358
382
< div ref = { calculateAlertRefHeight } >
@@ -413,7 +437,12 @@ const ResultSet = ({
413
437
}
414
438
415
439
if ( showSql ) {
416
- sql = < HighlightedSql sql = { query . sql } /> ;
440
+ sql = (
441
+ < HighlightedSql
442
+ sql = { query . sql }
443
+ { ...( showSqlInline && { maxLines : 1 , maxWidth : 60 } ) }
444
+ />
445
+ ) ;
417
446
}
418
447
419
448
if ( query . state === QueryState . STOPPED ) {
@@ -501,8 +530,39 @@ const ResultSet = ({
501
530
return (
502
531
< ResultContainer >
503
532
{ renderControls ( ) }
504
- { renderRowsReturned ( ) }
505
- { sql }
533
+ { showSql && showSqlInline ? (
534
+ < div
535
+ css = { css `
536
+ display : flex;
537
+ justify-content : space-between;
538
+ gap : ${ GAP } px;
539
+ ` }
540
+ >
541
+ < Card
542
+ css = { [
543
+ css `
544
+ height : 28px ;
545
+ width : calc (100% - ${ ROWS_CHIP_WIDTH + GAP } px);
546
+ code {
547
+ width : 100% ;
548
+ overflow : hidden;
549
+ white-space : nowrap !important ;
550
+ text-overflow : ellipsis;
551
+ display : block;
552
+ }
553
+ ` ,
554
+ ] }
555
+ >
556
+ { sql }
557
+ </ Card >
558
+ { renderRowsReturned ( ) }
559
+ </ div >
560
+ ) : (
561
+ < >
562
+ { renderRowsReturned ( ) }
563
+ { sql }
564
+ </ >
565
+ ) }
506
566
< FilterableTable
507
567
data = { data }
508
568
orderedColumnKeys = { results . columns . map ( col => col . column_name ) }
0 commit comments