Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
70056c8b
Commit
70056c8b
authored
3 years ago
by
Igor Kuznetsov
Browse files
Options
Downloads
Patches
Plain Diff
feat: add api method for transforming text to Bool type
parent
7ebe1d66
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1414
sbroad import
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/ir/expression/tests.rs
+0
-1
0 additions, 1 deletion
src/ir/expression/tests.rs
src/ir/operator.rs
+28
-4
28 additions, 4 deletions
src/ir/operator.rs
with
28 additions
and
5 deletions
src/ir/expression/tests.rs
+
0
−
1
View file @
70056c8b
use
super
::
*
;
use
crate
::
ir
::
value
::
*
;
use
crate
::
ir
::
*
;
use
pretty_assertions
::
assert_eq
;
...
...
This diff is collapsed.
Click to expand it.
src/ir/operator.rs
+
28
−
4
View file @
70056c8b
//! Operators for expression transformations.
use
std
::
collections
::
HashMap
;
use
serde
::{
Deserialize
,
Serialize
};
use
crate
::
errors
::
QueryPlannerError
;
use
super
::
expression
::
Expression
;
use
super
::
relation
::
Table
;
use
super
::{
Node
,
Nodes
,
Plan
};
use
crate
::
errors
::
QueryPlannerError
;
use
serde
::{
Deserialize
,
Serialize
};
use
std
::
collections
::
HashMap
;
/// Binary operator returning Bool expression.
#[derive(Serialize,
Deserialize,
PartialEq,
Debug)]
#[derive(Serialize,
Deserialize,
PartialEq,
Debug
,
Clone
)]
pub
enum
Bool
{
/// `&&`
And
,
...
...
@@ -30,6 +33,27 @@ pub enum Bool {
Or
,
}
impl
Bool
{
/// Create `Bool` from operator string.
///
/// # Errors
/// Returns `QueryPlannerError` when the operator is invalid.
pub
fn
from
(
s
:
&
str
)
->
Result
<
Self
,
QueryPlannerError
>
{
match
s
.to_lowercase
()
.as_str
()
{
"and"
=>
Ok
(
Bool
::
And
),
"or"
=>
Ok
(
Bool
::
Or
),
"="
=>
Ok
(
Bool
::
Eq
),
"in"
=>
Ok
(
Bool
::
In
),
">"
=>
Ok
(
Bool
::
Gt
),
">="
=>
Ok
(
Bool
::
GtEq
),
"<"
=>
Ok
(
Bool
::
Lt
),
"<="
=>
Ok
(
Bool
::
LtEq
),
"!="
|
"<>"
=>
Ok
(
Bool
::
NotEq
),
_
=>
Err
(
QueryPlannerError
::
InvalidBool
),
}
}
}
/// Relational algebra operator returning a new tuple.
///
/// Transforms input tuple(s) into the output one using
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment