From de8c630209de4288ef4bfb6f062036e21ea9c538 Mon Sep 17 00:00:00 2001 From: "J.C. Zhong" Date: Thu, 5 Dec 2024 17:33:38 +0000 Subject: [PATCH 1/3] fix sampling bug --- .../DataDocStatementExecution/StatementResult.tsx | 6 +++++- .../webapp/components/QueryEditor/QueryEditor.tsx | 1 + .../components/QueryRunButton/QueryRunButton.tsx | 13 +++++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx b/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx index 53a3a6bd2..17af85cf8 100644 --- a/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx +++ b/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx @@ -294,6 +294,11 @@ const FetchInfo: React.FC<{ Sampled {sampleRate}% + ) + + Results must be upscaled by {Math.round(100 / sampleRate)}x + + . Learn more about accuracy and opt-out {sampleUserGuideLink ? ( ) : null} - ) ); diff --git a/querybook/webapp/components/QueryEditor/QueryEditor.tsx b/querybook/webapp/components/QueryEditor/QueryEditor.tsx index f5dcc70ad..1a72a1c01 100644 --- a/querybook/webapp/components/QueryEditor/QueryEditor.tsx +++ b/querybook/webapp/components/QueryEditor/QueryEditor.tsx @@ -462,6 +462,7 @@ export const QueryEditor: React.FC< extensions={extensions} basicSetup={basicSetup} editable={!readOnly} + readOnly={readOnly} autoFocus={false} onChange={onChangeHandler} indentWithTab={false} diff --git a/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx b/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx index 0ed94d019..d9a942bd8 100644 --- a/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx +++ b/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx @@ -298,14 +298,19 @@ const TableSamplingSelector: React.FC<{ onTableSamplingInfoClick: () => void; }> = ({ sampleRate, setSampleRate, tooltipPos, onTableSamplingInfoClick }) => { const sampleRateOptions = React.useMemo(getTableSamplingRateOptions, []); - const userDefaultTableSampleRate = useSelector( - (state: IStoreState) => state.user.computedSettings['table_sample_rate'] - ); + const userDefaultTableSampleRate = useSelector((state: IStoreState) => { + const sampleRateSetting = parseFloat( + state.user.computedSettings['table_sample_rate'] + ); + return isNaN(sampleRateSetting) + ? TABLE_SAMPLING_CONFIG.default_sample_rate + : sampleRateSetting; + }); React.useEffect(() => { // If it is a new cell without the sample rate selected, use the default sample rate from user settings if (sampleRate === undefined) { - setSampleRate(parseFloat(userDefaultTableSampleRate)); + setSampleRate(userDefaultTableSampleRate); } }, [sampleRate, setSampleRate, userDefaultTableSampleRate]); From 66729679a6b2fb72239be42bc70e0c091d11960f Mon Sep 17 00:00:00 2001 From: "J.C. Zhong" Date: Thu, 5 Dec 2024 17:39:11 +0000 Subject: [PATCH 2/3] update message --- .../StatementResult.tsx | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx b/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx index 17af85cf8..e027c9e47 100644 --- a/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx +++ b/querybook/webapp/components/DataDocStatementExecution/StatementResult.tsx @@ -298,17 +298,22 @@ const FetchInfo: React.FC<{ Results must be upscaled by {Math.round(100 / sampleRate)}x - . Learn more about accuracy and opt-out + . {sampleUserGuideLink ? ( - { - window.open(sampleUserGuideLink, '_blank'); - }} - icon="Info" - size={16} - noPadding - /> + <> + + Learn more about accuracy and opt-out + + { + window.open(sampleUserGuideLink, '_blank'); + }} + icon="Info" + size={16} + noPadding + /> + ) : null} ); From cb960521c399079d226dfce5dbd6dd6c2d9b2b2d Mon Sep 17 00:00:00 2001 From: "J.C. Zhong" Date: Thu, 5 Dec 2024 17:54:29 +0000 Subject: [PATCH 3/3] update --- querybook/webapp/components/QueryRunButton/QueryRunButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx b/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx index d9a942bd8..41458435c 100644 --- a/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx +++ b/querybook/webapp/components/QueryRunButton/QueryRunButton.tsx @@ -309,7 +309,7 @@ const TableSamplingSelector: React.FC<{ React.useEffect(() => { // If it is a new cell without the sample rate selected, use the default sample rate from user settings - if (sampleRate === undefined) { + if (isNaN(sampleRate)) { setSampleRate(userDefaultTableSampleRate); } }, [sampleRate, setSampleRate, userDefaultTableSampleRate]);