Line data Source code
1 : import * as React from 'react';
2 :
3 : import { ComputeQueryExecutionProvider } from '../compute/compute_query_execution.js';
4 : import type { ComputeQueryExecution } from '../compute/computation_tasks.js';
5 : import { computationTaskTitle, type TaskVariant } from '../compute/computation_types.js';
6 : import { QueryType } from '../query/query_execution_state.js';
7 : import { executeTrackedQuery } from '../query/tracked_query_execution.js';
8 : import { useShellQueryHistory } from './shell_query_history.js';
9 :
10 1 : const LOG_CTX = 'scheduler';
11 :
12 1 : export function ShellComputeQueryExecutionProvider(props: React.PropsWithChildren) {
13 1 : const queryExecutions = useShellQueryHistory();
14 1 : const createExecution = React.useCallback((task: TaskVariant) => {
15 1 : const execution: ComputeQueryExecution = (query, execute) => executeTrackedQuery({
16 1 : query,
17 1 : tracker: queryExecutions,
18 1 : metadata: {
19 1 : queryType: QueryType.INTERNAL_SQLFRAME,
20 1 : title: computationTaskTitle(task),
21 1 : description: null,
22 1 : issuer: 'SQLFrame',
23 1 : userProvided: false,
24 1 : },
25 1 : execute: () => execute(null),
26 1 : errorTarget: LOG_CTX,
27 1 : });
28 1 : return execution;
29 1 : }, [queryExecutions]);
30 :
31 1 : return (
32 1 : <ComputeQueryExecutionProvider createExecution={createExecution}>
33 1 : {props.children}
34 1 : </ComputeQueryExecutionProvider>
35 : );
36 1 : }
|