-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(catalog): add function catalog (#827)
Signed-off-by: Michael Xu <[email protected]>
- Loading branch information
Showing
8 changed files
with
123 additions
and
1 deletion.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ | |
/.vscode | ||
.gdb_history | ||
risinglight | ||
/.DS_Store |
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,56 @@ | ||
// Copyright 2024 RisingLight Project Authors. Licensed under Apache-2.0. | ||
|
||
use std::fmt; | ||
use std::str::FromStr; | ||
|
||
use pretty_xmlish::helper::delegate_fmt; | ||
use pretty_xmlish::Pretty; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::*; | ||
|
||
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Clone, Serialize, Deserialize)] | ||
pub struct CreateFunction { | ||
name: String, | ||
arg_types: Vec<DataType>, | ||
return_types: DataType, | ||
language: String, | ||
body: String, | ||
} | ||
|
||
impl fmt::Display for CreateFunction { | ||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { | ||
let explainer = Pretty::childless_record("CreateFunction", self.pretty_function()); | ||
delegate_fmt(&explainer, f, String::with_capacity(1000)) | ||
} | ||
} | ||
|
||
impl FromStr for CreateFunction { | ||
type Err = (); | ||
|
||
fn from_str(_s: &str) -> std::result::Result<Self, Self::Err> { | ||
Err(()) | ||
} | ||
} | ||
|
||
impl CreateFunction { | ||
pub fn pretty_function<'a>(&self) -> Vec<(&'a str, Pretty<'a>)> { | ||
vec![ | ||
("name", Pretty::display(&self.name)), | ||
("language", Pretty::display(&self.language)), | ||
("body", Pretty::display(&self.body)), | ||
] | ||
} | ||
} | ||
|
||
impl Binder { | ||
pub(super) fn bind_create_function( | ||
&mut self, | ||
_name: ObjectName, | ||
_args: Option<Vec<OperateFunctionArg>>, | ||
_return_type: Option<DataType>, | ||
_params: CreateFunctionBody, | ||
) -> Result { | ||
todo!() | ||
} | ||
} |
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,42 @@ | ||
// Copyright 2024 RisingLight Project Authors. Licensed under Apache-2.0. | ||
|
||
use crate::types::DataType; | ||
|
||
#[derive(Clone, PartialEq, Eq, Hash, Debug)] | ||
pub struct FunctionCatalog { | ||
name: String, | ||
arg_types: Vec<DataType>, | ||
return_type: DataType, | ||
language: String, | ||
body: String, | ||
} | ||
|
||
impl FunctionCatalog { | ||
pub fn new( | ||
name: String, | ||
arg_types: Vec<DataType>, | ||
return_type: DataType, | ||
language: String, | ||
body: String, | ||
) -> Self { | ||
Self { | ||
name, | ||
arg_types, | ||
return_type, | ||
language, | ||
body, | ||
} | ||
} | ||
|
||
pub fn body(&self) -> String { | ||
self.body.clone() | ||
} | ||
|
||
pub fn name(&self) -> String { | ||
self.name.clone() | ||
} | ||
|
||
pub fn language(&self) -> String { | ||
self.language.clone() | ||
} | ||
} |
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