Skip to content
Open
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
16 changes: 8 additions & 8 deletions columnq/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ bytes = { version = "1" }
percent-encoding = "2.3"

# datafusion
datafusion = { version = "47", features = ["serde"] }
arrow = { version = "55", features = ["prettyprint"] }
datafusion = { version = "47", features = ["serde"] }
arrow = { version = "55.0.0", features = ["prettyprint"] }

# spreadsheets reader
calamine = { version = "0.23.1", features = ["dates"] }
Expand Down Expand Up @@ -59,10 +59,9 @@ yup-oauth2 = { version = "10", default-features = false, features = [
] }

[dependencies.connectorx]
git = "https://github.com/roapi/connector-x.git"
rev = "77e769ec5d8654a5f6912573a70d56ac8b7f7a50"
version = "0.3.3-alpha.1"
features = ["default", "dst_arrow"]
git = "https://github.com/sfu-db/connector-x.git"
version = "0.4.4-alpha.1" # Updated to the latest version found
features = ["fptr", "src_trino", "dst_"] # Added fptr (default), kept src_trino and dst_arrow
optional = true

[dev-dependencies]
Expand All @@ -71,7 +70,7 @@ toml = "0.7"
tempfile = "3.3.0"
pretty_assertions = "*"
dotenvy = "*"
rusqlite = "0"
rusqlite = "0.33.0"

[features]
default = ["rustls"]
Expand Down Expand Up @@ -100,4 +99,5 @@ native-tls = [
database-sqlite = ["connectorx/src_sqlite"]
database-mysql = ["connectorx/src_mysql"]
database-postgres = ["connectorx/src_postgres", "dep:tokio-postgres"]
database = ["database-sqlite", "database-mysql", "database-postgres"]
database-trino = ["connectorx/src_trino"]
database = ["database-sqlite", "database-mysql", "database-postgres", "database-trino"]
10 changes: 7 additions & 3 deletions columnq/src/table/database.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ pub enum DatabaseLoader {
MySQL,
SQLite,
Postgres,
Trino, // Added Trino
}

#[cfg(any(
feature = "database-sqlite",
feature = "database-mysql",
feature = "database-postgres"
feature = "database-postgres",
feature = "database-trino" // Added
))]
mod imp {
use crate::table::TableLoadOption;
Expand Down Expand Up @@ -45,6 +47,7 @@ mod imp {
Some(TableLoadOption::mysql { table }) => table.clone(),
Some(TableLoadOption::postgres { table }) => table.clone(),
Some(TableLoadOption::sqlite { table }) => table.clone(),
Some(TableLoadOption::trino { table }) => table.clone(), // Added
_ => None,
}
.unwrap_or(t.name.clone());
Expand All @@ -54,7 +57,7 @@ mod imp {
.context(SourceSnafu)
.map_err(Box::new)
.context(table::LoadDatabaseSnafu)?;
let destination = connectorx::get_arrow::get_arrow(&source, None, &[queries])
let destination = connectorx::get_arrow::get_arrow(&source, None, &[queries], None)
.context(DestinationSnafu)
.map_err(Box::new)
.context(table::LoadDatabaseSnafu)?;
Expand All @@ -76,7 +79,8 @@ mod imp {
#[cfg(not(any(
feature = "database-sqlite",
feature = "database-mysql",
feature = "database-postgres"
feature = "database-postgres",
feature = "database-trino" // Added
)))]
mod imp {
use crate::table::TableSource;
Expand Down
16 changes: 16 additions & 0 deletions columnq/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub enum Extension {
Sqlite,
Mysql,
Postgresql,
Trino, // Added
}

impl From<Extension> for &'static str {
Expand All @@ -136,6 +137,7 @@ impl From<Extension> for &'static str {
Extension::Sqlite => "sqlite",
Extension::Mysql => "mysql",
Extension::Postgresql => "postgresql",
Extension::Trino => "trino", // Added
}
}
}
Expand All @@ -158,6 +160,7 @@ impl TryFrom<&str> for Extension {
"xlsb" => Extension::Xlsb,
"ods" => Extension::Ods,
"sqlite" | "sqlite3" | "db" => Extension::Sqlite,
"trino" => Extension::Trino, // Added. Consider if other aliases are needed.
_ => {
return Err(Error::Extension {
msg: format!("unsupported extension {ext}"),
Expand Down Expand Up @@ -406,6 +409,9 @@ pub enum TableLoadOption {
postgres {
table: Option<String>,
},
trino { // Added
table: Option<String>,
},
}

impl TableLoadOption {
Expand Down Expand Up @@ -463,6 +469,7 @@ impl TableLoadOption {
Self::mysql { .. } => Extension::Mysql,
Self::sqlite { .. } => Extension::Sqlite,
Self::postgres { .. } => Extension::Postgresql,
Self::trino { .. } => Extension::Trino, // Added
}
}
}
Expand Down Expand Up @@ -636,6 +643,9 @@ impl TableSource {
"postgresql" => Some(TableLoadOption::postgres {
table: table_name_from_path(uri.path()),
}),
"trino" => Some(TableLoadOption::trino { // Added
table: table_name_from_path(uri.path()),
}),
_ => None,
}
}
Expand Down Expand Up @@ -824,6 +834,9 @@ pub async fn load(
TableLoadOption::postgres { .. } => LoadedTable::new_from_df_table(Arc::new(
database::DatabaseLoader::Postgres.to_mem_table(t)?,
)),
TableLoadOption::trino { .. } => LoadedTable::new_from_df_table(Arc::new( // Added
database::DatabaseLoader::Trino.to_mem_table(t)?,
)),
})
} else {
match t.extension()? {
Expand All @@ -847,6 +860,9 @@ pub async fn load(
Extension::Postgresql => Ok(LoadedTable::new_from_df_table(Arc::new(
database::DatabaseLoader::Postgres.to_mem_table(t)?,
))),
Extension::Trino => Ok(LoadedTable::new_from_df_table(Arc::new( // Added
database::DatabaseLoader::Trino.to_mem_table(t)?,
))),
ext => Err(Error::InvalidUri {
msg: format!(
"failed to register `{}` as table `{}`, unsupported table format `{:?}`",
Expand Down