Github user manishgupta88 commented on a diff in the pull request:
https://github.com/apache/carbondata/pull/2990#discussion_r242849005
--- Diff:
integration/spark-common/src/main/scala/org/apache/spark/sql/catalyst/CarbonDDLSqlParser.scala
---
@@ -1487,31 +1487,46 @@ abstract class CarbonDDLSqlParser extends
AbstractCarbonSparkSQLParser {
* @param values
* @return
*/
- def parseDataType(dataType: String, values: Option[List[(Int, Int)]]):
DataTypeInfo = {
+ def parseDataType(
+ dataType: String,
+ values: Option[List[(Int, Int)]],
+ isColumnRename: Boolean): DataTypeInfo = {
+ def validateAndGetDecimalDatatype: DataTypeInfo = {
+ var precision: Int = 0
+ var scale: Int = 0
+ if (values.isDefined) {
+ precision = values.get(0)._1
+ scale = values.get(0)._2
+ } else {
+ throw new MalformedCarbonCommandException("Decimal format provided
is invalid")
+ }
+ // precision should be > 0 and <= 38 and scale should be >= 0 and <=
38
+ if (precision < 1 || precision > 38) {
+ throw new MalformedCarbonCommandException("Invalid value for
precision")
+ } else if (scale < 0 || scale > 38) {
+ throw new MalformedCarbonCommandException("Invalid value for
scale")
+ }
+ DataTypeInfo("decimal", precision, scale)
+ }
+
dataType match {
case "bigint" | "long" =>
if (values.isDefined) {
throw new MalformedCarbonCommandException("Invalid data type")
}
DataTypeInfo(dataType)
case "decimal" =>
- var precision: Int = 0
- var scale: Int = 0
- if (values.isDefined) {
- precision = values.get(0)._1
- scale = values.get(0)._2
+ validateAndGetDecimalDatatype
--- End diff --
This change is not required. You can revert.
In default case handle for rename scenario
---