Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 13 additions & 6 deletions datafusion-postgres/src/pg_catalog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1766,6 +1766,7 @@ pub fn create_version_udf() -> ScalarUDF {
let func = move |_args: &[ColumnarValue]| {
// Create a UTF8 array with version information
let mut builder = StringBuilder::new();
// TODO: improve version string generation
builder
.append_value("DataFusion PostgreSQL 48.0.0 on x86_64-pc-linux-gnu, compiled by Rust");
let array: ArrayRef = Arc::new(builder.finish());
Expand All @@ -1787,19 +1788,22 @@ pub fn create_pg_get_userbyid_udf() -> ScalarUDF {
// Define the function implementation
let func = move |args: &[ColumnarValue]| {
let args = ColumnarValue::values_to_arrays(args)?;
let _input = &args[0]; // User OID, but we'll ignore for now
let input = &args[0]; // User OID, but we'll ignore for now

// Create a UTF8 array with default user name
let mut builder = StringBuilder::new();
builder.append_value("postgres");
for _ in 0..input.len() {
builder.append_value("postgres");
}

let array: ArrayRef = Arc::new(builder.finish());

Ok(ColumnarValue::Array(array))
};

// Wrap the implementation in a scalar function
create_udf(
"pg_get_userbyid",
"pg_catalog.pg_get_userbyid",
vec![DataType::Int32],
DataType::Utf8,
Volatility::Stable,
Expand All @@ -1811,19 +1815,22 @@ pub fn create_pg_table_is_visible() -> ScalarUDF {
// Define the function implementation
let func = move |args: &[ColumnarValue]| {
let args = ColumnarValue::values_to_arrays(args)?;
let _input = &args[0]; // Table OID
let input = &args[0]; // Table OID

// Always return true
let mut builder = BooleanBuilder::new();
builder.append_value(true);
for _ in 0..input.len() {
builder.append_value(true);
}

let array: ArrayRef = Arc::new(builder.finish());

Ok(ColumnarValue::Array(array))
};

// Wrap the implementation in a scalar function
create_udf(
"pg_table_is_visible",
"pg_catalog.pg_table_is_visible",
vec![DataType::Int32],
DataType::Boolean,
Volatility::Stable,
Expand Down
Loading