-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add support for bigint and table schema
This commit adds support for bigint data type and introduces the table_schema module. The table_schema module defines the TableSchema struct, which contains information about the schema and qualified name of a table. fix: Fix order by alias and cte table issues This commit fixes issues related to ordering by alias and common table expressions (CTEs). refactor: Refactor merge_schema function The merge_schema function in the utils module has been refactored to improve readability and maintainability. test: Add count wildcard rule optimization This commit adds a count wildcard rule optimization to the optimizer. The optimization replaces count(*) expressions with count(1) to improve query performance. chore: Update parser to support column aliases The parser has been updated to support column aliases in SELECT statements. docs: Update documentation for binary expressions The documentation for the BinaryExpr struct has been updated to provide more clarity on its usage and behavior.
- Loading branch information
Showing
23 changed files
with
1,053 additions
and
728 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
pub mod join_type; | ||
pub mod table_relation; | ||
pub mod table_schema; | ||
pub mod transformed; |
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,11 @@ | ||
use std::sync::Arc; | ||
|
||
use super::table_relation::TableRelation; | ||
use arrow::datatypes::SchemaRef; | ||
|
||
pub type TableSchemaRef = Arc<TableSchema>; | ||
|
||
pub struct TableSchema { | ||
pub schema: SchemaRef, | ||
pub qualified_name: Vec<Option<TableRelation>>, | ||
} |
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,109 @@ | ||
use crate::error::Result; | ||
|
||
pub struct Transformed<T> { | ||
pub data: T, | ||
pub transformed: bool, | ||
} | ||
|
||
impl<T> Transformed<T> { | ||
pub fn yes(data: T) -> Self { | ||
Transformed { | ||
data, | ||
transformed: true, | ||
} | ||
} | ||
|
||
pub fn no(data: T) -> Self { | ||
Transformed { | ||
data, | ||
transformed: false, | ||
} | ||
} | ||
|
||
pub fn update<U, F>(self, f: F) -> Transformed<U> | ||
where | ||
F: FnOnce(T) -> U, | ||
{ | ||
Transformed { | ||
data: f(self.data), | ||
transformed: self.transformed, | ||
} | ||
} | ||
|
||
pub fn transform_children<F>(self, f: F) -> Result<Transformed<T>> | ||
where | ||
F: FnOnce(T) -> Result<Transformed<T>>, | ||
{ | ||
f(self.data).map(|mut t| { | ||
t.transformed |= self.transformed; | ||
t | ||
}) | ||
} | ||
} | ||
|
||
pub trait TransformedResult<T> { | ||
fn data(self) -> Result<T>; | ||
} | ||
|
||
impl<T> TransformedResult<T> for Result<Transformed<T>> { | ||
fn data(self) -> Result<T> { | ||
self.map(|t| t.data) | ||
} | ||
} | ||
|
||
#[derive(Debug, PartialEq, Clone, Copy)] | ||
pub enum TreeNodeRecursion { | ||
Continue, | ||
Stop, | ||
} | ||
|
||
impl TreeNodeRecursion { | ||
pub fn visit_children<F>(self, f: F) -> Result<TreeNodeRecursion> | ||
where | ||
F: FnOnce() -> Result<TreeNodeRecursion>, | ||
{ | ||
match self { | ||
TreeNodeRecursion::Continue => f(), | ||
TreeNodeRecursion::Stop => Ok(self), | ||
} | ||
} | ||
} | ||
|
||
pub trait TransformNode: Sized + Clone { | ||
fn map_children<F>(self, f: F) -> Result<Transformed<Self>> | ||
where | ||
F: FnMut(Self) -> Result<Transformed<Self>>; | ||
|
||
fn apply_children<'n, F>(&'n self, f: F) -> Result<TreeNodeRecursion> | ||
where | ||
F: FnMut(&'n Self) -> Result<TreeNodeRecursion>; | ||
|
||
fn transform<F>(self, mut f: F) -> Result<Transformed<Self>> | ||
where | ||
F: FnMut(Self) -> Result<Transformed<Self>>, | ||
{ | ||
transform_impl(self, &mut f) | ||
} | ||
|
||
fn apply<'n, F>(&'n self, mut f: F) -> Result<TreeNodeRecursion> | ||
where | ||
F: FnMut(&'n Self) -> Result<TreeNodeRecursion>, | ||
{ | ||
apply_impl(self, &mut f) | ||
} | ||
} | ||
|
||
fn transform_impl<N, F>(node: N, f: &mut F) -> Result<Transformed<N>> | ||
where | ||
N: TransformNode, | ||
F: FnMut(N) -> Result<Transformed<N>>, | ||
{ | ||
f(node.clone())?.transform_children(|n| n.map_children(|c| transform_impl(c, f))) | ||
} | ||
|
||
fn apply_impl<'n, N: TransformNode, F: FnMut(&'n N) -> Result<TreeNodeRecursion>>( | ||
node: &'n N, | ||
f: &mut F, | ||
) -> Result<TreeNodeRecursion> { | ||
f(node)?.visit_children(|| node.apply_children(|c| apply_impl(c, f))) | ||
} |
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
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.