-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Omit table name when only one ident in SELECT (#1094)
- Loading branch information
1 parent
48a9ea9
commit cb385db
Showing
7 changed files
with
72 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
use std::collections::HashSet; | ||
|
||
use super::{IrFold, TId, Transform}; | ||
|
||
/// Folder that counts the number of table referenced in a PRQL query. | ||
#[derive(Debug, Default)] | ||
pub struct TableCounter { | ||
tables: HashSet<TId>, | ||
} | ||
|
||
impl TableCounter { | ||
pub fn count(&self) -> usize { | ||
self.tables.len() | ||
} | ||
} | ||
|
||
impl IrFold for TableCounter { | ||
fn fold_transforms(&mut self, transforms: Vec<Transform>) -> anyhow::Result<Vec<Transform>> { | ||
for transform in &transforms { | ||
if let Transform::Join { with: tid, .. } | Transform::From(tid) = transform { | ||
self.tables.insert(*tid); | ||
} | ||
} | ||
|
||
Ok(transforms) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.