Skip to content

Commit

Permalink
more
Browse files Browse the repository at this point in the history
  • Loading branch information
scsmithr committed Dec 17, 2024
1 parent 548dc1e commit 0dc5f2b
Show file tree
Hide file tree
Showing 14 changed files with 264 additions and 0 deletions.
2 changes: 2 additions & 0 deletions crates/rayexec_execution/src/functions/documentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ pub enum Category {
Interval,
List,
String,
Regexp,
Binary,
}

/// Documentation for a single function variant.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::UnaryExecutor;
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -23,6 +24,15 @@ impl FunctionInfo for Ascii {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Int32,
doc: Some(&Documentation {
category: Category::String,
description: "Get the ascii code of the first character of the argument.",
arguments: &["string"],
example: Some(Example {
example: "ascii('h')",
output: "104",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::UnaryExecutor;
use rayexec_error::{RayexecError, Result};

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -23,6 +24,15 @@ impl FunctionInfo for Lower {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation {
category: Category::String,
description: "Convert the string to lowercase.",
arguments: &["string"],
example: Some(Example {
example: "lower('ABC')",
output: "abc",
}),
}),
}]
}
}
Expand Down Expand Up @@ -69,6 +79,15 @@ impl FunctionInfo for Upper {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation {
category: Category::String,
description: "Convert the string to uppercase.",
arguments: &["string"],
example: Some(Example {
example: "lower('abc')",
output: "ABC",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::{BinaryExecutor, UniformExecutor};
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -26,6 +27,15 @@ impl FunctionInfo for Concat {
positional_args: &[],
variadic_arg: Some(DataTypeId::Utf8),
return_type: DataTypeId::Utf8,
doc: Some(&Documentation {
category: Category::String,
description: "Concatenate many strings into a single string.",
arguments: &["var_args"],
example: Some(Example {
example: "concat('cat', 'dog', 'mouse')",
output: "catdogmouse",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::{BinaryExecutor, UnaryExecutor};
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -25,6 +26,15 @@ impl FunctionInfo for Contains {
positional_args: &[DataTypeId::Utf8, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Boolean,
doc: Some(&Documentation {
category: Category::String,
description: "Check if string contains a search string.",
arguments: &["string", "search"],
example: Some(Example {
example: "contains('house', 'ou')",
output: "true",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::{BinaryExecutor, UnaryExecutor};
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -29,6 +30,15 @@ impl FunctionInfo for EndsWith {
positional_args: &[DataTypeId::Utf8, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Boolean,
doc: Some(&Documentation {
category: Category::String,
description: "Check if a string ends with a given suffix.",
arguments: &["string", "suffix"],
example: Some(Example {
example: "ends_with('house', 'se')",
output: "true",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::UnaryExecutor;
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -27,6 +28,15 @@ impl FunctionInfo for Length {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Int64,
doc: Some(&Documentation {
category: Category::String,
description: "Get the number of characters in a string.",
arguments: &["string"],
example: Some(Example {
example: "length('tschüß')",
output: "6",
}),
}),
}]
}
}
Expand Down Expand Up @@ -87,11 +97,26 @@ impl FunctionInfo for ByteLength {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Int64,
doc: Some(&Documentation {
category: Category::String,
description: "Get the number of bytes in a string.",
arguments: &["string"],
example: Some(Example {
example: "byte_length('tschüß')",
output: "6",
}),
}),
},
Signature {
positional_args: &[DataTypeId::Binary],
variadic_arg: None,
return_type: DataTypeId::Int64,
doc: Some(&Documentation {
category: Category::String,
description: "Get the number of bytes in a binary blob.",
arguments: &["blob"],
example: None,
}),
},
]
}
Expand Down Expand Up @@ -149,11 +174,26 @@ impl FunctionInfo for BitLength {
positional_args: &[DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Int64,
doc: Some(&Documentation {
category: Category::String,
description: "Get the number of bits in a string.",
arguments: &["string"],
example: Some(Example {
example: "bit_length('tschüß')",
output: "64",
}),
}),
},
Signature {
positional_args: &[DataTypeId::Binary],
variadic_arg: None,
return_type: DataTypeId::Int64,
doc: Some(&Documentation {
category: Category::String,
description: "Get the number of bits in a binary blob.",
arguments: &["blob"],
example: None,
}),
},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rayexec_error::{Result, ResultExt};
use regex::{escape, Regex};

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -28,6 +29,15 @@ impl FunctionInfo for Like {
positional_args: &[DataTypeId::Utf8, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Boolean,
doc: Some(&Documentation {
category: Category::String,
description: "Check if a string matches the given pattern.",
arguments: &["string", "pattern"],
example: Some(Example {
example: "like('hello, world', '%world')",
output: "true",
}),
}),
},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::{BinaryExecutor, TernaryExecutor};
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{
invalid_input_types_error,
Expand All @@ -29,11 +30,29 @@ impl FunctionInfo for LeftPad {
positional_args: &[DataTypeId::Utf8, DataTypeId::Int64],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation{
category: Category::String,
description: "Left pad a string with spaces until the resulting string contains 'count' characters.",
arguments: &["string", "count"],
example: Some(Example{
example: "lpad('house', 8)",
output: " house",
}),
}),
},
Signature {
positional_args: &[DataTypeId::Utf8, DataTypeId::Int64, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation{
category: Category::String,
description: "Left pad a string with another string until the resulting string contains 'count' characters.",
arguments: &["string", "count", "pad"],
example: Some(Example{
example: "lpad('house', 8, '_')",
output: "___house",
}),
}),
},
]
}
Expand Down Expand Up @@ -123,11 +142,30 @@ impl FunctionInfo for RightPad {
positional_args: &[DataTypeId::Utf8, DataTypeId::Int64],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation{
category: Category::String,
description: "Right pad a string with spaces until the resulting string contains 'count' characters.",
arguments: &["string", "count"],
example: Some(Example{
example: "rpad('house', 8)",
output: "house ",
}),
}),
},
Signature {
positional_args: &[DataTypeId::Utf8, DataTypeId::Int64, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation{
category: Category::String,
description: "Right pad a string with another string until the resulting string contains 'count' characters.",
arguments: &["string", "count", "pad"],
example: Some(Example{
example: "rpad('house', 8, '_')",
output: "house___",
}),
}),

},
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use rayexec_error::{Result, ResultExt};
use regex::Regex;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -26,6 +27,15 @@ impl FunctionInfo for RegexpReplace {
positional_args: &[DataTypeId::Utf8, DataTypeId::Utf8, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation {
category: Category::Regexp,
description: "Replace the first regular expression match in a string.",
arguments: &["string", "regexp", "replacement"],
example: Some(Example {
example: "regexp_replace('alphabet', '[ae]', 'DOG')",
output: "DOGlphabet",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use rayexec_bullet::executor::scalar::BinaryExecutor;
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -25,6 +26,15 @@ impl FunctionInfo for Repeat {
positional_args: &[DataTypeId::Utf8, DataTypeId::Int64],
variadic_arg: None,
return_type: DataTypeId::Utf8,
doc: Some(&Documentation {
category: Category::String,
description: "Repeat a string some number of times.",
arguments: &["string", "count"],
example: Some(Example {
example: "repeat('abc', 3)",
output: "abcabcabc",
}),
}),
}]
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use rayexec_bullet::executor::scalar::{BinaryExecutor, UnaryExecutor};
use rayexec_error::Result;

use crate::expr::Expression;
use crate::functions::documentation::{Category, Documentation, Example};
use crate::functions::scalar::{PlannedScalarFunction, ScalarFunction, ScalarFunctionImpl};
use crate::functions::{invalid_input_types_error, plan_check_num_args, FunctionInfo, Signature};
use crate::logical::binder::table_list::TableList;
Expand All @@ -29,6 +30,15 @@ impl FunctionInfo for StartsWith {
positional_args: &[DataTypeId::Utf8, DataTypeId::Utf8],
variadic_arg: None,
return_type: DataTypeId::Boolean,
doc: Some(&Documentation {
category: Category::String,
description: "Check if a string starts with a prefix.",
arguments: &["string", "prefix"],
example: Some(Example {
example: "starts_with('hello', 'he')",
output: "true",
}),
}),
}]
}
}
Expand Down
Loading

0 comments on commit 0dc5f2b

Please sign in to comment.