Skip to content

Commit e655d53

Browse files
authored
fix: udf name and pg_is_table_visible (#113)
* fix: udf name and pg_is_table_visible * fix: return value of pg_user_getbyid
1 parent ad180eb commit e655d53

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

datafusion-postgres/src/pg_catalog.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1766,6 +1766,7 @@ pub fn create_version_udf() -> ScalarUDF {
17661766
let func = move |_args: &[ColumnarValue]| {
17671767
// Create a UTF8 array with version information
17681768
let mut builder = StringBuilder::new();
1769+
// TODO: improve version string generation
17691770
builder
17701771
.append_value("DataFusion PostgreSQL 48.0.0 on x86_64-pc-linux-gnu, compiled by Rust");
17711772
let array: ArrayRef = Arc::new(builder.finish());
@@ -1787,19 +1788,22 @@ pub fn create_pg_get_userbyid_udf() -> ScalarUDF {
17871788
// Define the function implementation
17881789
let func = move |args: &[ColumnarValue]| {
17891790
let args = ColumnarValue::values_to_arrays(args)?;
1790-
let _input = &args[0]; // User OID, but we'll ignore for now
1791+
let input = &args[0]; // User OID, but we'll ignore for now
17911792

17921793
// Create a UTF8 array with default user name
17931794
let mut builder = StringBuilder::new();
1794-
builder.append_value("postgres");
1795+
for _ in 0..input.len() {
1796+
builder.append_value("postgres");
1797+
}
1798+
17951799
let array: ArrayRef = Arc::new(builder.finish());
17961800

17971801
Ok(ColumnarValue::Array(array))
17981802
};
17991803

18001804
// Wrap the implementation in a scalar function
18011805
create_udf(
1802-
"pg_get_userbyid",
1806+
"pg_catalog.pg_get_userbyid",
18031807
vec![DataType::Int32],
18041808
DataType::Utf8,
18051809
Volatility::Stable,
@@ -1811,19 +1815,22 @@ pub fn create_pg_table_is_visible() -> ScalarUDF {
18111815
// Define the function implementation
18121816
let func = move |args: &[ColumnarValue]| {
18131817
let args = ColumnarValue::values_to_arrays(args)?;
1814-
let _input = &args[0]; // Table OID
1818+
let input = &args[0]; // Table OID
18151819

18161820
// Always return true
18171821
let mut builder = BooleanBuilder::new();
1818-
builder.append_value(true);
1822+
for _ in 0..input.len() {
1823+
builder.append_value(true);
1824+
}
1825+
18191826
let array: ArrayRef = Arc::new(builder.finish());
18201827

18211828
Ok(ColumnarValue::Array(array))
18221829
};
18231830

18241831
// Wrap the implementation in a scalar function
18251832
create_udf(
1826-
"pg_table_is_visible",
1833+
"pg_catalog.pg_table_is_visible",
18271834
vec![DataType::Int32],
18281835
DataType::Boolean,
18291836
Volatility::Stable,

0 commit comments

Comments
 (0)