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

fix for invalid parquet issue #829

Merged
merged 1 commit into from
Jun 27, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 16 additions & 14 deletions server/src/storage/staging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,34 +255,36 @@ pub fn convert_disk_files_to_parquet(
custom_partition_fields.insert(custom_partition_field.to_string(), index);
}
}
let parquet_file = fs::File::create(&parquet_path).map_err(|_| MoveDataError::Create)?;
let props = parquet_writer_props(
time_partition.clone(),
index_time_partition,
custom_partition_fields,
)
.build();

schemas.push(merged_schema.clone());
let schema = Arc::new(merged_schema);
let mut writer = ArrowWriter::try_new(parquet_file, schema.clone(), Some(props))?;
let parquet_file = fs::File::create(&parquet_path).map_err(|_| MoveDataError::Create)?;
let mut writer = ArrowWriter::try_new(&parquet_file, schema.clone(), Some(props))?;
for ref record in record_reader.merged_iter(schema, time_partition.clone()) {
writer.write(record)?;
}

writer.close()?;

for file in files {
let file_size = file.metadata().unwrap().len();
let file_type = file.extension().unwrap().to_str().unwrap();

if fs::remove_file(file.clone()).is_err() {
log::error!("Failed to delete file. Unstable state");
process::abort()
if parquet_file.metadata().unwrap().len() == 0 {
log::error!("Invalid parquet file detected, removing it");
fs::remove_file(parquet_path).unwrap();
} else {
for file in files {
let file_size = file.metadata().unwrap().len();
let file_type = file.extension().unwrap().to_str().unwrap();
if fs::remove_file(file.clone()).is_err() {
log::error!("Failed to delete file. Unstable state");
process::abort()
}
metrics::STORAGE_SIZE
.with_label_values(&["staging", stream, file_type])
.sub(file_size as i64);
}
metrics::STORAGE_SIZE
.with_label_values(&["staging", stream, file_type])
.sub(file_size as i64);
}
}

Expand Down
Loading