-
Notifications
You must be signed in to change notification settings - Fork 2
Implement dialect translators #173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src/dialect_translation/mod.rs
Outdated
|
||
// expand arms for nullay | ||
$( | ||
expr::function::Function::$nullay => $self.[<from_ $nullay:snake>](), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nullary you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected.
src/dialect_translation/mod.rs
Outdated
/// We use macros to reduce code repetition in generating functions to convert each Epression variant. | ||
macro_rules! into_dialect_tranlator_trait_constructor { | ||
() => { | ||
pub trait IntoDialectTranslator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RelationToQueryTranslator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
src/dialect_translation/mod.rs
Outdated
/// Build Sarus Relatioin from dialect speciific AST | ||
// macro_rules! into_ralation_tranlator_trait_constructor { | ||
// () => { | ||
pub trait IntoRelationTranslator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QueryToRelationTranslator
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
src/dialect_translation/mod.rs
Outdated
} | ||
} | ||
|
||
fn from_column(&self, ident: &expr::Identifier) -> ast::Expr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
column
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed
src/dialect_translation/mod.rs
Outdated
let ast_expr = self.expr(expr); | ||
cast_builder(ast_expr, ast::DataType::Datetime(Some(64))) | ||
} | ||
fn from_case(&self, exprs: Vec<&expr::Expr>) -> ast::Expr { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove all froms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed
src/dialect_translation/mod.rs
Outdated
fn dialect(&self) -> Self::D; | ||
|
||
// It converts ast Expressions to sarus expressions | ||
fn try_from_expr( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try_expr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
corrected
src/display/mod.rs
Outdated
.expect("Error: this works on MacOS"); | ||
.or( | ||
Command::new("xdg-open") | ||
.arg(format!("http://localhost:8000/{name}.html")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will not work, remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is needed to visualise the relations and run some tests individually when the repository is in a remote linux machine. it requires to run a html server in the /tmp/ directory. It is not general but it allows me to run some individual tests in my development environment.
src/display/mod.rs
Outdated
.expect("Error: this works on MacOS"); | ||
.or( | ||
Command::new("xdg-open") | ||
.arg(format!("http://localhost:8000/{name}.html")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you do that, please remove everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have reverted it and created the issue here
src/relation/mod.rs
Outdated
@@ -1574,6 +1574,7 @@ impl Ready<Relation> for ValuesBuilder { | |||
mod tests { | |||
use super::{schema::Schema, *}; | |||
use crate::{builder::With, data_type::DataType, display::Dot}; | |||
use crate::{ast}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why have the {} ?
Can you run cargo fmt?
src/sql/relation.rs
Outdated
@@ -43,11 +44,15 @@ This is done in the query_names module. | |||
/// The Hierarchy of Relations is the context in which the query is converted, typically the list of tables with their Path | |||
/// The QueryNames is the map of sub-query referrenced by their names, so that links can be unfolded | |||
#[derive(Clone, Debug, Hash, PartialEq, Eq)] | |||
struct TryIntoRelationVisitor<'a>(&'a Hierarchy<Arc<Relation>>, QueryNames<'a>); | |||
pub struct TryIntoRelationVisitor<'a, T: QueryToRelationTranslator + Copy + Clone> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this public?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is an error. I reverted it
No description provided.