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: query by date partition #1447

Closed
Closed
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"commitInfo":{"delta-rs":"0.9.0","timestamp":1681604880998}}
{"protocol":{"minReaderVersion":1,"minWriterVersion":1}}
{"metaData":{"id":"1c863a88-7231-4ffc-a24b-3bbfad87d80a","name":"http_requests","description":"","format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"date\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ClientIP\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ClientRequestHost\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ClientRequestMethod\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"ClientRequestURI\",\"type\":\"string\",\"nullable\":true,\"metadata\":{}},{\"name\":\"EdgeEndTimestamp\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}},{\"name\":\"EdgeResponseBytes\",\"type\":\"long\",\"nullable\":true,\"metadata\":{}},{\"name\":\"EdgeResponseStatus\",\"type\":\"short\",\"nullable\":true,\"metadata\":{}},{\"name\":\"EdgeStartTimestamp\",\"type\":\"timestamp\",\"nullable\":true,\"metadata\":{}}]}","partitionColumns":["date"],"createdTime":1681604880998,"configuration":{}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"add":{"path":"date=2023-04-14/part-00000-731ab1b3-85a8-4bc3-92e5-96347fe3fd84-c000.snappy.parquet","size":5976,"partitionValues":{"date":"2023-04-14"},"modificationTime":1681604881837,"dataChange":true,"stats":"{\"numRecords\":1437,\"minValues\":{\"EdgeEndTimestamp\":\"2023-04-14T00:00:00.000Z\",\"ClientRequestHost\":\"example.com\",\"EdgeResponseStatus\":200,\"ClientRequestMethod\":\"GET\",\"EdgeStartTimestamp\":\"2023-04-14T00:00:00.000Z\",\"ClientIP\":\"127.0.0.1\",\"ClientRequestURI\":\"/\",\"EdgeResponseBytes\":303},\"maxValues\":{\"EdgeResponseBytes\":307,\"ClientRequestURI\":\"/\",\"EdgeResponseStatus\":200,\"EdgeStartTimestamp\":\"2023-04-14T00:00:45.000Z\",\"ClientIP\":\"127.0.0.1\",\"ClientRequestHost\":\"example.com\",\"ClientRequestMethod\":\"GET\",\"EdgeEndTimestamp\":\"2023-04-14T00:00:45.000Z\"},\"nullCount\":{\"ClientRequestHost\":0,\"ClientRequestURI\":0,\"ClientRequestMethod\":0,\"EdgeResponseStatus\":0,\"ClientIP\":0,\"EdgeEndTimestamp\":0,\"EdgeResponseBytes\":0,\"EdgeStartTimestamp\":0}}","tags":null}}
{"add":{"path":"date=2023-04-13/part-00000-e853fe2e-6f42-450c-8af1-4145b73a96c7-c000.snappy.parquet","size":3780,"partitionValues":{"date":"2023-04-13"},"modificationTime":1681604881849,"dataChange":true,"stats":"{\"numRecords\":144,\"minValues\":{\"EdgeStartTimestamp\":\"2023-04-13T23:58:58.000Z\",\"ClientRequestMethod\":\"GET\",\"ClientIP\":\"127.0.0.1\",\"EdgeEndTimestamp\":\"2023-04-13T23:58:58.000Z\",\"ClientRequestURI\":\"/\",\"ClientRequestHost\":\"example.com\",\"EdgeResponseBytes\":303,\"EdgeResponseStatus\":200},\"maxValues\":{\"ClientRequestHost\":\"example.com\",\"ClientRequestURI\":\"/\",\"ClientIP\":\"127.0.0.1\",\"EdgeResponseStatus\":200,\"ClientRequestMethod\":\"GET\",\"EdgeStartTimestamp\":\"2023-04-13T23:59:59.000Z\",\"EdgeEndTimestamp\":\"2023-04-14T00:00:00.000Z\",\"EdgeResponseBytes\":307},\"nullCount\":{\"ClientRequestMethod\":0,\"ClientIP\":0,\"EdgeResponseStatus\":0,\"ClientRequestURI\":0,\"EdgeEndTimestamp\":0,\"EdgeStartTimestamp\":0,\"EdgeResponseBytes\":0,\"ClientRequestHost\":0}}","tags":null}}
{"commitInfo":{"timestamp":1681604881849,"clientVersion":"delta-rs.0.9.0"}}
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"protocol":{"minReaderVersion":1,"minWriterVersion":1}}
{"metaData":{"id":"93bea48b-6453-474c-9214-4fd69194db55","name":null,"description":null,"format":{"provider":"parquet","options":{}},"schemaString":"{\"type\":\"struct\",\"fields\":[{\"name\":\"id\",\"type\":\"integer\",\"nullable\":true,\"metadata\":{}},{\"name\":\"date\",\"type\":\"date\",\"nullable\":false,\"metadata\":{}}]}","partitionColumns":["date"],"createdTime":1686160061066,"configuration":{}}}
{"commitInfo":{"timestamp":1686160061068,"operation":"CREATE TABLE","operationParameters":{"mode":"ErrorIfExists","protocol":"{\"minReaderVersion\":1,\"minWriterVersion\":1}","metadata":"{\"configuration\":{},\"created_time\":1686160061066,\"description\":null,\"format\":{\"options\":{},\"provider\":\"parquet\"},\"id\":\"93bea48b-6453-474c-9214-4fd69194db55\",\"name\":null,\"partition_columns\":[\"date\"],\"schema\":{\"fields\":[{\"metadata\":{},\"name\":\"id\",\"nullable\":true,\"type\":\"integer\"},{\"metadata\":{},\"name\":\"date\",\"nullable\":false,\"type\":\"date\"}],\"type\":\"struct\"}}","location":"file:///Users/cole/github.com/cmackenzie1/delta-rs/rust/tests/data/issue_1445"},"clientVersion":"delta-rs.0.13.0"}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{"add":{"path":"date=2023-06-07/part-00000-94397190-941b-4859-ad95-4f40dae21a9b-c000.snappy.parquet","size":484,"partitionValues":{"date":"2023-06-07"},"modificationTime":1686160061092,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"id\":1},\"maxValues\":{\"id\":1},\"nullCount\":{\"id\":0}}","tags":null}}
{"add":{"path":"date=2023-06-08/part-00000-938c1d51-6fe7-4b01-84da-ee1aa265befd-c000.snappy.parquet","size":484,"partitionValues":{"date":"2023-06-08"},"modificationTime":1686160061095,"dataChange":true,"stats":"{\"numRecords\":1,\"minValues\":{\"id\":2},\"maxValues\":{\"id\":2},\"nullCount\":{\"id\":0}}","tags":null}}
{"commitInfo":{"timestamp":1686160061095,"clientVersion":"delta-rs.0.13.0"}}
Binary file not shown.
Binary file not shown.
36 changes: 34 additions & 2 deletions rust/tests/datafusion_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ async fn test_datafusion_scan_timestamps() -> Result<()> {
#[tokio::test]
async fn test_issue_1292_datafusion_sql_projection() -> Result<()> {
let ctx = SessionContext::new();
let table = deltalake::open_table("./tests/data/http_requests")
let table = deltalake::open_table("./tests/data/issue_1292")
.await
.unwrap();
ctx.register_table("http_requests", Arc::new(table))?;
Expand Down Expand Up @@ -845,7 +845,7 @@ async fn test_issue_1292_datafusion_sql_projection() -> Result<()> {
#[tokio::test]
async fn test_issue_1291_datafusion_sql_partitioned_data() -> Result<()> {
let ctx = SessionContext::new();
let table = deltalake::open_table("./tests/data/http_requests")
let table = deltalake::open_table("./tests/data/issue_1291")
.await
.unwrap();
ctx.register_table("http_requests", Arc::new(table))?;
Expand Down Expand Up @@ -911,3 +911,35 @@ async fn test_issue_1374() -> Result<()> {

Ok(())
}

#[tokio::test]
async fn test_issue_1445_date_partition() -> Result<()> {
let ctx = SessionContext::new();
let table = deltalake::open_table("./tests/data/issue_1445")
.await
.unwrap();
ctx.register_table("t", Arc::new(table))?;

let batches = ctx
.sql(
r#"SELECT *
FROM t
WHERE date > '2023-06-07'
"#,
)
.await?
.collect()
.await?;

let expected = vec![
"+----+------------+",
"| id | date |",
"+----+------------+",
"| 2 | 2023-06-08 |",
"+----+------------+",
];

assert_batches_sorted_eq!(&expected, &batches);

Ok(())
}