-
Notifications
You must be signed in to change notification settings - Fork 196
Parquet Incremental Sync #768
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
Open
sapienza88
wants to merge
102
commits into
apache:main
Choose a base branch
from
sapienza88:parquet_incr_sync
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+928
−237
Open
Changes from all commits
Commits
Show all changes
102 commits
Select commit
Hold shift + click to select a range
e541a71
given a parquet file return data from a certain modification time
15e282a
create the path based on the partition then inject the file to append…
2ee71c9
Handle case of path construction with file partitioned over many fiel…
6032e5f
test append Parquet file into table init
f6fdc72
add function to test schema equivalence before appending
a94c3f3
construct path to inject to based on partitions
f8bdbfe
fix imports
c04a983
refactoring (lombok, logs, javadocs and function and approach comment…
5f2541e
use appendFile to append a file into a table while tracking the appen…
47e7076
find the files that satisfy to the time condition
fbb09ec
treat appends as separate files to add in the target partition folder
fe19a60
update approach: selective block compaction
da7f300
update approach: added a basic test to check data selection using mod…
a8730b7
fix append based on partition value
d19ccbf
fix test with basic example where partitions are not considered
aecb204
fix test with basic example where partitions are not considered2
0ec8cbb
fix test with basic example where partitions are not considered3
9cb75df
test with time of last append is now
9e125f2
test appendFile with Parquet: TODO test with multiple partitions 1) a…
233ca77
merge recursively one partition files
b4cba5a
fix paths for files to append
a564b29
fix bug of appending file path
d1ceafb
fix bug of schema
649250f
make sure returned files are non empty when iterating in the partitions
24ff828
make sure returned files are non empty when iterating in the partitio…
463d2ee
discard empty files when appending
71d1c34
discard empty files when appending
3319a91
one spark session for both tests
013ffe4
bug fix
b939a0a
bug fix
b6d8ddc
cleanups + TODO: partitions match and merge
c18ab1c
added test for many partitions, TODO integrate functions into Parquet…
b7c613e
selecting data bug fix, TODO integrate functions into ParquetConversi…
2a75f49
run all tests, TODO integrate functions into ParquetConversionSource
f1538b0
run all tests, TODO integrate functions into ParquetConversionSource
cdedeae
spotless:apply, TODO integrate functions into ParquetConversionSource
e873120
bug fixes, TODO integrate functions into ParquetConversionSource
4d0f245
bug fixes, TODO integrate functions into ParquetConversionSource
219656e
handle lightweight metadata in the conversionSource
ff809d7
fix CI
e06368f
fix CI, refactoring and isIncrementalSyncSafeFrom implementation
7cdccd0
added test
b919146
added test: init conversionSource instance
8ff5aa6
added test: init conversionSource instance: fix error
db9d7ab
added test: fix error
324d703
more tests + bug fixes and reformatting
3c453e6
CI fix
e4c0b4c
CI fix
4315282
CI fix
1417929
CI fix
7620c01
CI fix
e458d72
Merge branch 'main' of https://github.com/sapienza88/incubator-xtable…
9947f1b
Merge branch 'main' of https://github.com/sapienza88/incubator-xtable…
cd66151
CI fix
4e4c5cb
merge ready fixes & tests + refactoring & reformatting
212e50a
optimization: read metadata once for target file, read parquet files …
5ea0b5a
Lazily fetch info, move state into ParquetDataManager
the-other-tim-brown 64a5a2d
add TestParquetDataManager, simplify data manager methods
the-other-tim-brown 2135ccf
make IT parameterized, add incremental sync
the-other-tim-brown e76ac21
fix schema extraction to fix snapshot sync
the-other-tim-brown 9901c1b
add optimizations
the-other-tim-brown a2bb6c3
fix for ParquetDataManager Test (mock())
2d23f31
before resycing delete the first synced files metadata
ceb924c
in order to append parquet files, perform union then spark overwrite …
5b0a9fd
solving directory issue when overwriting data using spark
80e1927
solving directory issue when overwriting data using spark2
0aedd70
solving directory issue when overwriting data using spark3
5cbeeeb
solving directory issue when overwriting data using spark4
13e5a65
solving directory issue when overwriting data using spark5
fa77646
solving directory issue when overwriting data using spark6
e53fa4b
solving directory issue when overwriting data using spark7
a6b75d5
revert writeData changes
bdc9f40
solving directory issue when overwriting data using spark8
43d986d
solving directory issue when overwriting data using spark9
5f67a0f
solving directory issue when overwriting data using spark9
dae07b7
revert changes
9e0de0a
testing without cleaning metadata for the second sync
8c1b8f6
testing without cleaning metadata for the second sync
84bae49
testing without cleaning metadata for the second sync
6ce28a3
testing without cleaning metadata for the second sync
cf2564c
testing without cleaning metadata for the second sync
6cb87ee
revert changes
5c25093
revert changes
17a3134
revert changes
5b0d8dc
use no tempDir
8db84a0
revert changes
b8e0d16
use union() to append data for the second sync()
fdaeb4d
use union() to append data for the second sync()
b2f214d
use union() to append data for the second sync()
913ac29
use union() to append data for the second sync()
9e243a1
use union() to append data for the second sync() reverted
a7412c3
fix second sync error
c028112
fix second sync error
089e869
fix second sync error
f1f8be1
fix second sync error
6588d1d
fix second sync error
da9e401
fix second sync error
15567ab
fix second sync error
119b68c
fix second sync error
ca49c63
fix second sync error
9711135
fix second sync error
a62a24c
fix second sync error
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
104 changes: 104 additions & 0 deletions
104
xtable-core/src/main/java/org/apache/xtable/parquet/ParquetDataManager.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,104 @@ | ||
| /* | ||
| * 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.xtable.parquet; | ||
|
|
||
| import java.io.IOException; | ||
| import java.net.URI; | ||
| import java.nio.file.Paths; | ||
| import java.util.*; | ||
| import java.util.stream.Collectors; | ||
| import java.util.stream.Stream; | ||
|
|
||
| import lombok.AccessLevel; | ||
| import lombok.Getter; | ||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.log4j.Log4j2; | ||
|
|
||
| import org.apache.hadoop.conf.Configuration; | ||
| import org.apache.hadoop.fs.*; | ||
| import org.apache.hadoop.util.functional.RemoteIterators; | ||
|
|
||
| import org.apache.xtable.exception.ReadException; | ||
|
|
||
| /** | ||
| * Manages Parquet File's Metadata | ||
| * | ||
| * <p>This class provides functions to handle Parquet metadata, creating metadata objects from | ||
| * parquet files and filtering the files based on the modification times. | ||
| */ | ||
| @Log4j2 | ||
| @RequiredArgsConstructor | ||
| public class ParquetDataManager { | ||
| private final Configuration hadoopConf; | ||
| private final String basePath; | ||
| private final FileSystem fileSystem; | ||
|
|
||
| public ParquetDataManager(Configuration hadoopConf, String basePath) { | ||
| this.hadoopConf = hadoopConf; | ||
| this.basePath = basePath; | ||
| try { | ||
| URI uri = Paths.get(basePath).toUri(); | ||
| this.fileSystem = FileSystem.get(uri, hadoopConf); | ||
| } catch (IOException e) { | ||
| throw new ReadException("Unable to initialize file system for base path: " + basePath, e); | ||
| } | ||
| } | ||
|
|
||
| @Getter(value = AccessLevel.PRIVATE, lazy = true) | ||
| private final List<LocatedFileStatus> parquetFiles = loadParquetFiles(); | ||
|
|
||
| ParquetFileInfo getMostRecentParquetFile() { | ||
| LocatedFileStatus file = | ||
| getParquetFiles().stream() | ||
| .max(Comparator.comparing(LocatedFileStatus::getModificationTime)) | ||
| .orElseThrow(() -> new IllegalStateException("No files found")); | ||
| return new ParquetFileInfo(hadoopConf, file); | ||
| } | ||
|
|
||
| ParquetFileInfo getParquetDataFileAt(long targetTime) { | ||
| return getParquetFiles().stream() | ||
| .filter(file -> file.getModificationTime() >= targetTime) | ||
| .min(Comparator.comparing(LocatedFileStatus::getModificationTime)) | ||
| .map(file -> new ParquetFileInfo(hadoopConf, file)) | ||
| .orElseThrow(() -> new IllegalStateException("No file found at or after " + targetTime)); | ||
| } | ||
|
|
||
| private List<LocatedFileStatus> loadParquetFiles() { | ||
| try { | ||
| RemoteIterator<LocatedFileStatus> iterator = fileSystem.listFiles(new Path(basePath), true); | ||
| return RemoteIterators.toList(iterator).stream() | ||
| .filter(file -> file.getPath().getName().endsWith("parquet")) | ||
| .collect(Collectors.toList()); | ||
| } catch (IOException e) { | ||
| throw new ReadException("Unable to read files from file system", e); | ||
| } | ||
| } | ||
|
|
||
| Stream<ParquetFileInfo> getCurrentFileInfo() { | ||
|
Contributor
Author
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. @the-other-tim-brown You would want to rename this to the plural (getCurrentFilesInfo())? |
||
| return getParquetFiles().stream() | ||
| .map(fileStatus -> new ParquetFileInfo(hadoopConf, fileStatus)); | ||
| } | ||
|
|
||
| List<ParquetFileInfo> getParquetFilesMetadataAfterTime(long syncTime) { | ||
| return getParquetFiles().stream() | ||
| .filter(file -> file.getModificationTime() >= syncTime) | ||
| .map(file -> new ParquetFileInfo(hadoopConf, file)) | ||
| .collect(Collectors.toList()); | ||
| } | ||
| } | ||
Oops, something went wrong.
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.