Skip to content

Commit bf4cb9c

Browse files
committed
update call syntax
1 parent fa47061 commit bf4cb9c

File tree

18 files changed

+158
-47
lines changed

18 files changed

+158
-47
lines changed

docs/docs/program_model.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ CALL my_function(table1, table2, GET('config_var'));
720720

721721
### 编译期返回数据模式解析
722722

723-
UDF 的返回数据模式(Schema)可以在编译期确定,有以下两种方式
723+
UDF 的返回数据模式(Schema)可以在编译期确定,有以下三种方式
724724

725-
#### 1. 通过 LIKE 子句指定
725+
#### 1. 通过 LIKE 子句指定表模式
726726

727727
```sql
728728
CALL my_function(input_table) LIKE template_table;
@@ -736,7 +736,22 @@ if (!StringUtils.isEmpty(likeTableName)) {
736736
}
737737
```
738738

739-
#### 2. 通过执行 eval 方法推断
739+
#### 2. 通过 LIKE FUNCTION 子句指定函数模式
740+
741+
```sql
742+
CALL my_function(input_table) LIKE FUNCTION 'template_function';
743+
```
744+
745+
编译时,系统会从指定的函数获取返回数据模式:
746+
747+
```java
748+
if (likeFunctionName != null) {
749+
SqlFunctionBindable likeFunctionBindable = compileManager.getSqlFunction(likeFunctionName);
750+
returnDataFields = likeFunctionBindable.getReturnDataFields();
751+
}
752+
```
753+
754+
#### 3. 通过执行 eval 方法推断
740755

741756
如果没有 LIKE 子句,系统会在编译期执行一次 `eval` 方法来推断返回模式:
742757

docs/docs/sql_reference.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ DESC SQL FUNCTION my_function;
615615

616616
```sql
617617
CACHE TABLE table_name AS
618-
{CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
618+
{CALL function_name([arg1, arg2, ...]) [LIKE {like_table | FUNCTION 'function_name'}] [ASYNC]
619619
| select_statement}
620620
```
621621

@@ -627,6 +627,7 @@ CACHE TABLE table_name AS
627627
| `function_name` | 要调用的函数名称,可以是标识符或 `GET()` 表达式 |
628628
| `arg1, arg2, ...` | 函数参数,可以是标识符、`GET()` 表达式或字符串字面量 |
629629
| `like_table` | 可选。指定结果表的模板表 |
630+
| `FUNCTION 'function_name'` | 可选。指定结果表的模式与某个函数的输出模式相同 |
630631
| `ASYNC` | 可选。异步执行 |
631632
| `select_statement` | SELECT 查询语句 |
632633

@@ -642,6 +643,9 @@ CALL my_function('param1', 'param2');
642643
CACHE TABLE cached_result AS
643644
CALL my_function(GET('var1'), 'param2') LIKE template_table;
644645

646+
CACHE TABLE cached_result AS
647+
CALL my_function(GET('var1'), 'param2') LIKE FUNCTION 'template_function';
648+
645649
CACHE TABLE cached_result AS
646650
CALL my_function('param1') ASYNC;
647651
```
@@ -656,7 +660,7 @@ CALL my_function('param1') ASYNC;
656660
**语法:**
657661

658662
```sql
659-
CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
663+
CALL function_name([arg1, arg2, ...]) [LIKE {like_table | FUNCTION 'function_name'}] [ASYNC]
660664
```
661665

662666
**参数:**
@@ -666,6 +670,7 @@ CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
666670
| `function_name` | 函数名称,可以是标识符或 `GET()` 表达式 |
667671
| `arg1, arg2, ...` | 函数参数,可以是标识符、`GET()` 表达式或字符串字面量 |
668672
| `like_table` | 可选。指定结果表的模板表 |
673+
| `FUNCTION 'function_name'` | 可选。指定结果表的模式与某个函数的输出模式相同 |
669674
| `ASYNC` | 可选。异步执行 |
670675

671676
**示例:**
@@ -675,6 +680,8 @@ CALL my_function('param1', 'param2');
675680

676681
CALL my_function(GET('var1'), 'param2') LIKE template_table;
677682

683+
CALL my_function(GET('var1'), 'param2') LIKE FUNCTION 'template_function';
684+
678685
CALL my_function('param1') ASYNC;
679686

680687
CALL GET('fun1')(GET('id'), t1, '10') LIKE t1;

docs/en/docs/program_model.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -720,9 +720,9 @@ CALL my_function(table1, table2, GET('config_var'));
720720

721721
### Compile-time Return Data Schema Resolution
722722

723-
UDF return data schema (Schema) can be determined at compile time in two ways:
723+
UDF return data schema (Schema) can be determined at compile time in three ways:
724724

725-
#### 1. Specify via LIKE Clause
725+
#### 1. Specify via LIKE Clause with Table
726726

727727
```sql
728728
CALL my_function(input_table) LIKE template_table;
@@ -736,7 +736,22 @@ if (!StringUtils.isEmpty(likeTableName)) {
736736
}
737737
```
738738

739-
#### 2. Infer via Executing eval Method
739+
#### 2. Specify via LIKE FUNCTION Clause
740+
741+
```sql
742+
CALL my_function(input_table) LIKE FUNCTION 'template_function';
743+
```
744+
745+
At compile time, the system gets the return data schema from the specified function:
746+
747+
```java
748+
if (likeFunctionName != null) {
749+
SqlFunctionBindable likeFunctionBindable = compileManager.getSqlFunction(likeFunctionName);
750+
returnDataFields = likeFunctionBindable.getReturnDataFields();
751+
}
752+
```
753+
754+
#### 3. Infer via Executing eval Method
740755

741756
If there's no LIKE clause, the system executes the `eval` method once at compile time to infer the return schema:
742757

docs/en/docs/sql_reference.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Cache query results or function call results to a specified table.
615615

616616
```sql
617617
CACHE TABLE table_name AS
618-
{CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
618+
{CALL function_name([arg1, arg2, ...]) [LIKE {like_table | FUNCTION 'function_name'}] [ASYNC]
619619
| select_statement}
620620
```
621621

@@ -627,6 +627,7 @@ CACHE TABLE table_name AS
627627
| `function_name` | Function name to call, can be an identifier or `GET()` expression |
628628
| `arg1, arg2, ...` | Function parameters, can be identifiers, `GET()` expressions, or string literals |
629629
| `like_table` | Optional. Specify template table for result table |
630+
| `FUNCTION 'function_name'` | Optional. Specify that the result table schema matches the output schema of a function |
630631
| `ASYNC` | Optional. Execute asynchronously |
631632
| `select_statement` | SELECT query statement |
632633

@@ -642,6 +643,9 @@ CALL my_function('param1', 'param2');
642643
CACHE TABLE cached_result AS
643644
CALL my_function(GET('var1'), 'param2') LIKE template_table;
644645

646+
CACHE TABLE cached_result AS
647+
CALL my_function(GET('var1'), 'param2') LIKE FUNCTION 'template_function';
648+
645649
CACHE TABLE cached_result AS
646650
CALL my_function('param1') ASYNC;
647651
```
@@ -656,7 +660,7 @@ Call a SQL function.
656660
**Syntax:**
657661

658662
```sql
659-
CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
663+
CALL function_name([arg1, arg2, ...]) [LIKE {like_table | FUNCTION 'function_name'}] [ASYNC]
660664
```
661665

662666
**Parameters:**
@@ -666,6 +670,7 @@ CALL function_name([arg1, arg2, ...]) [LIKE like_table] [ASYNC]
666670
| `function_name` | Function name, can be an identifier or `GET()` expression |
667671
| `arg1, arg2, ...` | Function parameters, can be identifiers, `GET()` expressions, or string literals |
668672
| `like_table` | Optional. Specify template table for result table |
673+
| `FUNCTION 'function_name'` | Optional. Specify that the result table schema matches the output schema of a function |
669674
| `ASYNC` | Optional. Execute asynchronously |
670675

671676
**Examples:**
@@ -675,6 +680,8 @@ CALL my_function('param1', 'param2');
675680

676681
CALL my_function(GET('var1'), 'param2') LIKE template_table;
677682

683+
CALL my_function(GET('var1'), 'param2') LIKE FUNCTION 'template_function';
684+
678685
CALL my_function('param1') ASYNC;
679686

680687
CALL GET('fun1')(GET('id'), t1, '10') LIKE t1;

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@
1919
</modules>
2020

2121
<properties>
22-
<maven.compiler.source>8</maven.compiler.source>
23-
<maven.compiler.target>8</maven.compiler.target>
22+
<maven.compiler.source>11</maven.compiler.source>
23+
<maven.compiler.target>11</maven.compiler.target>
2424
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2525
<calcite.version>1.32.0</calcite.version>
2626
<flink.version>1.19.0</flink.version>

sqlrec-common/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>sqlrec-common</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>8</maven.compiler.source>
16-
<maven.compiler.target>8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919

sqlrec-connectors/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
</modules>
1919

2020
<properties>
21-
<maven.compiler.source>8</maven.compiler.source>
22-
<maven.compiler.target>8</maven.compiler.target>
21+
<maven.compiler.source>11</maven.compiler.source>
22+
<maven.compiler.target>11</maven.compiler.target>
2323
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
2424
</properties>
2525

sqlrec-connectors/sqlrec-connector-kafka/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>sqlrec-connector-kafka</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>8</maven.compiler.source>
16-
<maven.compiler.target>8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919
<dependencies>

sqlrec-connectors/sqlrec-connector-milvus/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>sqlrec-connector-milvus</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>8</maven.compiler.source>
16-
<maven.compiler.target>8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919

sqlrec-connectors/sqlrec-connector-redis/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
<artifactId>sqlrec-connector-redis</artifactId>
1313

1414
<properties>
15-
<maven.compiler.source>8</maven.compiler.source>
16-
<maven.compiler.target>8</maven.compiler.target>
15+
<maven.compiler.source>11</maven.compiler.source>
16+
<maven.compiler.target>11</maven.compiler.target>
1717
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1818
</properties>
1919

0 commit comments

Comments
 (0)