-
Notifications
You must be signed in to change notification settings - Fork 459
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add docs and fix failing python tests
Signed-off-by: Nikolay Ulmasov <[email protected]>
- Loading branch information
Showing
8 changed files
with
93 additions
and
31 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
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
python: | ||
DeltaTable: PYTHON_API_URL/delta_table | ||
replaceWhere: https://delta-io.github.io/delta-rs/api/delta_writer/ | ||
rust: | ||
DeltaTable: https://docs.rs/deltalake/latest/deltalake/table/struct.DeltaTable.html | ||
DeltaTable: https://docs.rs/deltalake/latest/deltalake/table/struct.DeltaTable.html | ||
replaceWhere: https://docs.rs/deltalake/latest/deltalake/operations/write/struct.WriteBuilder.html#method.with_replace_where |
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,21 @@ | ||
def replace_where(): | ||
# --8<-- [start:replace_where] | ||
import pyarrow as pa | ||
from deltalake import write_deltalake | ||
|
||
# Assuming there is already a table in this location with some records where `id = '1'` which we want to overwrite | ||
table_path = "/tmp/my_table" | ||
data = pa.table( | ||
{ | ||
"id": pa.array(["1", "1"], pa.string()), | ||
"value": pa.array([11, 12], pa.int64()), | ||
} | ||
) | ||
write_deltalake( | ||
table_path, | ||
data, | ||
mode="overwrite", | ||
predicate="id = '1'", | ||
engine="rust", | ||
) | ||
# --8<-- [end:replace_where] |
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,32 @@ | ||
#[tokio::main] | ||
async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
// --8<-- [start:replace_where] | ||
// Assuming there is already a table in this location with some records where `id = '1'` which we want to overwrite | ||
use arrow_schema::{DataType, Field, Schema as ArrowSchema}; | ||
use arrow_array::RecordBatch; | ||
import deltalake::protocol::SaveMode; | ||
|
||
let schema = ArrowSchema::new(vec![ | ||
Field::new("id", DataType::Utf8, true), | ||
Field::new("value", DataType::Int32, true), | ||
]); | ||
|
||
let data = RecordBatch::try_new( | ||
&schema, | ||
vec![ | ||
Arc::new(arrow::array::StringArray::from(vec!["1", "1"])), | ||
Arc::new(arrow::array::Int32Array::from(vec![11, 12])), | ||
], | ||
) | ||
.unwrap(); | ||
|
||
let table = deltalake::open_table("/tmp/my_table").await.unwrap(); | ||
let table = DeltaOps(table) | ||
.write(vec![data]) | ||
.with_save_mode(SaveMode::Overwrite) | ||
.with_replace_where(col("id").eq(lit("1"))) | ||
.await; | ||
// --8<-- [end:replace_where] | ||
|
||
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
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