Skip to content

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

Merged
merged 32 commits into from
Dec 20, 2023
Merged

Implement dialect translators #173

merged 32 commits into from
Dec 20, 2023

Conversation

andicuko
Copy link
Contributor

@andicuko andicuko commented Nov 6, 2023

No description provided.

@andicuko andicuko requested a review from ngrislain November 6, 2023 16:40
@andicuko andicuko self-assigned this Dec 14, 2023

// expand arms for nullay
$(
expr::function::Function::$nullay => $self.[<from_ $nullay:snake>](),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullary you mean?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected.

/// 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 {
Copy link
Contributor

@ngrislain ngrislain Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RelationToQueryTranslator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

/// Build Sarus Relatioin from dialect speciific AST
// macro_rules! into_ralation_tranlator_trait_constructor {
// () => {
pub trait IntoRelationTranslator {
Copy link
Contributor

@ngrislain ngrislain Dec 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

QueryToRelationTranslator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

}
}

fn from_column(&self, ident: &expr::Identifier) -> ast::Expr {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

column

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

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 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove all froms

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

fn dialect(&self) -> Self::D;

// It converts ast Expressions to sarus expressions
fn try_from_expr(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try_expr

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

corrected

.expect("Error: this works on MacOS");
.or(
Command::new("xdg-open")
.arg(format!("http://localhost:8000/{name}.html"))
Copy link
Contributor

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

Copy link
Contributor Author

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.

.expect("Error: this works on MacOS");
.or(
Command::new("xdg-open")
.arg(format!("http://localhost:8000/{name}.html"))
Copy link
Contributor

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.

Copy link
Contributor Author

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

@@ -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};
Copy link
Contributor

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?

@@ -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> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this public?

Copy link
Contributor Author

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

@andicuko andicuko marked this pull request as ready for review December 20, 2023 08:55
@ngrislain ngrislain merged commit 9f32e0d into main Dec 20, 2023
@ngrislain ngrislain deleted the transcriptors branch December 20, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants