Skip to content

Commit

Permalink
remove sample size in query string but use advanced setting
Browse files Browse the repository at this point in the history
Signed-off-by: abbyhu2000 <[email protected]>
  • Loading branch information
abbyhu2000 committed Feb 7, 2025
1 parent 2ff6f19 commit d3fe9fb
Show file tree
Hide file tree
Showing 9 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const queriesTestSuite = () => {
// Default SQL query should be set
cy.waitForLoader(true);
cy.getElementByTestId(`osdQueryEditor__multiLine`).contains(
`SELECT * FROM ${INDEX_WITH_TIME_1}* LIMIT 10`
`SELECT * FROM ${INDEX_WITH_TIME_1}`
);
cy.getElementByTestId(`queryResultCompleteMsg`).should('be.visible');

Expand Down
2 changes: 1 addition & 1 deletion cypress/utils/apps/query_enhancements/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const getDefaultQuery = (datasetName, language) => {
case QueryLanguages.PPL.name:
return `source = ${datasetName}`;
case QueryLanguages.SQL.name:
return `SELECT * FROM ${datasetName} LIMIT 10`;
return `SELECT * FROM ${datasetName}`;
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const indexPatternTypeConfig: DatasetTypeConfig = {
title: i18n.translate('data.indexPatternType.sampleQuery.basicSQLQuery', {
defaultMessage: 'Sample query for SQL',
}),
query: `SELECT * FROM ${dataset.title} LIMIT 10`,
query: `SELECT * FROM ${dataset.title}`,
},
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const indexTypeConfig: DatasetTypeConfig = {
title: i18n.translate('data.indexType.sampleQuery.basicSQLQuery', {
defaultMessage: 'Sample query for SQL',
}),
query: `SELECT * FROM ${dataset.title} LIMIT 10`,
query: `SELECT * FROM ${dataset.title}`,
},
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/query_enhancements/public/datasets/s3_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export const s3TypeConfig: DatasetTypeConfig = {
title: i18n.translate('queryEnhancements.s3Type.sampleQuery.basicSQLQuery', {
defaultMessage: 'Sample query for SQL',
}),
query: `SELECT * FROM ${dataset.title} LIMIT 10`,
query: `SELECT * FROM ${dataset.title}`,
},
];
}
Expand Down
3 changes: 1 addition & 2 deletions src/plugins/query_enhancements/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,7 @@ export class QueryEnhancementsPlugin
startServices: core.getStartServices(),
usageCollector: data.search.usageCollector,
}),
getQueryString: (currentQuery: Query) =>
`SELECT * FROM ${currentQuery.dataset?.title} LIMIT 10`,
getQueryString: (currentQuery: Query) => `SELECT * FROM ${currentQuery.dataset?.title}`,
fields: { sortable: false, filterable: false, visualizable: false },
docLink: {
title: i18n.translate('queryEnhancements.sqlLanguage.docLink', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
const query: Query = request.body.query;
const aggConfig: QueryAggConfig | undefined = request.body.aggConfig;
const rawResponse: any = await pplFacet.describeQuery(context, request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
const query: Query = request.body.query;
const rawResponse: any = await sqlFacet.describeQuery(context, request);

Expand Down
1 change: 1 addition & 0 deletions src/plugins/query_enhancements/server/utils/facet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export class Facet {
const { format, lang } = request.body;
const params = {
body: {
fetch_size: request.body.fetch_size,
query: query.query,
...(meta?.name && { datasource: meta.name }),
...(meta?.sessionId && {
Expand Down

0 comments on commit d3fe9fb

Please sign in to comment.