Skip to content

Commit 2209e45

Browse files
authored
fix: String type parameters will result in double quotes and the query will be empty (#18569)
1 parent ff22a5c commit 2209e45

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

src/query/sql/src/planner/binder/bind_table_reference/bind_table_function.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ use databend_common_catalog::table_args::TableArgs;
3131
use databend_common_catalog::table_function::TableFunction;
3232
use databend_common_exception::ErrorCode;
3333
use databend_common_exception::Result;
34+
use databend_common_expression::display::scalar_ref_to_string;
3435
use databend_common_expression::types::convert_to_type_name;
3536
use databend_common_expression::types::NumberScalar;
3637
use databend_common_expression::FunctionKind;
@@ -101,11 +102,13 @@ impl Binder {
101102
span: *span,
102103
expr: Box::new(Expr::Literal {
103104
span: *span,
104-
value: Literal::String(self.table_args.positioned[pos].to_string()),
105+
value: Literal::String(scalar_ref_to_string(
106+
&self.table_args.positioned[pos].as_ref(),
107+
)),
105108
}),
106109
target_type: convert_to_type_name(ty),
107110
pg_style: false,
108-
}
111+
};
109112
}
110113
}
111114
}

tests/sqllogictests/suites/base/03_common/03_0013_select_udf.test

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,17 @@ create or replace function invalid_udtf_0 () RETURNS TABLE (c1_string string, c2
242242

243243
statement error
244244
select * from invalid_udtf_0();
245+
246+
statement ok
247+
create or replace table t2 (c1 string);
248+
249+
statement ok
250+
insert into t2 values('hello'), ('databend');
251+
252+
statement ok
253+
create or replace function filter_t2 (arg0 string) RETURNS TABLE (c1_string string) as $$ select * from t2 where c1 = arg0 $$;
254+
255+
query T
256+
select * from filter_t2('hello');
257+
----
258+
hello

0 commit comments

Comments
 (0)