Spark Dataset createOrReplaceTempView ViewName restrictions

Viewed 1510

Call createOrReplaceTempView on Spark Dataset with "123D" as name of the view and get:

org.apache.spark.sql.AnalysisException: Invalid view name: 123D;

Whereas with parameter "123Z" everything is Ok.

Is there any restrictions on parameter of createOrReplaceTempView?

Spark version: 2.3.1

1 Answers

A trailing D after a number has a special meaning which indicates that the preceding number should be of double type. See the docs for a list of possible letters, including L, S, Y, D, F, BD.

It's perhaps not a good practice to name your views/tables like that, but if you really want to do it, you can add backticks, e.g.

df.createOrReplaceTempView('`123D`')

And you also need to add backticks when you do a select, e.g.

spark.sql("select * from `123D`")
Related