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

refactor!: proof_of_sql_parser::intermediate_ast::OrderBy with sqlparser::ast::OrderByExpr in the proof-of-sql crate #450

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

varshith257
Copy link
Contributor

@varshith257 varshith257 commented Dec 31, 2024

Please be sure to look over the pull request guidelines here: https://github.com/spaceandtimelabs/sxt-proof-of-sql/blob/main/CONTRIBUTING.md#submit-pr.

Please go through the following checklist

Rationale for this change

This PR addresses the need to replace the proof_of_sql_parser::OrderBy with the sqlparser::ast::OrderByExpr in the proof-of-sql crate as part of a larger transition toward integrating the sqlparser .

This change is a subtask of issue #235, with the main goal of streamlining the repository by switching to the sqlparser crate and gradually replacing intermediary constructs like proof_of_sql_parser::intermediate_ast with sqlparser::ast.

What changes are included in this PR?

  • All instances of proof_of_sql_parser::OrderBy have been replaced with sqlparser::ast::OrderByExpr
  • Every usage of OrderBy has been updated to maintain the original functionality, ensuring no changes to the logic or behavior.

Are these changes tested?

Yes

Part of #235

@varshith257 varshith257 marked this pull request as ready for review January 3, 2025 10:44
…parser::ast::OrderByExpr` in the proof-of-sql crate
Comment on lines +128 to +141
fn owned_column_to_expr<S: Scalar>(col: &OwnedColumn<S>) -> Expr {
match col {
OwnedColumn::Boolean(_) => Expr::Identifier("BooleanColumn".into()),
OwnedColumn::TinyInt(_) => Expr::Identifier("TinyIntColumn".into()),
OwnedColumn::SmallInt(_) => Expr::Identifier("SmallIntColumn".into()),
OwnedColumn::Int(_) => Expr::Identifier("IntColumn".into()),
OwnedColumn::BigInt(_) => Expr::Identifier("BigIntColumn".into()),
OwnedColumn::VarChar(_) => Expr::Identifier("VarCharColumn".into()),
OwnedColumn::Int128(_) => Expr::Identifier("Int128Column".into()),
OwnedColumn::Decimal75(_, _, _) => Expr::Identifier("DecimalColumn".into()),
OwnedColumn::Scalar(_) => Expr::Identifier("ScalarColumn".into()),
OwnedColumn::TimestampTZ(_, _, _) => Expr::Identifier("TimestampColumn".into()),
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm this leads to duplicates, right?

@@ -0,0 +1 @@
* text=auto
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's not commit this please unless you have a very good reason
https://stackoverflow.com/questions/21472971/what-is-the-purpose-of-text-auto-in-gitattributes-file

(
col.clone(),
OrderByExpr {
expr: owned_column_to_expr(col),
Copy link
Contributor

Choose a reason for hiding this comment

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

OK we can't do this since expressions are not by default identifiers.

))
|order_by| -> PostprocessingResult<(OwnedColumn<S>, OrderByExpr)> {
let identifier = match &order_by.expr {
Expr::Identifier(ident) => ident.clone(),
Copy link
Contributor

Choose a reason for hiding this comment

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

We can order by expressions such as c0 + c1, not identifiers.

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