Evinnt
Evinnt

Reputation: 31

Databricks "extraneous input expecting EOF" error

This took me a while to figure out so I thought I'd share to save someone else the pain. This is obviously dummy code to illustrate the issue.

This doesn't work:

%sql

Select 'A' as A -- I won't need this
  , '1' as B;

Select 'Magic';

Error message:

Error in SQL statement: ParseException: 
extraneous input 'Select' expecting {<EOF>, ';'}(line 4, pos 0)

== SQL ==
Select 'A' as A -- I won't need this
  , '1' as B;

Select 'Magic';
^^^

This does work:

%sql

Select 'A' as A -- I wont need this
  , '1' as B;

Select 'Magic';

And the difference in the single-quote in the comment on line 3.

Upvotes: 3

Views: 14658

Answers (1)

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12788

When you use single-quote in the comment, you need to pass the comment in double quotes.

Example: -- I won't need this it should be -- "I won't need this"

enter image description here

Upvotes: 2

Related Questions