Skip to content
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

feat: sql type checking and logical plan #1708

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

joshua-spacetime
Copy link
Collaborator

Description of Changes

Defines the logical query plan and implements lowering from ast to logical plan which includes variable binding and type checking. DML is still left to do.

API and ABI breaking changes

None

Expected complexity level and risk

3

let hex = if hex.starts_with(b"0x") {
&hex[2..]
} else if hex.starts_with(b"X'") {
&hex[2..hex.len()]
Copy link
Contributor

Choose a reason for hiding this comment

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

The test compile_eq_identity_address also check for x

let b = type_ast(*b, tx)?;
assert_eq_types(a.ty(), b.ty())?;
Ok(RelExpr::Union(Box::new(a), Box::new(b)))
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Remember to add a comment or check here about checking the schemas are compatible with the union/minus projection

// Equality supports numerics, strings, and bytes
(BinOp::Eq | BinOp::Ne, Type::Alg(t))
if t.is_bool()
|| t.is_integer()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should add a trait similar to eq, ord so we instead do if t.is_comparable

] {
let result = parse_and_type_sub(sql, &tx).inspect_err(|_| {
// println!("sql: {}\n\n\terr: {}\n", sql, err);
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this way of testing could blindly let pass an unrelated error and mask something is broken.

If the idea is to make checking for the error easier without heavy matching, how about adding a simple enum Error{TypeCheck, FieldNotFound} that we return for the error?

field: &str,
expected: Option<&Type>,
) -> TypingResult<(usize, usize, &AlgebraicType)> {
self.find(table)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think is better to make a struct that describes what are the usize, usize here...

@joshua-spacetime joshua-spacetime marked this pull request as ready for review September 17, 2024 15:16
Copy link
Contributor

@mamcx mamcx left a comment

Choose a reason for hiding this comment

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

I approve after agree with @joshua-spacetime that some changes are for the next step

@joshua-spacetime joshua-spacetime changed the title feat: Variable resolution and type checking for sql feat: sql type checking and logical plan Sep 17, 2024
@joshua-spacetime joshua-spacetime added this pull request to the merge queue Sep 17, 2024
Merged via the queue into master with commit f047bb1 Sep 17, 2024
9 checks passed
@joshua-spacetime joshua-spacetime deleted the joshua/feat/sql/types branch September 17, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants