-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
379 additions
and
99 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright (c) 2023-2024 Retake, Inc. | ||
// | ||
// This file is part of ParadeDB - Postgres for Search and Analytics | ||
// | ||
// This program is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU Affero General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// This program is distributed in the hope that it will be useful | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU Affero General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU Affero General Public License | ||
// along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
use bigdecimal::BigDecimal; | ||
use std::str::FromStr; | ||
|
||
/// Represents a constant for NULL string in your database. | ||
pub const NULL_STR: &str = "NULL"; | ||
|
||
pub(crate) fn bool_to_str(value: bool) -> String { | ||
if value { | ||
"true".to_string() | ||
} else { | ||
"false".to_string() | ||
} | ||
} | ||
|
||
pub(crate) fn varchar_to_str(value: &str) -> String { | ||
if value.is_empty() { | ||
"(empty)".to_string() | ||
} else { | ||
value.trim_end_matches('\n').to_string() | ||
} | ||
} | ||
|
||
pub(crate) fn f32_to_str(value: f32) -> String { | ||
if value.is_nan() { | ||
// The sign of NaN can be different depending on platform. | ||
// So the string representation of NaN ignores the sign. | ||
"NaN".to_string() | ||
} else if value == f32::INFINITY { | ||
"Infinity".to_string() | ||
} else if value == f32::NEG_INFINITY { | ||
"-Infinity".to_string() | ||
} else { | ||
big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap()) | ||
} | ||
} | ||
|
||
pub(crate) fn f64_to_str(value: f64) -> String { | ||
if value.is_nan() { | ||
// The sign of NaN can be different depending on platform. | ||
// So the string representation of NaN ignores the sign. | ||
"NaN".to_string() | ||
} else if value == f64::INFINITY { | ||
"Infinity".to_string() | ||
} else if value == f64::NEG_INFINITY { | ||
"-Infinity".to_string() | ||
} else { | ||
big_decimal_to_str(BigDecimal::from_str(&value.to_string()).unwrap()) | ||
} | ||
} | ||
|
||
pub(crate) fn big_decimal_to_str(value: BigDecimal) -> String { | ||
value.round(12).normalized().to_string() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
pub mod arrow; | ||
mod conversion; | ||
pub mod engine; | ||
mod error; | ||
mod normalize; | ||
mod output; |
Oops, something went wrong.