Skip to content

Add option to convert nulls for BQ keys #472

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

Merged
merged 1 commit into from
Sep 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,16 @@ object BigDiffy extends Command with Serializable {
@tailrec
def get(xs: Array[String], i: Int, r: java.util.Map[String, AnyRef]): String =
if (i == xs.length - 1) {
r.get(xs(i)).toString
val valueOfKey = r.get(xs(i))
if (valueOfKey == null) {
logger.warn(
s"""Null value found for key: ${xs.mkString(".")}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably can reuse most of the existing avro code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do you also want to warn here? I was just thinking in our case it was like a valid category, so we had hundreds of thousands of rows like that (thus wanting to make it a command line argument before).

Copy link
Contributor

Choose a reason for hiding this comment

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

Yea I think it makes sense to warn here as well, I'd rather err on the side of being too noisy first and course correct later if it's a problem

| If this is not expected check your data or use a different key.""".stripMargin)
}

// Implicitly converts nulls to "null"
// Same as for Avro string case above
String.valueOf(valueOfKey)
} else {
get(xs, i + 1, r.get(xs(i)).asInstanceOf[java.util.Map[String, AnyRef]])
}
Expand Down