-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[HUDI-915] Add missing partititonpath to records COW #8666
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
codope
merged 12 commits into
apache:master
from
jonvex:fix_bootstrap_filegroup_update_lost_partition
May 17, 2023
Merged
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
5d1b90a
COW working but found new MOR issue
66dd335
fixed failing test and resolved checkstyle
495d460
added tests for nonpartitioned table
1ea8180
add multiple partition tests, timeline server causes some errors so i…
bfa1909
add todo
840cfab
fix checkstyle
1b2f284
added lock to bootstrap file map and fixed failing test
bb7e42e
Merge branch 'apache:master' into fix_bootstrap_filegroup_update_lost…
jonvex cc420c8
got rid of timeline changes because that should be in a different pr
62deeb2
Merge branch 'apache:master' into fix_bootstrap_filegroup_update_lost…
jonvex c20d278
addressed pr comments
6ba0740
addressed 2nd round of pr comments
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...ent/hudi-spark-client/src/main/java/org/apache/hudi/client/utils/SparkPartitionUtils.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hudi.client.utils; | ||
|
|
||
| import org.apache.hudi.AvroConversionUtils; | ||
| import org.apache.hudi.HoodieSparkUtils; | ||
| import org.apache.hudi.SparkAdapterSupport$; | ||
| import org.apache.hudi.common.util.Option; | ||
| import org.apache.hudi.hadoop.CachingPath; | ||
|
|
||
| import org.apache.avro.Schema; | ||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.spark.sql.execution.datasources.SparkParsePartitionUtil; | ||
| import org.apache.spark.sql.internal.SQLConf; | ||
|
|
||
| public class SparkPartitionUtils { | ||
|
|
||
| public static Object[] getPartitionFieldVals(Option<String[]> partitionFields, | ||
| String partitionPath, | ||
| String basePath, | ||
| Schema writerSchema, | ||
| Configuration hadoopConf) { | ||
| if (!partitionFields.isPresent()) { | ||
| return new Object[0]; | ||
| } | ||
| SparkParsePartitionUtil sparkParsePartitionUtil = SparkAdapterSupport$.MODULE$.sparkAdapter().getSparkParsePartitionUtil(); | ||
| return HoodieSparkUtils.parsePartitionColumnValues( | ||
| partitionFields.get(), | ||
| partitionPath, | ||
| new CachingPath(basePath), | ||
| AvroConversionUtils.convertAvroSchemaToStructType(writerSchema), | ||
| hadoopConf.get("timeZone", SQLConf.get().sessionLocalTimeZone()), | ||
| sparkParsePartitionUtil, | ||
| hadoopConf.getBoolean("spark.sql.sources.validatePartitionColumns", true)); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
hudi-common/src/main/java/org/apache/hudi/io/storage/HoodieBootstrapRecordIterator.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,82 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.hudi.io.storage; | ||
|
|
||
| import org.apache.hudi.common.model.HoodieRecord; | ||
| import org.apache.hudi.common.model.MetadataValues; | ||
| import org.apache.hudi.common.util.Option; | ||
| import org.apache.hudi.common.util.collection.ClosableIterator; | ||
|
|
||
| import org.apache.avro.Schema; | ||
|
|
||
| import static org.apache.hudi.common.util.ValidationUtils.checkState; | ||
|
|
||
| public abstract class HoodieBootstrapRecordIterator<T> implements ClosableIterator<HoodieRecord<T>> { | ||
|
|
||
| protected ClosableIterator<HoodieRecord<T>> skeletonIterator; | ||
| protected ClosableIterator<HoodieRecord<T>> dataFileIterator; | ||
| private final Option<String[]> partitionFields; | ||
| private final Object[] partitionValues; | ||
|
|
||
| protected Schema schema; | ||
|
|
||
| public HoodieBootstrapRecordIterator(ClosableIterator<HoodieRecord<T>> skeletonIterator, | ||
| ClosableIterator<HoodieRecord<T>> dataFileIterator, | ||
| Schema schema, | ||
| Option<String[]> partitionFields, | ||
| Object[] partitionValues) { | ||
| this.skeletonIterator = skeletonIterator; | ||
| this.dataFileIterator = dataFileIterator; | ||
| this.schema = schema; | ||
| this.partitionFields = partitionFields; | ||
| this.partitionValues = partitionValues; | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
|
|
||
| } | ||
|
|
||
| @Override | ||
| public boolean hasNext() { | ||
| checkState(skeletonIterator.hasNext() == dataFileIterator.hasNext()); | ||
| return skeletonIterator.hasNext(); | ||
| } | ||
|
|
||
| @Override | ||
| public HoodieRecord<T> next() { | ||
| HoodieRecord<T> dataRecord = dataFileIterator.next(); | ||
| HoodieRecord<T> skeletonRecord = skeletonIterator.next(); | ||
| HoodieRecord<T> ret = dataRecord.prependMetaFields(schema, schema, | ||
| new MetadataValues().setCommitTime(skeletonRecord.getRecordKey(schema, HoodieRecord.COMMIT_TIME_METADATA_FIELD)) | ||
| .setCommitSeqno(skeletonRecord.getRecordKey(schema, HoodieRecord.COMMIT_SEQNO_METADATA_FIELD)) | ||
| .setRecordKey(skeletonRecord.getRecordKey(schema, HoodieRecord.RECORD_KEY_METADATA_FIELD)) | ||
| .setPartitionPath(skeletonRecord.getRecordKey(schema, HoodieRecord.PARTITION_PATH_METADATA_FIELD)) | ||
| .setFileName(skeletonRecord.getRecordKey(schema, HoodieRecord.FILENAME_METADATA_FIELD)), null); | ||
| if (partitionFields.isPresent()) { | ||
| for (int i = 0; i < partitionValues.length; i++) { | ||
| int position = schema.getField(partitionFields.get()[i]).pos(); | ||
| setThePartitionField(position, partitionValues[i], ret.getData()); | ||
| } | ||
| } | ||
| return ret; | ||
| } | ||
|
|
||
| protected abstract void setThePartitionField(int position, Object fieldValue, T row); | ||
jonvex marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.