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

fix: table sampling and editor bug #1525

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,27 @@ const FetchInfo: React.FC<{
<span className="accent-warning-text ml4">
Sampled {sampleRate}%
</span>
)
<span className="accent-warning-text ml4">
Results must be upscaled by {Math.round(100 / sampleRate)}x
</span>
.
{sampleUserGuideLink ? (
<IconButton
className="ml4"
onClick={() => {
window.open(sampleUserGuideLink, '_blank');
}}
icon="Info"
size={16}
noPadding
/>
<>
<span className="ml4">
Learn more about accuracy and opt-out
</span>
<IconButton
className="ml4"
onClick={() => {
window.open(sampleUserGuideLink, '_blank');
}}
icon="Info"
size={16}
noPadding
/>
</>
) : null}
)
</div>
);

Expand Down
1 change: 1 addition & 0 deletions querybook/webapp/components/QueryEditor/QueryEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,7 @@ export const QueryEditor: React.FC<
extensions={extensions}
basicSetup={basicSetup}
editable={!readOnly}
readOnly={readOnly}
autoFocus={false}
onChange={onChangeHandler}
indentWithTab={false}
Expand Down
15 changes: 10 additions & 5 deletions querybook/webapp/components/QueryRunButton/QueryRunButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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));
if (isNaN(sampleRate)) {
setSampleRate(userDefaultTableSampleRate);
}
}, [sampleRate, setSampleRate, userDefaultTableSampleRate]);

Expand Down
Loading