Skip to content

Commit

Permalink
Merge pull request #65 from supabase/fix/bq-pagination-pushdown
Browse files Browse the repository at this point in the history
feat: add pagination and pushdown for bq fdw
  • Loading branch information
burmecia authored Mar 1, 2023
2 parents 6951340 + 0c4004b commit 73b352f
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 64 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion supabase-wrappers-macros/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "supabase-wrappers-macros"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
authors = ["Supabase Inc. https://supabase.com/"]
license = "Apache-2.0"
Expand Down
2 changes: 1 addition & 1 deletion supabase-wrappers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "supabase-wrappers"
version = "0.1.7"
version = "0.1.8"
edition = "2021"
authors = ["Supabase Inc. https://supabase.com/"]
license = "Apache-2.0"
Expand Down
30 changes: 30 additions & 0 deletions supabase-wrappers/src/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,30 @@ pub struct Sort {
pub collate: Option<String>,
}

impl Sort {
pub fn deparse(&self) -> String {
let mut sql = format!("order by {}", self.field);

if self.reversed {
sql.push_str(" desc");
} else {
sql.push_str(" asc");
}

if self.nulls_first {
sql.push_str(" nulls first")
} else {
sql.push_str(" nulls last")
}

if let Some(collate) = &self.collate {
sql.push_str(&format!(" collate {}", collate));
}

sql
}
}

/// Query limit, a.k.a `LIMIT count OFFSET offset` clause
///
/// ## Examples
Expand All @@ -328,6 +352,12 @@ pub struct Limit {
pub offset: i64,
}

impl Limit {
pub fn deparse(&self) -> String {
format!("limit {} offset {}", self.count, self.offset)
}
}

/// The Foreign Data Wrapper trait
///
/// This is the main interface for your foreign data wrapper. Required functions
Expand Down
37 changes: 14 additions & 23 deletions wrappers/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions wrappers/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "wrappers"
version = "0.1.7"
version = "0.1.8"
edition = "2021"

[lib]
Expand Down Expand Up @@ -38,7 +38,7 @@ clickhouse-rs = { git = "https://github.com/suharev7/clickhouse-rs", branch = "a
chrono = { version = "0.4", optional = true }

# for bigquery_fdw, firebase_fdw, airtable_fdw and etc.
gcp-bigquery-client = { version = "0.16.0", optional = true }
gcp-bigquery-client = { version = "0.16.5", optional = true }
time = { version = "0.3.17", features = ["parsing"], optional = true }
serde = { version = "1", optional = true }
serde_json = { version = "1.0.86", optional = true }
Expand Down
1 change: 1 addition & 0 deletions wrappers/src/fdw/bigquery_fdw/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,3 +134,4 @@ insert into people values (4, 'Yoda', current_timestamp());
| Version | Date | Notes |
| ------- | ---------- | ---------------------------------------------------- |
| 0.1.0 | 2022-11-30 | Initial version |
| 0.1.1 | 2023-02-15 | Upgrade bq client lib to v0.16.5, code improvement |
Loading

0 comments on commit 73b352f

Please sign in to comment.