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::ResourceId with sqlparser::ast::ObjectName in the proof-of-sql crate #449

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

Conversation

varshith257
Copy link
Contributor

@varshith257 varshith257 commented Dec 30, 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::ResourceId with the sqlparser::ast::ObjectName 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::ResourceId have been replaced with sqlparser::ast::ObjectName
  • A few of them required a ResourceId (e.g. Select etc..), which depends on the ResourceId and will be migrated at the refactoring of Exprs.
  • Every usage of ResourceId has been updated to maintain the original functionality, ensuring no changes to the logic or behavior.
  • The breaking change here is that ObjectName doesn't support Copy trait so we have needed few clones in the places where values are moved

Are these changes tested?

Yes

Part of #235
Fixes #352

@iajoiner iajoiner self-requested a review January 2, 2025 07:53
Copy link
Contributor

@iajoiner iajoiner left a comment

Choose a reason for hiding this comment

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

Really thanks for your PR! I think it will be great if we add some helper function to produce a TableRef from multiple Strings / &strs. That way we can do something like table_ref(["namespace", "table_name"])

crates/proof-of-sql-parser/src/sqlparser.rs Outdated Show resolved Hide resolved
@iajoiner iajoiner marked this pull request as ready for review January 3, 2025 02:42
@varshith257 varshith257 requested a review from iajoiner January 3, 2025 10:15
…sqlparser::ast::ObjectName` in the proof-of-sql crate
Comment on lines +12 to +20
// /// Error types for `TableRef`.
// #[derive(Snafu, Debug, PartialEq, Eq)]
// pub enum TableRefError {
// #[snafu(display("Missing schema or table identifier in ObjectName"))]
// MissingSchemaOrTable {
// /// The problematic `ObjectName`.
// object_name: ObjectName,
// },
// }
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 remove these please.

use core::{
fmt,
fmt::{Display, Formatter},
str::FromStr,
};
use proof_of_sql_parser::{impl_serde_from_str, ResourceId};
use sqlparser::ast::Ident;
// use snafu::Snafu;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same

#[must_use]
pub fn new(resource_id: ResourceId) -> Self {
Self { resource_id }
pub fn new(object_name: ObjectName) -> Self {
Copy link
Contributor

@iajoiner iajoiner Jan 6, 2025

Choose a reason for hiding this comment

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

Hmm we either do not allow ObjectName with other than one or two Ident for TableRef or we can put two Idents there with schema_name optional. Personally I prefer the latter option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants