-
Notifications
You must be signed in to change notification settings - Fork 953
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
Query requests return with sample size defined in advanced setting #9356
base: main
Are you sure you want to change the base?
Query requests return with sample size defined in advanced setting #9356
Conversation
❌ Empty Changelog SectionThe Changelog section in your PR description is empty. Please add a valid changelog entry or entries. If you did add a changelog entry, check to make sure that it was not accidentally included inside the comment block in the Changelog section. |
Signed-off-by: abbyhu2000 <[email protected]>
d3fe9fb
to
b164a62
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #9356 +/- ##
==========================================
- Coverage 61.71% 61.70% -0.01%
==========================================
Files 3816 3817 +1
Lines 91829 91847 +18
Branches 14543 14549 +6
==========================================
+ Hits 56668 56670 +2
- Misses 31506 31520 +14
- Partials 3655 3657 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Signed-off-by: abbyhu2000 <[email protected]>
…rch-Dashboards into sending_size_response
getInitialQueryString: (query: Query) => { | ||
switch (query.language) { | ||
case 'PPL': | ||
return `source = ${query.dataset?.title} | head 10`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
be a follow up. but did want to potentially interpolate the sample size here?
so by default without changing the advance settings this would be source = foo | head 500
?
@canascar however i dont know if that would cause some workload issues
@@ -43,6 +43,7 @@ export class Facet { | |||
const { format, lang } = request.body; | |||
const params = { | |||
body: { | |||
fetch_size: request.body.fetch_size, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if we have the context still here are we not able to just access advanced settings in this file and set the param? or was there a technical blocker that we should specify for each strategy the size if set or not.
and should we check if this value is set or not if it is then we pass it? what are implications of passing undefined to this the API? because right now i believe it will fire a request like
{
body: {
fetch_size: undefined,
query: query.query,
// ... other properties
},
// ... format property if applicable
}
will it be ignored?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i dont see updates to the async search strategies (like S3), but I think doing it here in the fetch call should actually cover everything. Since async searches eventually hit this fetch method anyway, we should be good.
Mind double-checking that though? Just want to make sure I'm not missing something with the async flow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
directly passing the fetch size in the facet will cause async query to fail since it doesn't accept fetch_size as a param
const fetchSize = await context.core.uiSettings.client.get('discover:sampleSize');
const params = {
body: {
fetch_size: fetchSize,
query: query.query,
...(meta?.name && { datasource: meta.name }),
...(meta?.sessionId && {
sessionId: meta.sessionId,
}),
...(lang && { lang }),
},
...(format !== 'jdbc' && { format }),
};
![Screenshot 2025-02-12 at 5 51 14 PM](https://private-user-images.githubusercontent.com/43937633/412681201-77978310-7174-4882-a6a4-90c0450e8a37.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk2OTAxNDIsIm5iZiI6MTczOTY4OTg0MiwicGF0aCI6Ii80MzkzNzYzMy80MTI2ODEyMDEtNzc5NzgzMTAtNzE3NC00ODgyLWE2YTQtOTBjMDQ1MGU4YTM3LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE2VDA3MTA0MlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk2MjNhNjA3YjExMDBjZjAxYTBjNzM2OWJkYTMwZDcwNzJiYjMxODFhYmE2YTZlYmQ5NjEzZDljZjkyZGZlMWUmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.fMbTIJkq4dtOTOhPPodFfo-eQYtzxNMBTfj4wBS9ToA)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think since async search for s3 and PPL doesn't support fetch_size yet, we can interpolate the default query string for s3 dataset types and PPL queries for now. The limit number we get from advanced setting
source = ${dataset.title} | head 500
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will change to only pass in fetch_size if fetch_size is defined.
@@ -35,6 +35,7 @@ export const pplSearchStrategyProvider = ( | |||
return { | |||
search: async (context, request: any, options) => { | |||
try { | |||
request.body.fetch_size = await context.core.uiSettings.client.get('discover:sampleSize'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is my bad - I get why you did it this way.
After thinking about it more, pulling from discover's advanced settings on the server side probably isn't the right move. If we want dashboards to have query editor + ppl/sql support down the road, we shouldn't make everything use discover's sample size setting.
however - until we deprecate these search strategies which is something we need to do and move to the right ones (based on data type + proper internal routes), we might be stuck. Could you check if we're already passing size params in the request/options somewhere? If we are, we should probably use that instead.
If we're not though, trying to refactor this now might be more trouble than it's worth, since we know we need to clean it up later anyway. Might make more sense to keep it on the query enhancements side for now and just add a TODO and link whatever issue we open in the code for follow up.
Let me know what you find re: the request params and we can figure out next steps.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it. By looking at the runSearch
and fetch
function in data plugin, i do not see we pass in any size param here.
Do you mind keep it on the query enhancements side for now?
@@ -33,6 +33,7 @@ export const sqlSearchStrategyProvider = ( | |||
return { | |||
search: async (context, request: any, options) => { | |||
try { | |||
request.body.fetch_size = await context.core.uiSettings.client.get('discover:sampleSize'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: instead of modifying objects directly, we should try to spread them like:
const newObj = { ...oldObj, newStuff }
It's a small thing but helps avoid unexpected side effects 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
@@ -98,7 +98,7 @@ const queriesTestSuite = () => { | |||
// Default SQL query should be set | |||
cy.waitForLoader(true); | |||
cy.getElementByTestId(`osdQueryEditor__multiLine`).contains( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
js file 😭
smart! some comments though first. |
Signed-off-by: abbyhu2000 <[email protected]>
Signed-off-by: abbyhu2000 <[email protected]>
Description
The size of the SQL and PPL responses should be determined by advanced setting
discover:sampleSize
. Default value is 500.SQL:
Default
PPL:
Default:
async SQL/PPL:
Default:
Screenshot
Screen.Recording.2025-02-13.at.4.56.28.PM.mov
Testing the changes
Changelog
Check List
yarn test:jest
yarn test:jest_integration