[SPARK-2917] [SQL] Avoid table creation in logical plan analyzing for CTAS

Semantically, if `databaseName == None`, then we need to resolve the `databaseName`.