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