Skip to content

Conversation

@roeap
Copy link
Collaborator

@roeap roeap commented Mar 21, 2025

What changes are proposed in this pull request?

Current checks for a pre-signed url in our readers may mis-classify object store URLs that do not use store specific schemes (s3://m az:// ...) as pre-signed urls. We extend the current checks, to also consider the presence of a query string and define a helper trait to ensure we can maintain the check in one place.

How was this change tested?

current unit tests.

@roeap roeap force-pushed the feat/pre-signed branch from 2610c41 to 1f378d0 Compare March 21, 2025 18:05
@codecov
Copy link

codecov bot commented Mar 21, 2025

Codecov Report

Attention: Patch coverage is 87.17949% with 5 lines in your changes missing coverage. Please review.

Project coverage is 84.34%. Comparing base (79b9f24) to head (b2c6915).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
kernel/src/engine/default/filesystem.rs 50.00% 1 Missing and 2 partials ⚠️
kernel/src/engine/default/parquet.rs 60.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #760      +/-   ##
==========================================
+ Coverage   84.32%   84.34%   +0.01%     
==========================================
  Files          81       81              
  Lines       19200    19227      +27     
  Branches    19200    19227      +27     
==========================================
+ Hits        16191    16217      +26     
- Misses       2204     2207       +3     
+ Partials      805      803       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Collaborator

@zachschuermann zachschuermann left a comment

Choose a reason for hiding this comment

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

LGTM with a couple nits and we should do a quick unit test for this to assert (and document!) behavior


impl UrlExt for Url {
fn is_presigned(&self) -> bool {
matches!(self.scheme(), "http" | "https") && self.query().is_some()
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: docs

Copy link
Collaborator

Choose a reason for hiding this comment

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

so only material change is checking that the query is Some? maybe link docs to the guarantee?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the checks to explicitly consider some well known cases. Initially i thought covering all cases would not be feasible, so just make the heuristic a bit more concrete. Then again, hopefully people will leet us know in case there are servers out there using different signing schemes.

Comment on lines 14 to 24
use crate::arrow::array::builder::{MapBuilder, MapFieldNames, StringBuilder};
use crate::arrow::array::{BooleanArray, Int64Array, RecordBatch, StringArray};
use crate::engine::arrow_data::ArrowEngineData;
use crate::engine::arrow_utils::{fixup_parquet_read, generate_mask, get_requested_indices};
use crate::engine::default::executor::TaskExecutor;
use crate::engine::parquet_row_group_skipping::ParquetRowGroupSkipping;
use crate::parquet::arrow::arrow_reader::{
ArrowReaderMetadata, ArrowReaderOptions, ParquetRecordBatchReaderBuilder,
};
use crate::parquet::arrow::arrow_writer::ArrowWriter;
use crate::parquet::arrow::async_reader::{ParquetObjectReader, ParquetRecordBatchStreamBuilder};
Copy link
Collaborator

Choose a reason for hiding this comment

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

i actually hesitate to move these crate::{arrow/parquet} items down here since they aren't really our crate (just re-exports). I generally group my imports into one of: std, external, and crate. I would advocate for having a new grouping just for arrow/parquet (or alternatively just leave in external group)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

makes a lot of sense. reverted for now to leave that for a future decision ...

Copy link
Collaborator

Choose a reason for hiding this comment

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

sounds good, thanks!

}

#[test]
fn test_pre_signed_url() {
Copy link
Collaborator

@sebastiantia sebastiantia Mar 24, 2025

Choose a reason for hiding this comment

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

super nit: unit test for case insensitive comparison

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added :)

// note signed permission (sp) must always be present
self
.query_pairs().any(|(k, _)| k.eq_ignore_ascii_case("sp")) ||
// <https://cloud.google.com/storage/docs/authentication/signatures
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: stray angled bracket <

Copy link
Collaborator

@sebastiantia sebastiantia left a comment

Choose a reason for hiding this comment

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

Approved with some minor nits!

@roeap roeap merged commit 512a31a into delta-io:main Mar 24, 2025
21 checks passed
@roeap roeap deleted the feat/pre-signed branch March 24, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants