Skip to content

Commit 640ef30

Browse files
committed
fix formatting
1 parent 4ad04d8 commit 640ef30

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

core/src/duckdb.rs

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -485,15 +485,7 @@ impl TableProviderFactory for DuckDBTableProviderFactory {
485485
.with_indexes(indexes.clone());
486486

487487
let pool = Arc::new(pool);
488-
make_initial_table(Arc::new(table_definition.clone()), &pool)?;
489-
490-
let write_settings = DuckDBWriteSettings::from_params(&options);
491-
492-
let table_writer_builder = DuckDBTableWriterBuilder::new()
493-
.with_table_definition(table_definition)
494-
.with_pool(pool)
495-
.set_on_conflict(on_conflict)
496-
.with_write_settings(write_settings);
488+
make_initial_table(Arc::new(table_definition), &pool)?;
497489

498490
let dyn_pool: Arc<DynDuckDbConnectionPool> = Arc::new(read_pool);
499491

@@ -510,15 +502,29 @@ impl TableProviderFactory for DuckDBTableProviderFactory {
510502
self.settings_registry
511503
.apply_settings(conn, &options, DuckDBSettingScope::Global)?;
512504

513-
// Use actual DuckDB storage schema for the read provider (may differ from cmd.schema).
505+
// After table creation, read actual DuckDB schema (may differ from cmd.schema,
506+
// e.g. DuckDB stores TIMESTAMPTZ as Microsecond regardless of requested precision).
514507
let schema_conn = dyn_pool.connect().await?;
515-
let read_schema = get_schema(schema_conn, &TableReference::bare(name.clone()))
508+
let schema = get_schema(schema_conn, &TableReference::bare(name.clone()))
516509
.await
517510
.map_err(|e| DataFusionError::External(Box::new(e)))?;
518511

512+
let table_definition =
513+
TableDefinition::new(RelationName::new(name.clone()), Arc::clone(&schema))
514+
.with_constraints(cmd.constraints.clone())
515+
.with_indexes(indexes.clone());
516+
517+
let write_settings = DuckDBWriteSettings::from_params(&options);
518+
519+
let table_writer_builder = DuckDBTableWriterBuilder::new()
520+
.with_table_definition(table_definition)
521+
.with_pool(pool)
522+
.set_on_conflict(on_conflict)
523+
.with_write_settings(write_settings);
524+
519525
let read_provider = Arc::new(DuckDBTable::new_with_schema(
520526
&dyn_pool,
521-
read_schema,
527+
schema,
522528
TableReference::bare(name.clone()),
523529
None,
524530
Some(self.dialect.clone()),
@@ -1173,9 +1179,7 @@ pub(crate) mod tests {
11731179
// DuckDB stores TIMESTAMPTZ as Microsecond regardless of requested precision.
11741180
match ts_field.data_type() {
11751181
DataType::Timestamp(TimeUnit::Microsecond, _) => {}
1176-
other => panic!(
1177-
"Expected Timestamp(Microsecond, _), got {other:?}"
1178-
),
1182+
other => panic!("Expected Timestamp(Microsecond, _), got {other:?}"),
11791183
}
11801184
}
11811185
}

0 commit comments

Comments
 (0)