Skip to content
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-584]added validation for table is not empty #511

Closed
wants to merge 8 commits into from

Conversation

anubhav100
Copy link
Contributor

@anubhav100 anubhav100 commented Jan 9, 2017

when using either the carbon session or spark source it allows to create bucketed table even if table name in options is empty in this i am correcting this bug by validating table name

@CarbonDataQA
Copy link

Build Success with Spark 1.5.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/526/

@jackylk
Copy link
Contributor

jackylk commented Jan 9, 2017

Please provide description to this PR. Are you using CarbonSession or SparkSession? How to reproduce this bug?

@CarbonDataQA
Copy link

Build Success with Spark 1.5.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/531/

@@ -108,6 +111,9 @@ class CarbonSource extends CreatableRelationProvider

val dbName: String = parameters.getOrElse("dbName", CarbonCommonConstants.DATABASE_DEFAULT_NAME)
val tableName: String = parameters.getOrElse("tableName", "default_table")
if(tableName.isEmpty || tableName.contains("")) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can use StringUtils.isBlank utility function

@anubhav100
Copy link
Contributor Author

@jackylk sure done

@CarbonDataQA
Copy link

Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/575/

@@ -108,6 +110,10 @@ class CarbonSource extends CreatableRelationProvider

val dbName: String = parameters.getOrElse("dbName", CarbonCommonConstants.DATABASE_DEFAULT_NAME)
val tableName: String = parameters.getOrElse("tableName", "default_table")
if(org.apache.commons.lang.StringUtils.isBlank(tableName) ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add space after if
import this class at the beginning of file

@@ -108,6 +110,10 @@ class CarbonSource extends CreatableRelationProvider

val dbName: String = parameters.getOrElse("dbName", CarbonCommonConstants.DATABASE_DEFAULT_NAME)
val tableName: String = parameters.getOrElse("tableName", "default_table")
if(org.apache.commons.lang.StringUtils.isBlank(tableName) ||
org.apache.commons.lang.StringUtils.isWhitespace(tableName)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think isBlank will check whether it is space, so this is not required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylk but what if table name is "a n u b h a v" i think it will not check for its validation

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, it will fail in parser. It will not come to here

@@ -108,6 +110,10 @@ class CarbonSource extends CreatableRelationProvider

val dbName: String = parameters.getOrElse("dbName", CarbonCommonConstants.DATABASE_DEFAULT_NAME)
val tableName: String = parameters.getOrElse("tableName", "default_table")
if(org.apache.commons.lang.StringUtils.isBlank(tableName) ||
org.apache.commons.lang.StringUtils.isWhitespace(tableName)) {
throw new MalformedCarbonCommandException("INVALID TABLE NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can say it is empty table name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylk sure i am correcting it

@@ -108,6 +110,10 @@ class CarbonSource extends CreatableRelationProvider

val dbName: String = parameters.getOrElse("dbName", CarbonCommonConstants.DATABASE_DEFAULT_NAME)
val tableName: String = parameters.getOrElse("tableName", "default_table")
if(org.apache.commons.lang.StringUtils.isBlank(tableName) ||
org.apache.commons.lang.StringUtils.isWhitespace(tableName)) {
throw new MalformedCarbonCommandException("INVALID TABLE NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can say it is empty table name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylk i think emptyTableName will make less sense because it is not gurranted that it will be empty

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if the if check is true, it means the table name passing by user is blank

Copy link
Contributor

@jackylk jackylk Jan 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is misunderstanding, I suggest to give "the specified table name is blank" in the exception message. Not suggesting to change the variable name.

@CarbonDataQA
Copy link

Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/593/

@CarbonDataQA
Copy link

Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/594/

@anubhav100
Copy link
Contributor Author

@jackylk all issues are resolved

@CarbonDataQA
Copy link

Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/595/

val tableName: String = parameters.getOrElse("tableName", "default_table")
val emptyTableName: String = parameters.getOrElse("tableName", "default_table")
if (StringUtils.isBlank(emptyTableName)) {
throw new MalformedCarbonCommandException("INVALID TABLE NAME")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there is misunderstanding, I suggest to give "the specified table name is blank" in the exception message. Not suggesting to change the variable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylk oh get that now thats why i am asking you i m correcting it now

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jackylk corrected it sry for mistake

@CarbonDataQA
Copy link

Build Success with Spark 1.6.2, Please check CI http://136.243.101.176:8080/job/ApacheCarbonPRBuilder/599/

@asfgit asfgit closed this in 392bc29 Jan 14, 2017
@jackylk
Copy link
Contributor

jackylk commented Jan 14, 2017

LGTM
Thanks for working on this

Beyyes pushed a commit to Beyyes/carbondata that referenced this pull request Jul 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants