Repository: risingwavelabs/risingwave (language: python)

Issue:
Sqlsmith: Sql feature generation
As we add more features, these should be tested via sqlsmith as well.

SQL Features:
- [ ] Generate other table functions: `generate_series`, `unnest`. See: https://github.com/singularity-data/risingwave/issues/4540
- [ ] Generate array_agg, jsonb_agg, jsonb_object_agg
- [ ] Generate select from System Tables
- [ ] Generate `NATURAL JOIN`
- [ ] Generate `JOIN` with `USING`
- [ ] Generate query w/o `GROUP BY`
- [ ] Randomly toggle session variables
- [ ] Generate `pow`/`exp`.
- [ ] Generate TopN by group: https://www.risingwave.dev/docs/current/sql-pattern-topn/
- [ ] Generate jsonb exprs, see: https://github.com/risingwavelabs/risingwave/issues/7714
- [ ] #7132
- [x] Generate order-by-clauses with `NULLS { FIRST | LAST }` (will be done in https://github.com/risingwavelabs/risingwave/pull/10864/commits/000cbc11cbc04f20abfd127b1bf4b3fd24e75c44)
- [ ] Generate `max`,`min`,`count` for `timestamptz`
- [ ] Generate `bit_and`, `bit_or` and `big_xor` in batch queries, and `bit_xor` in streaming queries.
- [ ] Generate array range access.
- [ ] https://github.com/risingwavelabs/risingwave/issues/10241
- [ ] Generate window functions other than `row_number`, `rank`.
- [ ] Generate `ALTER` DDL statements.\
- [ ] https://github.com/risingwavelabs/risingwave/issues/10516
- [ ] Generate temporal filter in sqlsmith


Discussion / hints:

Fix patch:
diff --git a/src/frontend/src/binder/expr/function/builtin_scalar.rs b/src/frontend/src/binder/expr/function/builtin_scalar.rs
index 5859d54c26d96..39b2b02a99753 100644
--- a/src/frontend/src/binder/expr/function/builtin_scalar.rs
+++ b/src/frontend/src/binder/expr/function/builtin_scalar.rs
@@ -533,6 +533,13 @@ impl Binder {
                         .into())
                     }
                 })),
+                ("pg_my_temp_schema", guard_by_len(0, raw(|_binder, _inputs| {
+                    // Returns the OID of the current session's temporary schema, or zero if it has none (because it has not created any temporary tables).
+                    Ok(ExprImpl::literal_int(
+                        // always return 0, as we haven't supported temporary tables nor temporary schema yet
+                        0,
+                    ))
+                }))),
                 ("current_setting", guard_by_len(1, raw(|binder, inputs| {
                     let input = &inputs[0];
                     let input = if let ExprImpl::Literal(literal) = input &&
diff --git a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_proc.rs b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_proc.rs
index 2f2abce7a0b8e..d23d7ea933168 100644
--- a/src/frontend/src/catalog/system_catalog/pg_catalog/pg_proc.rs
+++ b/src/frontend/src/catalog/system_catalog/pg_catalog/pg_proc.rs
@@ -31,4 +31,5 @@ struct PgProc {
     // Data type of the return value, refer to pg_type.
     prorettype: i32,
     prokind: String,
+    proargtypes: Vec<i32>,
 }
diff --git a/src/frontend/src/expr/function_impl/pg_get_viewdef.rs b/src/frontend/src/expr/function_impl/pg_get_viewdef.rs
index fda4eb961501c..413af0626d163 100644
--- a/src/frontend/src/expr/function_impl/pg_get_viewdef.rs
+++ b/src/frontend/src/expr/function_impl/pg_get_viewdef.rs
@@ -24,6 +24,11 @@ use crate::catalog::CatalogReader;
 
 #[function("pg_get_viewdef(int4) -> varchar")]
 fn pg_get_viewdef(oid: i32, writer: &mut impl Write) -> Result<()> {
+    pg_get_viewdef_pretty(oid, false, writer)
+}
+
+#[function("pg_get_viewdef(int4, boolean) -> varchar")]
+fn pg_get_viewdef_pretty(oid: i32, _pretty: bool, writer: &mut impl Write) -> Result<()> {
     pg_get_viewdef_impl_captured(oid, writer)
 }
 


Test patch:
diff --git a/e2e_test/batch/catalog/sysinfo.slt.part b/e2e_test/batch/catalog/sysinfo.slt.part
index 5c9aea2fb6103..ea3a3654804e5 100644
--- a/e2e_test/batch/catalog/sysinfo.slt.part
+++ b/e2e_test/batch/catalog/sysinfo.slt.part
@@ -70,6 +70,16 @@ select pg_get_viewdef('tab_mv'::regclass);
 ----
 SELECT a.c AS ac, b.c AS bc FROM tab AS a JOIN tab AS b ON a.a = b.b
 
+query T
+select pg_get_viewdef('tab_mv'::regclass, false);
+----
+SELECT a.c AS ac, b.c AS bc FROM tab AS a JOIN tab AS b ON a.a = b.b
+
+query T
+select pg_get_viewdef('tab_mv'::regclass, true);
+----
+SELECT a.c AS ac, b.c AS bc FROM tab AS a JOIN tab AS b ON a.a = b.b
+
 query error Invalid parameter oid: view or materialized view does not exist:
 select pg_get_viewdef('tab'::regclass);