Skip to content

Commit 7616021

Browse files
authored
use nanosecond timestamps in file metadata (#28)
1 parent 64eaabd commit 7616021

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/materialized/dependencies.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,15 @@ impl TableFunctionImpl for StaleFilesUdtf {
200200
col("expected_target").alias("target"),
201201
col("target_last_modified"),
202202
col("sources_last_modified"),
203-
nvl(col("target_last_modified"), lit(0))
204-
.lt(col("sources_last_modified"))
205-
.alias("is_stale"),
203+
nvl(
204+
col("target_last_modified"),
205+
lit(ScalarValue::TimestampNanosecond(
206+
Some(0),
207+
Some(Arc::from("UTC")),
208+
)),
209+
)
210+
.lt(col("sources_last_modified"))
211+
.alias("is_stale"),
206212
])?
207213
.build()?;
208214

src/materialized/file_metadata.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
use arrow::array::{Int64Builder, StringBuilder, UInt64Builder};
18+
use arrow::array::{StringBuilder, TimestampNanosecondBuilder, UInt64Builder};
1919
use arrow::record_batch::RecordBatch;
20-
use arrow_schema::{DataType, Field, Schema, SchemaRef};
20+
use arrow_schema::{DataType, Field, Schema, SchemaRef, TimeUnit};
2121
use async_trait::async_trait;
2222
use datafusion::catalog::SchemaProvider;
2323
use datafusion::catalog::{CatalogProvider, Session};
@@ -65,7 +65,11 @@ impl FileMetadata {
6565
Field::new("table_schema", DataType::Utf8, false),
6666
Field::new("table_name", DataType::Utf8, false),
6767
Field::new("file_path", DataType::Utf8, false),
68-
Field::new("last_modified", DataType::Int64, false),
68+
Field::new(
69+
"last_modified",
70+
DataType::Timestamp(TimeUnit::Nanosecond, Some(Arc::from("UTC"))),
71+
false,
72+
),
6973
Field::new("size", DataType::UInt64, false),
7074
])),
7175
catalog_list,
@@ -444,7 +448,7 @@ struct FileMetadataBuilder {
444448
schema_names: StringBuilder,
445449
table_names: StringBuilder,
446450
file_paths: StringBuilder,
447-
last_modified: Int64Builder,
451+
last_modified: TimestampNanosecondBuilder,
448452
size: UInt64Builder,
449453
}
450454

@@ -456,7 +460,7 @@ impl FileMetadataBuilder {
456460
schema_names: StringBuilder::new(),
457461
table_names: StringBuilder::new(),
458462
file_paths: StringBuilder::new(),
459-
last_modified: Int64Builder::new(),
463+
last_modified: TimestampNanosecondBuilder::new().with_timezone("UTC"),
460464
size: UInt64Builder::new(),
461465
}
462466
}

0 commit comments

Comments
 (0)