3

I'm attempting to create a temp view in Spark SQL using a with the statement:

create temporary view cars as (
    with models as (
       select 'abc' as model
    )
    select model from models
)

But this error is thrown:

error in SQL statement: ParseException: 
mismatched input 'with' expecting {'(', 'SELECT', 'FROM', 'DESC', 'VALUES', 'TABLE', 'INSERT', 'DESCRIBE', 'MAP', 'MERGE', 'UPDATE', 'REDUCE'}(line 2, pos 8)

== SQL ==
create temporary view cars as (
        with models as (
--------^^^
           select 'abc' as model
        )
        select model from models
    )

1 Answer 1

9

Removing brackets after first as makes it work:

create temporary view cars as 
with models as (
   select 'abc' as model
)
select model from models
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.