Skip to content

Conversation

@danny0405
Copy link
Contributor

Change Logs

Fix the bulk_insert for Flink MDT initialization after #8684 .

Impact

none

Risk level (write none, low medium or high below)

none

Documentation Update

Describe any necessary documentation update if there is any new feature, config, or user-facing change

  • The config description must be updated if new configs are added or the default value of the configs are changed
  • Any new feature or user-facing change requires updating the Hudi website. Please create a Jira ticket, attach the
    ticket number here and follow the instruction to make
    changes to the website.

Contributor's checklist

  • Read through contributor's guide
  • Change Logs and Impact were stated clearly
  • Adequate tests were added if applicable
  • CI passed

@danny0405 danny0405 added engine:flink Flink integration metadata labels Jun 9, 2023
@danny0405
Copy link
Contributor Author

@hudi-bot run azure

@hudi-bot
Copy link
Collaborator

hudi-bot commented Jun 9, 2023

CI report:

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

@danny0405
Copy link
Contributor Author

.collect(Collectors.groupingBy(r -> r.getCurrentLocation().getFileId()));
return preppedRecordsByFileId.values().stream().parallel().map(records -> {
HoodieWriteMetadata<List<WriteStatus>> result;
records.get(0).getCurrentLocation().setInstantTime("I");
Copy link
Member

Choose a reason for hiding this comment

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

Why setting instantTime to I? Should it not be instantTime passed to the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Flink relies on this flag to distinguish which write handle to use. A little hacky but it's the minimum change right now.

? writeClient.upsertPreppedRecords(preppedRecordList, instantTime)
: Collections.emptyList();
List<WriteStatus> statuses = isInitializing
? writeClient.bulkInsertPreppedRecords(preppedRecordList, instantTime, Option.empty())
Copy link
Contributor

Choose a reason for hiding this comment

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

major reason to use bulkInsert is that, we use a custom partitioner based on file group and so the spark tasks will be such that, each spark task will get records pertaining to one file group of interest.

we can try to incorporate that as well. esply with RLI, record mapping to file groups is based on hash. So, we can't have diff set of records routed to one spark task.

Copy link
Contributor Author

@danny0405 danny0405 Jun 10, 2023

Choose a reason for hiding this comment

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

Flink does not support flexible partitioner like Spark do, but we can still get some benefits because writing Hfiles directly for initilization of MDT is more efficient. For example, when user enable the MDT for a existing table and there are plenty of metadata records to bootstrap with.

Copy link
Contributor

Choose a reason for hiding this comment

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

records to file group mapping is deterministic and we can have only one file written per file group. for eg, if we instanttiate col stats with 4 file groups, we should spin up 4 spark tasks and each spark task should get records pertaining to the file group of interest (remember records are mapped to file group based on hashing). So, if one spark task gets records for all file groups, then we might end up w/ n*m files (where n is no of spark tasks and m is number of file groups) which may not work. we need only m files created and m spark tasks should spin up where each spark tasks writes to just 1 file group.
hope that makes sense.

Copy link
Contributor Author

@danny0405 danny0405 Jun 11, 2023

Choose a reason for hiding this comment

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

What the spark partitioner does is to repartition the records by the file group (index) to avoid concurrent write from different tasks into one file group. Flink already does that, even though it is parallelized in single JVM process.

Copy link
Contributor

Choose a reason for hiding this comment

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

if its already taken care of, then we are good

@danny0405 danny0405 merged commit d1831b0 into apache:master Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

engine:flink Flink integration

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants