* Wraps a generated `_dntk.execute_sql*` call with the shared dataframe-formatter * prelude and, when the block defines a result variable name, an assignment plus a * trailing echo of that variable. Both SQL helpers share this logic, including the * `input_1` fallback applied to the result variab
(block: SqlBlock, executeSqlFunctionCall: string)
| 89 | * `input_1` fallback applied to the result variable name. |
| 90 | */ |
| 91 | function wrapSqlExecution(block: SqlBlock, executeSqlFunctionCall: string): string { |
| 92 | const pythonVariableName = block.metadata?.deepnote_variable_name |
| 93 | const sanitizedPythonVariableName = |
| 94 | pythonVariableName !== undefined ? sanitizePythonVariableName(pythonVariableName) || 'input_1' : undefined |
| 95 | |
| 96 | const dataFrameConfig = createDataFrameConfig(block) |
| 97 | |
| 98 | if (sanitizedPythonVariableName === undefined) { |
| 99 | return dedent` |
| 100 | ${dataFrameConfig} |
| 101 | |
| 102 | ${executeSqlFunctionCall} |
| 103 | ` |
| 104 | } |
| 105 | |
| 106 | return dedent` |
| 107 | ${dataFrameConfig} |
| 108 | |
| 109 | ${sanitizedPythonVariableName} = ${executeSqlFunctionCall} |
| 110 | ${sanitizedPythonVariableName} |
| 111 | ` |
| 112 | } |
| 113 | |
| 114 | export function isSqlBlock(block: DeepnoteBlock): block is SqlBlock { |
| 115 | return block.type === 'sql' |
no test coverage detected