-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Search] SQL search strategy #127859
[Search] SQL search strategy #127859
Conversation
Pinging @elastic/kibana-app-services (Team:AppServicesSv) |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
@elasticmachine merge upstream |
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.
Added some minor feedback below, overall looking very good!
One thing I noticed was that the error handling varied depending on the error I got:
If I include an index that doesn't exist, I get this:
For incorrect syntax (such as SELECT * FROM logs-*
, without quoting "logs-"
):
In the latter scenario, it looks like the response does in fact contain useful information that should be bubbled up:
"parsing_exception: [parsing_exception] Reason: line 1:22: mismatched input '-' expecting {<EOF>, ',', 'ANALYZE', 'ANALYZED', 'AS', 'CATALOGS', 'COLUMNS', 'CURRENT_DATE', 'CURRENT_TIME', 'CURRENT_TIMESTAMP', 'DAY', 'DEBUG', 'EXECUTABLE', 'EXPLAIN', 'FIRST', 'FORMAT', 'FULL', 'FUNCTIONS', 'GRAPHVIZ', 'GROUP', 'HAVING', 'HOUR', 'INNER', 'INTERVAL', 'JOIN', 'LAST', 'LEFT', 'LIMIT', 'MAPPED', 'MINUTE', 'MONTH', 'NATURAL', 'OPTIMIZED', 'ORDER', 'PARSED', 'PHYSICAL', 'PIVOT', 'PLAN', 'RIGHT', 'RLIKE', 'QUERY', 'SCHEMAS', 'SECOND', 'SHOW', 'SYS', 'TABLES', 'TEXT', 'TOP', 'TYPE', 'TYPES', 'VERIFY', 'WHERE', 'YEAR', LIMIT_ESC, IDENTIFIER, DIGIT_IDENTIFIER, QUOTED_IDENTIFIER, BACKQUOTED_IDENTIFIER}"
</EuiPageContent> | ||
</EuiPageBody> | ||
); | ||
}; |
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.
How simple would it be to add a datagrid with the table results? I think it would be a nice addition. (Or maybe being able to swap the view between a datagrid and the raw response.)
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.
conversion is already implemented in canvas essql search strategy. The plan was to offer a higher level abstraction that will allow passing in kibana query (Filter[], TimeRange, Query[]} and some additional options and will return Datatable.
We shouldn't promote people using this low level stragey, preferably we should be the only consumers imo. What do you think about making this just our internal implementation detail ?
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.
(Or maybe being able to swap the view between a datagrid and the raw response.)
I think Lukas just meant here to improve UI of an example plugin?
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.
Sorry, meant to leave a comment here but GitHub wasn't cooperating at the time. Yes, I just meant improve the UI. We can take care of this in a separate PR if we decide it's helpful.
export const SQL_SEARCH_STRATEGY = 'sql'; | ||
|
||
export type SqlRequestParams = | ||
| Omit<SqlQueryRequest, 'wait_for_completion_timeout' | 'keep_alive' | 'keep_on_completion'> |
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.
Does this mean we wouldn't allow overriding the value for wait_for_completion_timeout
by consumers?
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.
Good point. I agree that allowing wait_for_completion_timeout
wait for completion makes sense since it doesn't interfere with search sessions. Fixing
keep_alive: '1m', | ||
}), | ||
}; | ||
} |
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.
Is there enough overlap between this and the ese
request utils file to warrant combining them? It seems like the parameters are almost identical. Do the different request types make this more difficult than it is worth?
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.
They are quite different. I think combining them would bring more complexity than benefit
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 honestly basically a nit, but I just worry that in the future when we make changes to how we handle keep_alive
, wait_for_completion_timeout
, and keep_on_completion
, we'll have to make them in two places.
What are your thoughts of doing something like this:
import { getDefaultAsyncSubmitParams as getEsAsyncSubmitParams, getDefaultAsyncGetParams as getEsAsyncGetParams } from '../../ese_search/request_utils';
export function getDefaultAsyncSubmitParams(
searchSessionsConfig: SearchSessionsConfigSchema | null,
options: ISearchOptions
): Pick<SqlQueryRequest, 'keep_alive' | 'wait_for_completion_timeout' | 'keep_on_completion'> {
const useSearchSessions = searchSessionsConfig?.enabled && !!options.sessionId;
const { wait_for_completion_timeout, keep_on_completion, keep_alive } = getEsAsyncSubmitParams(searchSessionsConfig, options);
return { wait_for_completion_timeout, keep_on_completion, keep_alive };
}
export function getDefaultAsyncGetParams(
searchSessionsConfig: SearchSessionsConfigSchema | null,
options: ISearchOptions
): Pick<SqlGetAsyncRequest, 'keep_alive' | 'wait_for_completion_timeout'> {
return getEsAsyncSubmitParams(searchSessionsConfig, options);
}
Or better yet, pulling these parameters that we know that every async strategy is going to use into a higher level request_utils.ts. (I'm noticing even EQL search strategy re-uses these from ese_search/request_utils.)
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.
Let's do it 🚀
I suggest we do it separately and review it carefully. Started a draft here #128358
I suggest we should extract polling/async/session-related stuff into common/async_utils
and then use it in every async strategy.
I suggest we merge this and then I finish with the draft
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.
🙌 Sounds great
isRunning: response.is_running, | ||
...(warning ? { warning } : {}), | ||
}; | ||
} |
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.
Same feedback here as above... can we use the method from ese_search/response_utils
here?
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.
Not very different, ese_search/response_utils
just has { total, loaded };
and sql doesn't have it. But I don't think is worth it to share anything here
src/plugins/data/server/search/strategies/sql_search/sql_search_strategy.test.ts
Show resolved
Hide resolved
}); | ||
}); | ||
}); | ||
} |
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.
Dang, it would be nice if we could add another test here that used something similar to shard_delay
for SQL requests to verify that the workflow works for submit/poll until completion.
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 agree, I don't think it is available now. Created an issue for elasticsearch to help us elastic/elasticsearch#85214
@lukasolson, thanks! should be fixed. An issue in the example itself |
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.
LGTM
@elasticmachine merge upstream |
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.
LGTM!
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]Module Count
Public APIs missing comments
Public APIs missing exports
Page load bundle
History
To update your PR or re-run it, just comment with: |
Summary
close #119280
This pr adds "low level" SQL search strategy that is implemented in a similar way how default
ESE_SEARCH_STRATEGY
strategy. The assumption is that it will be used in unified search efforts.It is aligned with default
ESE_SEARCH_STRATEGY
:Comparing to canvas's existing SQL search strategy:
Next steps after this pr