-
Notifications
You must be signed in to change notification settings - Fork 403
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1661 from roeap/partition-values
fix: more consistent handling of partition values and file paths
- Loading branch information
Showing
18 changed files
with
366 additions
and
67 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
|
@@ -27,3 +27,4 @@ Cargo.lock | |
!/delta-inspect/Cargo.lock | ||
!/proofs/Cargo.lock | ||
|
||
justfile |
This file contains 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,20 @@ | ||
from datetime import date, datetime | ||
from typing import Any | ||
|
||
|
||
def encode_partition_value(val: Any) -> str: | ||
# Rules based on: https://github.com/delta-io/delta/blob/master/PROTOCOL.md#partition-value-serialization | ||
if isinstance(val, bool): | ||
return str(val).lower() | ||
if isinstance(val, str): | ||
return val | ||
elif isinstance(val, (int, float)): | ||
return str(val) | ||
elif isinstance(val, date): | ||
return val.isoformat() | ||
elif isinstance(val, datetime): | ||
return val.isoformat(sep=" ") | ||
elif isinstance(val, bytes): | ||
return val.decode("unicode_escape", "backslashreplace") | ||
else: | ||
raise ValueError(f"Could not encode partition value for type: {val}") |
This file contains 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 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 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 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 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 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 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 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,20 @@ | ||
use arrow::record_batch::RecordBatch; | ||
use deltalake::operations::collect_sendable_stream; | ||
use deltalake::DeltaOps; | ||
|
||
#[tokio::main(flavor = "current_thread")] | ||
async fn main() -> Result<(), deltalake::errors::DeltaTableError> { | ||
// Create a delta operations client pointing at an un-initialized location. | ||
let ops = if let Ok(table_uri) = std::env::var("TABLE_URI") { | ||
DeltaOps::try_from_uri(table_uri).await? | ||
} else { | ||
DeltaOps::try_from_uri("./rust/tests/data/delta-0.8.0").await? | ||
}; | ||
|
||
let (_table, stream) = ops.load().await?; | ||
let data: Vec<RecordBatch> = collect_sendable_stream(stream).await?; | ||
|
||
println!("{:?}", data); | ||
|
||
Ok(()) | ||
} |
This file contains 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
Oops, something went wrong.