theelderbeever commented on issue #7860:
URL:
https://github.com/apache/arrow-datafusion/issues/7860#issuecomment-1769354817
@devinjdangelo jinx... but yeah defining the table to write to using strings
then just manually casting the timestamp worked.
```rust
let schema = Schema::new(VectorMetric::fields());
let ctx = SessionContext::new();
ctx.register_parquet(
"metrics",
"data/metrics",
ParquetReadOptions::default()
.table_partition_cols(vec![(
"time_bucket".to_string(),
// DataType::Timestamp(TimeUnit::Second, None),
DataType::Utf8,
)])
.schema(&schema),
)
.await
.unwrap();
ctx.register_batch("batch", batch).unwrap();
let write_options = DataFrameWriteOptions::default()
.with_compression(CompressionTypeVariant::ZSTD)
.with_single_file_output(false);
let df = ctx
.sql(
r#"
SELECT *, DATE_TRUNC('DAY', timestamp)::TEXT AS time_bucket FROM
batch
"#,
)
.await
.unwrap()
.write_table("metrics", write_options)
.await
.unwrap();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]