Skip to content

Commit

Permalink
fix review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
varshith257 authored and varshith257 committed Dec 12, 2024
1 parent 8074df3 commit 0be1a68
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl<S: Scalar> TryFrom<RecordBatch> for OwnedTable<S> {
.zip(value.columns())
.map(|(field, array_ref)| {
let owned_column = OwnedColumn::try_from(array_ref)?;
let identifier = Ident::new(field.name()); //This may always succeed.
let identifier = Ident::new(field.name());
Ok((identifier, owned_column))
})
.collect();
Expand Down
41 changes: 20 additions & 21 deletions crates/proof-of-sql/src/base/database/owned_table_utility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use super::{OwnedColumn, OwnedTable};
use crate::base::scalar::Scalar;
use alloc::string::String;
use core::ops::Deref;
use proof_of_sql_parser::posql_time::{PoSQLTimeUnit, PoSQLTimeZone};
use sqlparser::ast::Ident;

Expand Down Expand Up @@ -58,11 +57,11 @@ pub fn owned_table<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn tinyint<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i8>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::TinyInt(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -79,11 +78,11 @@ pub fn tinyint<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn smallint<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i16>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::SmallInt(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -100,11 +99,11 @@ pub fn smallint<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn int<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i32>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::Int(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -120,11 +119,11 @@ pub fn int<S: Scalar>(
/// ```
#[allow(clippy::missing_panics_doc)]
pub fn bigint<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i64>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::BigInt(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -142,11 +141,11 @@ pub fn bigint<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn boolean<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<bool>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::Boolean(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -164,11 +163,11 @@ pub fn boolean<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn int128<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<i128>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::Int128(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -186,11 +185,11 @@ pub fn int128<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn scalar<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<S>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::Scalar(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -208,11 +207,11 @@ pub fn scalar<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn varchar<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
data: impl IntoIterator<Item = impl Into<String>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::VarChar(data.into_iter().map(Into::into).collect()),
)
}
Expand All @@ -231,13 +230,13 @@ pub fn varchar<S: Scalar>(
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
/// - Panics if creating the `Precision` from the specified precision value fails.
pub fn decimal75<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
precision: u8,
scale: i8,
data: impl IntoIterator<Item = impl Into<S>>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::Decimal75(
crate::base::math::decimal::Precision::new(precision).unwrap(),
scale,
Expand Down Expand Up @@ -271,13 +270,13 @@ pub fn decimal75<S: Scalar>(
/// # Panics
/// - Panics if `name.parse()` fails to convert the name into an `Identifier`.
pub fn timestamptz<S: Scalar>(
name: impl Deref<Target = str>,
name: impl Into<Ident>,
time_unit: PoSQLTimeUnit,
timezone: PoSQLTimeZone,
data: impl IntoIterator<Item = i64>,
) -> (Ident, OwnedColumn<S>) {
(
name.deref().into(),
name.into(),
OwnedColumn::TimestampTZ(time_unit, timezone, data.into_iter().collect()),
)
}

0 comments on commit 0be1a68

Please sign in to comment.