Skip to content

Commit

Permalink
fix: Use SQLite dialect for SQLite (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
peasee authored Aug 26, 2024
1 parent b2cac67 commit b5dd268
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions src/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::sql::sql_provider_datafusion::{self, expr::Engine, SqlTable};
use arrow::{array::RecordBatch, datatypes::SchemaRef};
use async_trait::async_trait;
use datafusion::catalog::Session;
use datafusion::sql::unparser::dialect::SqliteDialect;
use datafusion::{
catalog::TableProviderFactory,
common::Constraints,
Expand Down Expand Up @@ -138,6 +139,7 @@ fn handle_db_error(err: db_connection_pool::Error) -> DataFusionError {

#[async_trait]
impl TableProviderFactory for SqliteTableProviderFactory {
#[allow(clippy::too_many_lines)]
async fn create(
&self,
_state: &dyn Session,
Expand Down Expand Up @@ -241,13 +243,16 @@ impl TableProviderFactory for SqliteTableProviderFactory {

let dyn_pool: Arc<DynSqliteConnectionPool> = read_pool;

let read_provider = Arc::new(SqlTable::new_with_schema(
"sqlite",
&dyn_pool,
Arc::clone(&schema),
TableReference::bare(name.clone()),
Some(Engine::SQLite),
));
let read_provider = Arc::new(
SqlTable::new_with_schema(
"sqlite",
&dyn_pool,
Arc::clone(&schema),
TableReference::bare(name.clone()),
Some(Engine::SQLite),
)
.with_dialect(Arc::new(SqliteDialect {})),
);

let sqlite = Arc::into_inner(sqlite)
.context(DanglingReferenceToSqliteSnafu)
Expand Down

0 comments on commit b5dd268

Please sign in to comment.