Skip to content

Commit

Permalink
cleanup: panics of identifier
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 committed Dec 17, 2024
1 parent 8c4de71 commit 44bd86c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 46 deletions.
1 change: 0 additions & 1 deletion crates/proof-of-sql/benches/scaffold/random_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ pub type OptionalRandBound = Option<fn(usize) -> i64>;
/// # Panics
///
/// Will panic if:
/// - The provided identifier cannot be parsed into an `Ident` type.
/// - An unsupported `ColumnType` is encountered, triggering a panic in the `todo!()` macro.
#[allow(clippy::cast_sign_loss, clippy::cast_possible_truncation)]
pub fn generate_random_columns<'a, S: Scalar>(
Expand Down
24 changes: 6 additions & 18 deletions crates/proof-of-sql/src/base/database/owned_table_utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,7 @@ pub fn bigint<S: Scalar>(
/// boolean("a", [true, false, true]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn boolean<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<bool>>,
Expand All @@ -159,9 +157,7 @@ pub fn boolean<S: Scalar>(
/// int128("a", [1, 2, 3]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn int128<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i128>>,
Expand All @@ -181,9 +177,7 @@ pub fn int128<S: Scalar>(
/// scalar("a", [1, 2, 3]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn scalar<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<S>>,
Expand All @@ -203,9 +197,7 @@ pub fn scalar<S: Scalar>(
/// varchar("a", ["a", "b", "c"]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn varchar<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<String>>,
Expand All @@ -225,9 +217,7 @@ pub fn varchar<S: Scalar>(
/// decimal75("a", 12, 1, [1, 2, 3]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
/// - Panics if creating the `Precision` from the specified precision value fails.
pub fn decimal75<S: Scalar>(
name: impl Into<Ident>,
Expand Down Expand Up @@ -266,9 +256,7 @@ pub fn decimal75<S: Scalar>(
/// timestamptz("event_time", PoSQLTimeUnit::Second, PoSQLTimeZone::utc(), vec![1625072400, 1625076000, 1625079600]),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn timestamptz<S: Scalar>(
name: impl Into<Ident>,
time_unit: PoSQLTimeUnit,
Expand Down
28 changes: 7 additions & 21 deletions crates/proof-of-sql/src/base/database/table_utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,7 @@ pub fn borrowed_int<S: Scalar>(
/// borrowed_bigint("a", [1, 2, 3], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_bigint<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i64>>,
Expand All @@ -174,9 +172,7 @@ pub fn borrowed_bigint<S: Scalar>(
/// borrowed_boolean("a", [true, false, true], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_boolean<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<bool>>,
Expand All @@ -199,9 +195,7 @@ pub fn borrowed_boolean<S: Scalar>(
/// borrowed_int128("a", [1, 2, 3], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_int128<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i128>>,
Expand All @@ -224,9 +218,7 @@ pub fn borrowed_int128<S: Scalar>(
/// borrowed_scalar("a", [1, 2, 3], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_scalar<S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<S>>,
Expand All @@ -248,9 +240,7 @@ pub fn borrowed_scalar<S: Scalar>(
/// borrowed_varchar("a", ["a", "b", "c"], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_varchar<'a, S: Scalar>(
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<String>>,
Expand Down Expand Up @@ -280,9 +270,7 @@ pub fn borrowed_varchar<'a, S: Scalar>(
/// borrowed_decimal75("a", 12, 1, [1, 2, 3], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
/// - Panics if creating the `Precision` from the specified precision value fails.
pub fn borrowed_decimal75<S: Scalar>(
name: impl Into<Ident>,
Expand Down Expand Up @@ -327,9 +315,7 @@ pub fn borrowed_decimal75<S: Scalar>(
/// borrowed_timestamptz("event_time", PoSQLTimeUnit::Second, PoSQLTimeZone::utc(), vec![1625072400, 1625076000, 1625079600], &alloc),
/// ]);
/// ```
///
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Ident`.
pub fn borrowed_timestamptz<S: Scalar>(
name: impl Into<Ident>,
time_unit: PoSQLTimeUnit,
Expand Down
4 changes: 2 additions & 2 deletions crates/proof-of-sql/src/sql/parse/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub enum ConversionError {
#[snafu(display("Column '{identifier}' was not found in table '{resource_id}'"))]
/// The column is missing in the table
MissingColumn {
/// The missing column ident
/// The missing column identifier
identifier: Box<Ident>,
/// The table resource id
resource_id: Box<ResourceId>,
Expand All @@ -27,7 +27,7 @@ pub enum ConversionError {
#[snafu(display("Column '{identifier}' was not found"))]
/// The column is missing (without table information)
MissingColumnWithoutTable {
/// The missing column ident
/// The missing column identifier
identifier: Box<Ident>,
},

Expand Down
4 changes: 0 additions & 4 deletions crates/proof-of-sql/src/sql/proof_exprs/test_utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ use crate::base::{
use proof_of_sql_parser::intermediate_ast::AggregationOperator;
use sqlparser::ast::Ident;

/// # Panics
/// Panics if:
/// - `name.parse()` fails, which means the provided string could not be parsed into the expected type (usually an `Ident`).
pub fn col_ref(tab: TableRef, name: &str, accessor: &impl SchemaAccessor) -> ColumnRef {
let name: Ident = name.into();
let type_col = accessor.lookup_column(tab, name.clone()).unwrap();
Expand All @@ -18,7 +15,6 @@ pub fn col_ref(tab: TableRef, name: &str, accessor: &impl SchemaAccessor) -> Col

/// # Panics
/// Panics if:
/// - `name.parse()` fails to parse the column name.
/// - `accessor.lookup_column()` returns `None`, indicating the column is not found.
pub fn column(tab: TableRef, name: &str, accessor: &impl SchemaAccessor) -> DynProofExpr {
let name: Ident = name.into();
Expand Down

0 comments on commit 44bd86c

Please sign in to comment.