(code: string, signal?: AbortSignal)
| 49 | } |
| 50 | |
| 51 | async validateDSL(code: string, signal?: AbortSignal): Promise<string> { |
| 52 | throwIfAborted(signal); |
| 53 | if (!code.trim()) throw new Error('Python query must contain code'); |
| 54 | if (code.includes('\0')) throw new Error('Python query contains a NUL character'); |
| 55 | // Compile in the execution environment without running the user's code or loading source data. |
| 56 | // https://docs.python.org/3/library/functions.html#compile |
| 57 | const script = `import json |
| 58 | compile(json.loads(${JSON.stringify(JSON.stringify(code))}), '<ava-query>', 'exec') |
| 59 | print('{"data":[],"schema":[],"rowCount":0}') |
| 60 | `; |
| 61 | if (this.execute) { |
| 62 | await (signal ? this.execute(script, signal) : this.execute(script)); |
| 63 | } else { |
| 64 | const { createPythonExecutor } = await import('../interpreter/python/util/execute'); |
| 65 | await createPythonExecutor(30_000)(script, 64 * 1024, signal); |
| 66 | } |
| 67 | throwIfAborted(signal); |
| 68 | return code; |
| 69 | } |
| 70 | } |
nothing calls this directly
no test coverage detected