@@ -229,13 +229,12 @@ def without_sql_comment(parser, line):
229
229
230
230
args = _option_strings_from_parser (parser )
231
231
pattern = re .compile (r'([\'"])(.*?)\1' )
232
- temp_line = pattern .sub (lambda x : x .group ().replace (" " , "" ), line )
233
- spaces_removed = len (line ) - len (temp_line )
232
+ line = pattern .sub (lambda match : match .group ().replace (" " , "@@SPACE@@" ), line )
234
233
result = itertools .takewhile (
235
- lambda word : (not word .startswith ("--" )) or (word in args ), temp_line .split ()
234
+ lambda word : (not word .startswith ("--" )) or (word in args ), line .split ()
236
235
)
237
236
result = " " .join (result )
238
- result = line [: len ( result ) + spaces_removed ]
237
+ result = result . replace ( "@@SPACE@@" , " " )
239
238
return result
240
239
241
240
@@ -278,7 +277,13 @@ def split_args_and_sql(line):
278
277
# If any SQL commands are found in the line, we split the line into args and sql.
279
278
# Note: lines without SQL commands will not be split
280
279
# ex. %sql duckdb:// or %sqlplot boxplot --table data.csv
281
- if any (cmd in line_no_filenames for cmd in SQL_COMMANDS ) or any (
280
+ if "<<" in line :
281
+ [before_assign , after_assign ] = line .split ("<<" )
282
+ result_var = before_assign .split ()[- 1 ]
283
+ arg_line = " " .join (before_assign .split ()[:- 1 ])
284
+ sql_line = result_var + " << " + after_assign
285
+
286
+ elif any (cmd in line_no_filenames for cmd in SQL_COMMANDS ) or any (
282
287
cmd .upper () in line_no_filenames for cmd in SQL_COMMANDS
283
288
):
284
289
# Identify beginning of sql query using keywords
0 commit comments