SQL: Add macro support in select case (#88514)
* Feat: timeGroup macro handling in VQB * Add tests * Add functions to SQL ds * Fix lint errors * Add feature toggle * Add rendering based on object * Fix lint * Fix CI failures * Fix tests * Address review comments * Add docs * Fix JSX runtime warnings * Remove docs part that mentions suggest more macros * Update docs/sources/shared/datasources/sql-query-builder-macros.md Co-authored-by: Jack Baldry <jack.baldry@grafana.com> * Add smoke test for this feature * lint * Add supported macros to influx * Add setupTests.ts to include in tsconfig.json * Import jest-dom instead of setupTests.ts --------- Co-authored-by: Jack Baldry <jack.baldry@grafana.com>
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { SelectableValue, toOption } from '@grafana/data';
|
||||
|
||||
import {
|
||||
QueryEditorExpressionType,
|
||||
QueryEditorFunctionExpression,
|
||||
QueryEditorFunctionParameterExpression,
|
||||
QueryEditorGroupByExpression,
|
||||
QueryEditorPropertyExpression,
|
||||
QueryEditorPropertyType,
|
||||
@@ -67,3 +70,18 @@ export function createFunctionField(functionName?: string): QueryEditorFunctionE
|
||||
parameters: [],
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the column value from a QueryEditorFunctionParameterExpression object.
|
||||
*
|
||||
* @param column - The QueryEditorFunctionParameterExpression object representing the column.
|
||||
* @returns The column value as a SelectableValue<string> or null if the column is undefined or null.
|
||||
*/
|
||||
export function getColumnValue(
|
||||
column?: QueryEditorFunctionParameterExpression | QueryEditorFunctionExpression
|
||||
): SelectableValue<string> | null {
|
||||
if (column?.name) {
|
||||
return toOption(column.name);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user