Skip to content

Commit 70f6695

Browse files
fix(staging): recognize streaming input after SQL comments
Signed-off-by: Aakash Saravanan <aakash.saravanan@databricks.com>
1 parent 8ab0fa6 commit 70f6695

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/databricks/sql/backend/kernel/client.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -572,9 +572,9 @@ def execute_command(
572572
try:
573573
stripped_sql = _strip_leading_sql_comments(operation)
574574
staging_verb = _staging_verb(stripped_sql)
575-
if re.match(
576-
r"""PUT\s*(['"])__input_stream__\1""",
577-
stripped_sql,
575+
if staging_verb == "PUT" and re.match(
576+
r"""(['"])__input_stream__\1""",
577+
_strip_leading_sql_comments(stripped_sql[3:]),
578578
re.IGNORECASE,
579579
):
580580
raise NotSupportedError(

‎tests/unit/test_kernel_client.py‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,8 @@ def test_staging_verb_matches_only_the_leading_statement(operation, expected):
953953
"/* upload */ PUT '__input_stream__' INTO '/Volumes/c/s/v/file'",
954954
"/* outer /* inner */ outer */ PUT '__input_stream__' INTO '/Volumes/c/s/v/file'",
955955
"PUT'__input_stream__' INTO '/Volumes/c/s/v/file'",
956+
"PUT /* upload */ '__input_stream__' INTO '/Volumes/c/s/v/file'",
957+
"PUT\n-- upload\n'__input_stream__' INTO '/Volumes/c/s/v/file'",
956958
"/* upload */ PUT\"__input_stream__\" INTO '/Volumes/c/s/v/file'",
957959
],
958960
)

0 commit comments

Comments
 (0)