In the CTE you can't do a CREATE.
It expects an expression in the form of expression_name [ ( column_name [ , ... ] ) ] [ AS ] ( query )
where expression_name specifies a name for the common table expression.
If you want to create a view from a CTE, you can do this:
-- CTE in CREATE VIEW statement
CREATE VIEW v AS
WITH t(a, b, c, d) AS (SELECT 1, 2, 3, 4)
SELECT * FROM t;
SELECT * FROM v;
+---+---+---+---+
| a| b| c| d|
+---+---+---+---+
| 1| 2| 3| 4|
+---+---+---+---+
PS. snippet from the Spark documentation