This is an automated email from the ASF dual-hosted git repository.
davidzollo pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/seatunnel.git
The following commit(s) were added to refs/heads/dev by this push:
new 77b3fd4d73 [Docs] Add zh DynamicCompile Scala example (#11130)
77b3fd4d73 is described below
commit 77b3fd4d734919db76aff9abceaca264072126ac
Author: Jast <[email protected]>
AuthorDate: Fri Jun 19 22:13:25 2026 +0800
[Docs] Add zh DynamicCompile Scala example (#11130)
---
docs/zh/transforms/dynamic-compile.md | 45 +++++++++++++++++++++++++++++++++++
1 file changed, 45 insertions(+)
diff --git a/docs/zh/transforms/dynamic-compile.md
b/docs/zh/transforms/dynamic-compile.md
index 56ec419928..7f5ca99d13 100644
--- a/docs/zh/transforms/dynamic-compile.md
+++ b/docs/zh/transforms/dynamic-compile.md
@@ -33,6 +33,8 @@ DynamicCompile 转换插件提供一种可编程的方式来处理行,允许
Java中的某些语法可能不受支持,请参阅https://github.com/janino-compiler/janino
GROOVY,JAVA,SCALA(目前支持 Zeta)
+**注意**:SCALA 支持使用 Scala REPL 进行动态编译,需要编写符合 Scala 语法的代码。
+
### compile_pattern [Enum]
SOURCE_CODE,ABSOLUTE_PATH
@@ -220,6 +222,49 @@ transform {
| Kin Dom | 30 | 123 | JAVA |
| Joy Dom | 30 | 123 | JAVA |
+- 使用 Scala
+
+下面的 Scala 示例演示如何新增 `compile_language` 字段。
+
+```hacon
+transform {
+ DynamicCompile {
+ plugin_input = "fake"
+ plugin_output = "scala_out"
+ compile_language="SCALA"
+ compile_pattern="SOURCE_CODE"
+ source_code="""
+ import org.apache.seatunnel.api.table.catalog.Column
+ import org.apache.seatunnel.api.table.catalog.CatalogTable
+ import org.apache.seatunnel.api.table.catalog.PhysicalColumn
+ import
org.apache.seatunnel.api.table.`type`.SeaTunnelRowAccessor
+ import org.apache.seatunnel.api.table.`type`.BasicType
+ import java.util.ArrayList
+
+ class ScalaDemo {
+ def getInlineOutputColumns(inputCatalogTable:
CatalogTable): Array[Column] = {
+ val columns = new ArrayList[Column]()
+ val destColumn = PhysicalColumn.of(
+ "compile_language",
+ BasicType.STRING_TYPE,
+ 10L,
+ true,
+ "",
+ ""
+ )
+ columns.add(destColumn)
+ columns.toArray(new Array[Column](0))
+ }
+
+ def getInlineOutputFieldValues(inputRow:
SeaTunnelRowAccessor): Array[Object] = {
+ Array[Object]("SCALA")
+ }
+ }
+ """
+ }
+}
+```
+
更多复杂例子可以参考
https://github.com/apache/seatunnel/tree/dev/seatunnel-e2e/seatunnel-transforms-v2-e2e/seatunnel-transforms-v2-e2e-part-2/src/test/resources/dynamic_compile/conf