mirror of
https://github.com/openobserve/openobserve.git
synced 2026-11-05 16:10:43 +00:00
fix: dashboard drilldown support to logs page, getting ` and query of unions not getting passed properly (#5525)
<!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Improved SQL query generation logic for drilldown functionality - Enhanced query construction to handle table aliases more effectively - Sanitized query strings by replacing backticks with double quotes <!-- end of auto-generated comment: release notes by coderabbit.ai -->
This commit is contained in:
@@ -837,10 +837,18 @@ export default defineComponent({
|
||||
if (!parser) {
|
||||
await importSqlParser();
|
||||
}
|
||||
|
||||
|
||||
const ast = await parseQuery(originalQuery, parser);
|
||||
if (!ast) return;
|
||||
|
||||
const tableAliases = ast.from
|
||||
?.filter((fromEntry: any) => fromEntry.as)
|
||||
.map((fromEntry: any) => fromEntry.as);
|
||||
|
||||
const aliasClause = tableAliases?.length
|
||||
? ` AS ${tableAliases.join(", ")}`
|
||||
: "";
|
||||
|
||||
const breakdownColumn = breakdown[0]?.column;
|
||||
const breakdownValue = drilldownParams[0]?.seriesName;
|
||||
const whereClause = buildWhereClause(
|
||||
@@ -849,11 +857,13 @@ export default defineComponent({
|
||||
breakdownValue,
|
||||
);
|
||||
|
||||
const modifiedQuery =
|
||||
let modifiedQuery =
|
||||
drilldownData.data.logsMode === "auto"
|
||||
? `SELECT * FROM "${streamName}" ${whereClause}`
|
||||
? `SELECT * FROM "${streamName}"${aliasClause} ${whereClause}`
|
||||
: drilldownData.data.logsQuery;
|
||||
|
||||
modifiedQuery = modifiedQuery.replace(/`/g, '"');
|
||||
|
||||
const encodedQuery: any = b64EncodeUnicode(modifiedQuery);
|
||||
|
||||
const pos = window.location.pathname.indexOf("/web/");
|
||||
|
||||
Reference in New Issue
Block a user