Github user jackylk commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/1665#discussion_r157473214
--- Diff:
integration/spark2/src/main/scala/org/apache/spark/sql/parser/CarbonSparkSqlParser.scala
---
@@ -210,13 +208,40 @@ class CarbonHelperSqlAstBuilder(conf: SQLConf,
parser: CarbonSpark2SqlParser)
}
}
- val fields = parser.getFields(cols ++ partitionByStructFields)
+ var fields = parser.getFields(cols ++ partitionByStructFields)
val options = new CarbonOption(properties)
// validate tblProperties
val bucketFields = parser.getBucketFields(tableProperties, fields,
options)
validateStreamingProperty(options)
+ // validate for create table as select
+ val selectQuery = Option(query).map(plan)
+ selectQuery match {
+ case Some(q) =>
+ // create table as select does not allow creation of partitioned
table
+ if (partitionFields.nonEmpty) {
+ val errorMessage = "A Create Table As Select (CTAS) statement is
not allowed to " +
+ "create a partitioned table using Carbondata
file formats."
+ operationNotAllowed(errorMessage, partitionColumns)
+ }
+ // create table as select does not allow to explicitly specify
schema
+ if (fields.nonEmpty) {
+ operationNotAllowed(
+ "Schema may not be specified in a Create Table As Select
(CTAS) statement", columns)
+ }
+ // create table as select does not allow specifying any table
properties
+ if (tableProperties.nonEmpty) {
--- End diff --
I think this can be allowed, it is also in Hive syntax
---