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

[HUDI-3008] Fixing HoodieFileIndex partition column parsing for nested fields #4308

Merged
merged 1 commit into from
Dec 22, 2021

Conversation

harsh1231
Copy link
Contributor

@harsh1231 harsh1231 commented Dec 14, 2021

Tips

What is the purpose of the pull request

  • HoodieFileIndex parses partition columns from schema. But it had a bug where nested fields were not considered. this patch is fixing the same.
  • If the table is partitioned on column a.b.c. which is struct in nature , loading hoodie table through spark was giving
    Cannot find column: 'a.b.c' in the schema
    Run Command : spark.read.format("hudi").load("<table_path>").show()
    This PR fixes above error by traversing schema struct recursively.

Brief change log

(for example:)

  • Modify AnnotationLocation checkstyle rule in checkstyle.xml

Verify this pull request

(Please pick either of the following options)

This pull request is a trivial rework / code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(example:)

  • Added integration tests for end-to-end.
  • Added HoodieClientWriteTest to verify the change.
  • Manually verified the change by running a job locally.

Committer checklist

  • Has a corresponding JIRA in PR title & commit

  • Commit message is descriptive of the change

  • CI is green

  • Necessary doc changes done or have another open PR

  • For large changes, please consider breaking it into sub-tasks under an umbrella JIRA.

@nsivabalan
Copy link
Contributor

Can we add tests please

@vinothchandar vinothchandar added this to Ready for Review in PR Tracker Board Dec 15, 2021
@harsh1231
Copy link
Contributor Author

Can we add tests please

added

* @param structField
* @return map of ( columns names -> StructField )
*/
private def convertStructToMap(structField : Either[StructField,StructType]) : Map[String,StructField] = {
Copy link
Contributor

Choose a reason for hiding this comment

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

@xiarixiaoyao : can you review this patch please.

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we name this method "generateNameFieldMap" or "fetchNameFieldMap"

Copy link
Contributor

Choose a reason for hiding this comment

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

yes, will do it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

generateNameFieldMap

Done

Copy link
Contributor

@nsivabalan nsivabalan left a comment

Choose a reason for hiding this comment

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

add more tests to get good coverage. looks good.

@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azure

PR Tracker Board automation moved this from Ready for Review to Nearing Landing Dec 16, 2021
Copy link
Contributor

@nsivabalan nsivabalan left a comment

Choose a reason for hiding this comment

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

LGTM except for one minor comment. Lets wait for a day to hear from @xiarixiaoyao as well.

@nsivabalan nsivabalan changed the title [HUDI-3008] Fixes bug in hoodieDeltaStreamer for nested partition lookup [HUDI-3008] Fixing HoodieFileIndex nested partition lookup Dec 16, 2021
@nsivabalan nsivabalan changed the title [HUDI-3008] Fixing HoodieFileIndex nested partition lookup [HUDI-3008] Fixing HoodieFileIndex partition column parsing for nested fields Dec 16, 2021
}
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

pls notice the code style of scala:
structField : Either[StructField,StructType] => structField: Either[StructField, StructType]
Map[String,StructField] => Map[String, StructField]
case (key :String , sf:StructField) => (field.name + "." + key , sf ) => case (key: String, sf: StructField) => (field.name + "." + key, sf )

@xiarixiaoyao
Copy link
Contributor

LGTM,
pls fix the code style thanks

@harsh1231
Copy link
Contributor Author

LGTM,
pls fix the code style thanks

Done

assert(fileIndex.getAllQueryPartitionPaths.get(0).partitionPath.equals("c"))
}


Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove the empty line here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azure

@nsivabalan
Copy link
Contributor

@harsh1231 : Can you rebase with latest master.

@harsh1231 harsh1231 force-pushed the HUDI-3008 branch 2 times, most recently from e890932 to 168fb8f Compare December 20, 2021 13:22
@harsh1231
Copy link
Contributor Author

@harsh1231 : Can you rebase with latest master.

Done

@vinothchandar
Copy link
Member

@xiarixiaoyao can you please take a look and either approve the PR or suggest next steps?

@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azure

@xiarixiaoyao
Copy link
Contributor

@harsh1231, Thank you very much for your contribution. I have a little suggestion: pls pay attention to scala's code style, once fixed, we can merge this pr.

* @return map of ( columns names -> StructField )
*/
private def generateNameFieldMap(structField : Either[StructField, StructType]) : Map[String, StructField] = {
structField match {
Copy link
Contributor

Choose a reason for hiding this comment

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

Please delete the space before ‘:’

private def generateNameFieldMap(structField : Either[StructField, StructType]) : Map[String, StructField] =>

private def generateNameFieldMap(structField: Either[StructField, StructType]): Map[String, StructField]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done, thanks for pointing out code style of scala.

@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azur

@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azure

1 similar comment
@xiarixiaoyao
Copy link
Contributor

@hudi-bot run azure

@nsivabalan nsivabalan self-assigned this Dec 22, 2021
@hudi-bot
Copy link

CI report:

Bot commands @hudi-bot supports the following commands:
  • @hudi-bot run azure re-run the last Azure build

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

6 participants