Skip to content

Conversation

@dilipbiswal
Copy link
Contributor

Check for partition column null-ability while building the partition spec.

@dilipbiswal
Copy link
Contributor Author

@davies Can you please let me know your comments.

@yhuai
Copy link
Contributor

yhuai commented Nov 26, 2015

ok to test

@yhuai
Copy link
Contributor

yhuai commented Nov 26, 2015

@dilipbiswal Do you know why it is broken?

@dilipbiswal
Copy link
Contributor Author

@yhuai Hi Yin, in the discoverPartitions method, we are trying to create the partition spec and are trying to cast a partition value to the corresponding user specified schema's column type. In case of null partition value the following code raises a null poiner exception in row.getString(i).

Cast(Literal.create(row.getString(i), StringType), userProvidedSchema.fields(i).dataType).eval()

in this fix i am trying to check for null first and create a null literal of string type as opposed to calling row.getString(). Hope it is okay .. Please let me know.

@SparkQA
Copy link

SparkQA commented Nov 26, 2015

Test build #46777 has finished for PR 10001 at commit af508de.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

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 it's better to check null in InternalRow.getString()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@davies Thanks for reviewing the change. In cases when we know in advance that schema does not allow nulls , sometimes we can skip this null check. By moving it to internalRow , would we loose the opportunity to optimize ? Pl. let me know.

Copy link
Contributor

Choose a reason for hiding this comment

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

The null-checking is cheap.

Or we could use Literal.create(row.getUTF8String(i), StringType), to avoid the conversion between String and UTF8String.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good @davies .Made the change. Thanks a lot for your feedback.

@yhuai
Copy link
Contributor

yhuai commented Nov 27, 2015

@dilipbiswal I guess I did not ask my question clearly. I meant why 1.5 is good but 1.6 is broken. There must be a change that exposed this issue.

@dilipbiswal
Copy link
Contributor Author

@yhuai Yeah.. this function discoverPartitions() was changed recently (10/22/2015) as part of spark-9735.

@davies
Copy link
Contributor

davies commented Nov 27, 2015

LGTM

@SparkQA
Copy link

SparkQA commented Nov 27, 2015

Test build #46791 has finished for PR 10001 at commit 4de7697.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

asfgit pushed a commit that referenced this pull request Nov 27, 2015
…ned by long column

Check for partition column null-ability while building the partition spec.

Author: Dilip Biswal <[email protected]>

Closes #10001 from dilipbiswal/spark-11997.

(cherry picked from commit a374e20)
Signed-off-by: Davies Liu <[email protected]>
@asfgit asfgit closed this in a374e20 Nov 27, 2015
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.

4 participants