|
20 | 20 | import org.apache.calcite.rex.RexCall; |
21 | 21 | import org.apache.calcite.rex.RexNode; |
22 | 22 | import org.apache.calcite.sql.SqlKind; |
| 23 | +import org.apache.calcite.sql.fun.SqlStdOperatorTable; |
23 | 24 | import org.junit.jupiter.api.Test; |
24 | 25 |
|
25 | 26 | /** |
@@ -212,6 +213,31 @@ void concatStringLiteralAndChar() throws Exception { |
212 | 213 | assertProtoPlanRoundrip("select 'brand_'||P_BRAND from PART"); |
213 | 214 | } |
214 | 215 |
|
| 216 | + @Test |
| 217 | + void variadicConcat() { |
| 218 | + ScalarFunctionInvocation concat = |
| 219 | + sb.scalarFn( |
| 220 | + DefaultExtensionCatalog.FUNCTIONS_STRING, |
| 221 | + "concat:str", |
| 222 | + TypeCreator.REQUIRED.STRING, |
| 223 | + Expression.StrLiteral.builder().value("a").build(), |
| 224 | + Expression.StrLiteral.builder().value("b").build(), |
| 225 | + Expression.StrLiteral.builder().value("c").build()); |
| 226 | + |
| 227 | + RexCall outer = |
| 228 | + assertInstanceOf( |
| 229 | + RexCall.class, concat.accept(expressionRexConverter, Context.newContext())); |
| 230 | + assertEquals(SqlStdOperatorTable.CONCAT, outer.getOperator()); |
| 231 | + assertEquals(2, outer.getOperands().size()); |
| 232 | + |
| 233 | + RexCall inner = assertInstanceOf(RexCall.class, outer.getOperands().get(0)); |
| 234 | + assertEquals(SqlStdOperatorTable.CONCAT, inner.getOperator()); |
| 235 | + assertEquals(2, inner.getOperands().size()); |
| 236 | + assertEquals("'a':VARCHAR", inner.getOperands().get(0).toString()); |
| 237 | + assertEquals("'b':VARCHAR", inner.getOperands().get(1).toString()); |
| 238 | + assertEquals("'c':VARCHAR", outer.getOperands().get(1).toString()); |
| 239 | + } |
| 240 | + |
215 | 241 | @Test |
216 | 242 | void strptimeTime() { |
217 | 243 | Expression.StrLiteral inputString = Expression.StrLiteral.builder().value("12:34:56").build(); |
|
0 commit comments