-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Key by paneindex and reshuffle before loading files. #34324
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -664,19 +664,14 @@ def start_bundle(self): | |
self.pending_jobs = [] | ||
self.schema_cache = {} | ||
|
||
def process( | ||
self, | ||
element, | ||
load_job_name_prefix, | ||
pane_info=beam.DoFn.PaneInfoParam, | ||
*schema_side_inputs): | ||
def process(self, element, load_job_name_prefix, *schema_side_inputs): | ||
# Each load job is assumed to have files respecting these constraints: | ||
# 1. Total size of all files < 15 TB (Max size for load jobs) | ||
# 2. Total no. of files in a single load job < 10,000 | ||
# This assumption means that there will always be a single load job | ||
# triggered for each partition of files. | ||
destination = element[0] | ||
partition_key, files = element[1] | ||
partition_key, files, pane_index = element[1] | ||
|
||
if callable(self.schema): | ||
schema = self.schema(destination, *schema_side_inputs) | ||
|
@@ -705,7 +700,7 @@ def process( | |
table_reference.datasetId, | ||
table_reference.tableId)) | ||
job_name = '%s_%s_pane%s_partition%s' % ( | ||
load_job_name_prefix, destination_hash, pane_info.index, partition_key) | ||
load_job_name_prefix, destination_hash, pane_index, partition_key) | ||
_LOGGER.info('Load job has %s files. Job name is %s.', len(files), job_name) | ||
|
||
create_disposition = self.create_disposition | ||
|
@@ -1104,6 +1099,8 @@ def _load_data( | |
# Load data using temp tables | ||
trigger_loads_outputs = ( | ||
partitions_using_temp_tables | ||
| "KeyByPaneIndexWithTempTables" >> beam.ParDo(KeyByPaneIndex()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need to worry about the update compatibility? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I will make those changes before merging this |
||
| "ReshuffleBeforeLoadWithTempTables" >> beam.Reshuffle() | ||
| "TriggerLoadJobsWithTempTables" >> beam.ParDo( | ||
TriggerLoadJobs( | ||
schema=self.schema, | ||
|
@@ -1186,6 +1183,8 @@ def _load_data( | |
# Load data directly to destination table | ||
destination_load_job_ids_pc = ( | ||
partitions_direct_to_destination | ||
| "KeyByPaneIndexWithoutTempTables" >> beam.ParDo(KeyByPaneIndex()) | ||
| "ReshuffleBeforeLoadWithoutTempTables" >> beam.Reshuffle() | ||
| "TriggerLoadJobsWithoutTempTables" >> beam.ParDo( | ||
TriggerLoadJobs( | ||
schema=self.schema, | ||
|
@@ -1313,3 +1312,9 @@ def expand(self, pcoll): | |
self.DESTINATION_FILE_PAIRS: all_destination_file_pairs_pc, | ||
self.DESTINATION_COPY_JOBID_PAIRS: destination_copy_job_ids_pc, | ||
} | ||
|
||
|
||
class KeyByPaneIndex(beam.DoFn): | ||
def process(self, element, pane_info=beam.DoFn.PaneInfoParam): | ||
destination, (partition_key, files) = element | ||
return [(destination, (partition_key, files, pane_info.index))] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is very similar to a first attempt to fix the same issue in Java - #28272 add pane info in "WritePartition" so it is survived in ReShuffle. In earlier discussion it was decided to go with fixing ReShuffle itself (and that PR was closed). Shall we go for same decision here? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. One of the original concern was upgrade compatibility. However because a ReShuffle is added here, pipeline graph will be changed anyways There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does it make sense to do this keying by pane in the upstream I think that'll make it easier to revert this quick fix when Reshuffle gets fixed (which should be the longterm solution) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this safe to remove
pane_info
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still using pane info, but just adding it earlier as part of the key that gets processed by TriggerLoadJob