New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[CARBONDATA-4014] Support Change Column Comment #3960
Conversation
Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4228/ |
Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2484/ |
d0ddbc5
to
8fe2cb6
Compare
Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4229/ |
Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2485/ |
53ebd84
to
67d3789
Compare
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4230/ |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2486/ |
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4232/ |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2488/ |
LGTM |
@@ -366,7 +366,7 @@ class AlterTableValidationTestCase extends QueryTest with BeforeAndAfterAll { | |||
sql("alter table default.restructure change decimalfield deciMalfield Decimal(11,3)") | |||
sql("alter table default.restructure change decimalfield deciMalfield Decimal(12,3)") | |||
intercept[ProcessMetaDataException] { | |||
sql("alter table default.restructure change decimalfield deciMalfield Decimal(12,3)") | |||
sql("alter table default.restructure change decimalfield deciMalfield Decimal(12,2)") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why change here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Before this pr, we don't allow change dataype to same precision, which is actually allowed now for 2 reason:
- Be consistent with hive and spark;
- In 'CHANGE COLUMN' command. we support just change comment without renaming and changing datatype;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- do we support alter column without any change?
- how to remove comment from column
@@ -169,7 +169,8 @@ case class AlterTableDataTypeChangeModel(dataTypeInfo: DataTypeInfo, | |||
tableName: String, | |||
columnName: String, | |||
newColumnName: String, | |||
isColumnRename: Boolean) | |||
isColumnRename: Boolean, | |||
newColumnComment: Option[String]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better to provide a default value: None.
it can avoid other unnecessary changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified code according to you suggestion.
if (col.getColumnName.equalsIgnoreCase(oldColumnName)) { | ||
throw new MalformedCarbonCommandException( | ||
s"Column Rename Operation failed. Renaming or ChangeType or " + | ||
s"ChangeComment the partition column $newColumnName is not " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about to support changing comments of partition columns?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is really hard to support changing comments of partition columns, as spark and hive also don't support.
https://stackoverflow.com/questions/57871294/how-to-add-edit-the-comment-of-a-partitioned-column-in-hive-table
} else { | ||
throw new MalformedCarbonCommandException("Data type provided is invalid.") | ||
} | ||
DataTypeInfo(DataTypeConverterUtil.convertToCarbonType(dataType).getName.toLowerCase) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the parameter isColumnRename of this method needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need. It is useless to throw MalformedCarbonCommandException("Data type provided is invalid.")
CarbonAlterTableColumnRenameCommand.validateColumnDataType will validate the given datatype.
I have delete the parameter isColumnRename. Please have a check
if (changeColumnCommand.newColumn.metadata != null && | ||
changeColumnCommand.newColumn.metadata.contains(CarbonCommonConstants.COLUMN_COMMENT)) { | ||
newColumnComment = Some(changeColumnCommand. | ||
newColumn.metadata.getString(CarbonCommonConstants.COLUMN_COMMENT)) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is already a varibale "newColumn" that can be used above, or it is better to make "changeColumnCommand.newColumn.metadata" as a variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified code according to you suggestion.
67d3789
to
b6a1751
Compare
|
if alter column change nothing, the command should return directly without execution. |
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4252/ |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2507/ |
b6a1751
to
f2fff60
Compare
I have modified code according to you suggestion. |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2517/ |
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4262/ |
@@ -258,7 +262,7 @@ private[sql] case class CarbonAlterTableColRenameDataTypeChangeCommand( | |||
} | |||
} catch { | |||
case e: Exception => | |||
if (carbonTable != null) { | |||
if ( carbonTable != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there has a blank between the '(' and carbonTable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have modified code according to you suggestion.
f2fff60
to
a5f372b
Compare
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2520/ |
Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4265/ |
retest this please |
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4266/ |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2521/ |
LGTM |
col => | ||
if (col.getColumnName.equalsIgnoreCase(oldColumnName)) { | ||
throw new MalformedCarbonCommandException( | ||
s"Change Column Operation failed. Renaming or ChangeType or " + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please change this to
throw new InvalidOperationException("Alter on partition columns is not supported")
And add a test case for this
a5f372b
to
45d0c0f
Compare
Build Failed with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4268/ |
Build Failed with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2523/ |
Why is this PR needed? Now, we support add column comment in "CREATE TABLE" and "ADD COLUMN". but do not support alter comment of the column, which shall be support in 'CHANGE COLUMN' What changes were proposed in this PR? Support "ALTER TABLE table_name CHANGE [COLUMN] col_name col_name data_type [COMMENT col_comment]" Does this PR introduce any user interface change? Yes. add CHANGE COLUMN explaination in the ddl document. Is any new testcase added? Yes
45d0c0f
to
de35992
Compare
Build Success with Spark 2.3.4, Please check CI http://121.244.95.60:12545/job/ApacheCarbonPRBuilder2.3/4269/ |
Build Success with Spark 2.4.5, Please check CI http://121.244.95.60:12545/job/ApacheCarbon_PR_Builder_2.4.5/2524/ |
LGTM |
Why is this PR needed?
Now, we support add column comment in "CREATE TABLE" and "ADD COLUMN". but do not support alter comment of the column, which shall be support in 'CHANGE COLUMN'
What changes were proposed in this PR?
Support "ALTER TABLE table_name CHANGE [COLUMN] col_name col_name data_type [COMMENT col_comment]"
Does this PR introduce any user interface change?
Is any new testcase added?