Skip to content

Commit 6ba4593

Browse files
committed
Add output redirection
1 parent 831c65b commit 6ba4593

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

singlestoredb/magics/run_shared.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,13 @@ def get_cells() -> Any:
103103
return
104104
for cell in nb.cells:
105105
if cell.cell_type == 'code':
106+
output_redirect = getattr(
107+
cell, 'metadata', {},
108+
).get('output_variable', '')
109+
if output_redirect:
110+
output_redirect = f' << {output_redirect}'
106111
if getattr(cell, 'metadata', {}).get('language', '') == 'sql':
107-
yield f'%%sql\n{cell.source}'
112+
yield f'%%sql{output_redirect}\n{cell.source}'
108113
else:
109114
yield cell.source
110115
else:

0 commit comments

Comments
 (0)